| | |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.bi.controller.admin.config.vo.BiChartConfigImportExcelVO; |
| | | import cn.iocoder.yudao.module.bi.controller.admin.config.vo.BiChartConfigImportReqVO; |
| | | import cn.iocoder.yudao.module.bi.controller.admin.config.vo.BiChartConfigImportRespVO; |
| | | import cn.iocoder.yudao.module.bi.dal.dataobject.BiChartConfigDO; |
| | | import cn.iocoder.yudao.module.bi.service.config.BiChartConfigService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获取图表配置") |
| | | @Parameter(name = "id", description = "编号", required = true) |
| | | @PreAuthorize("@ss.hasPermission('bi:chart-config:query')") |
| | | public CommonResult<BiChartConfigDO> get(@RequestParam("id") Long id) { |
| | | return success(chartConfigService.get(id)); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "分页查询图表配置") |
| | | @PreAuthorize("@ss.hasPermission('bi:chart-config:query')") |
| | | public CommonResult<PageResult<BiChartConfigDO>> getPage( |
| | | @RequestParam(value = "dashboardId", required = false) Long dashboardId, |
| | | @RequestParam(value = "name", required = false) String name, |
| | | @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | return success(chartConfigService.getPage(dashboardId, pageNo, pageSize)); |
| | | return success(chartConfigService.getPage(dashboardId, name, pageNo, pageSize)); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得导入图表配置模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<BiChartConfigImportExcelVO> list = Arrays.asList( |
| | | BiChartConfigImportExcelVO.builder().name("示例图表").dashboardName("示例仪表盘") |
| | | .chartType("bar").dataSourceName("示例数据源").querySql("select 1") |
| | | .position("").chartOptions("").refreshInterval(0).sort(0).status(1).build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "图表配置导入模板.xls", "图表配置列表", BiChartConfigImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入图表配置") |
| | | @PreAuthorize("@ss.hasPermission('bi:chart-config:import')") |
| | | public CommonResult<BiChartConfigImportRespVO> importExcel(@Valid BiChartConfigImportReqVO importReqVO) |
| | | throws Exception { |
| | | List<BiChartConfigImportExcelVO> list = ExcelUtils.read(importReqVO.getFile(), BiChartConfigImportExcelVO.class); |
| | | return success(chartConfigService.importChartConfigList(list, importReqVO)); |
| | | } |
| | | |
| | | } |