mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-14 13:42:07 +08:00
1、报表基础内容实现,service单元测试实现,移除report微服务中没用的单元测试内容;
2、DefaultDBFieldHandler自动填充处理类中request注入改为上下文获取;
This commit is contained in:
+77
@@ -0,0 +1,77 @@
|
||||
package com.cf.imes.module.report.controller.admin.template;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportDatasetReqVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportDatasetRespVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportDatasetSaveReqVO;
|
||||
import com.cf.imes.module.report.dal.dataobject.template.ReportDatasetDO;
|
||||
import com.cf.imes.module.report.service.template.ReportDatasetService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 报表数据集控制器
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/7/8 15:22
|
||||
*/
|
||||
@Tag(name = "管理后台 - 报表数据集")
|
||||
@RestController
|
||||
@RequestMapping("/report")
|
||||
@Validated
|
||||
public class ReportDatasetController {
|
||||
@Resource
|
||||
private ReportDatasetService datasetService;
|
||||
|
||||
@PutMapping("/dataset")
|
||||
@Operation(summary = "创建报表数据集")
|
||||
@PreAuthorize("@ss.hasPermission('report:dataset:create')")
|
||||
public CommonResult<Long> createDataset(@Valid @RequestBody ReportDatasetSaveReqVO createReqVO) {
|
||||
return success(datasetService.createDataset(createReqVO));
|
||||
}
|
||||
|
||||
@PostMapping("/dataset")
|
||||
@Operation(summary = "更新报表数据集")
|
||||
@PreAuthorize("@ss.hasPermission('report:dataset:update')")
|
||||
public CommonResult<Boolean> updateDataset(@Valid @RequestBody ReportDatasetSaveReqVO updateReqVO) {
|
||||
datasetService.updateDataset(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/dataset/{id}")
|
||||
@Operation(summary = "删除报表数据集")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('report:dataset:delete')")
|
||||
public CommonResult<Boolean> deleteDataset(@PathVariable("id") Long id) {
|
||||
datasetService.deleteDataset(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/dataset/{id}")
|
||||
@Operation(summary = "获得报表数据集")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('report:dataset:query')")
|
||||
public CommonResult<ReportDatasetRespVO> getDataset(@PathVariable("id") Long id) {
|
||||
ReportDatasetDO dataset = datasetService.getDataset(id);
|
||||
return success(BeanUtils.toBean(dataset, ReportDatasetRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/datasets")
|
||||
@Operation(summary = "获取数据源下的报表数据集列表")
|
||||
@PreAuthorize("@ss.hasPermission('report:dataset:query')")
|
||||
public CommonResult<List<ReportDatasetRespVO>> getDatasetPage(@Valid ReportDatasetReqVO pageReqVO) {
|
||||
return success(BeanUtils.toBean(datasetService.getDatasetList(pageReqVO), ReportDatasetRespVO.class));
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package com.cf.imes.module.report.controller.admin.template;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportDatasourceReqVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportDatasourceRespVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportDatasourceSaveReqVO;
|
||||
import com.cf.imes.module.report.dal.dataobject.template.ReportDatasourceDO;
|
||||
import com.cf.imes.module.report.service.template.ReportDatasourceService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 报表数据源控制器
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/7/5 16:53
|
||||
*/
|
||||
@Tag(name = "管理后台 - 报表数据源")
|
||||
@RestController
|
||||
@RequestMapping("/report/datasource")
|
||||
@Validated
|
||||
public class ReportDatasourceController {
|
||||
@Resource
|
||||
private ReportDatasourceService datasourceService;
|
||||
|
||||
@PutMapping("/datasource")
|
||||
@Operation(summary = "创建报表数据源")
|
||||
@PreAuthorize("@ss.hasPermission('report:datasource:create')")
|
||||
public CommonResult<Long> createDatasource(@Valid @RequestBody ReportDatasourceSaveReqVO createReqVO) {
|
||||
return success(datasourceService.createDatasource(createReqVO));
|
||||
}
|
||||
|
||||
@PostMapping("/datasource")
|
||||
@Operation(summary = "更新报表数据源")
|
||||
@PreAuthorize("@ss.hasPermission('report:datasource:update')")
|
||||
public CommonResult<Boolean> updateDatasource(@Valid @RequestBody ReportDatasourceSaveReqVO updateReqVO) {
|
||||
datasourceService.updateDatasource(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/datasource/{id}")
|
||||
@Operation(summary = "删除报表数据源")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1")
|
||||
@PreAuthorize("@ss.hasPermission('report:datasource:delete')")
|
||||
public CommonResult<Boolean> deleteDatasource(@PathVariable("id") Long id) {
|
||||
datasourceService.deleteDatasource(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/datasource/{id}")
|
||||
@Operation(summary = "获得报表数据源")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1")
|
||||
@PreAuthorize("@ss.hasPermission('report:datasource:query')")
|
||||
public CommonResult<ReportDatasourceRespVO> getDatasource(@PathVariable("id") Long id) {
|
||||
ReportDatasourceDO datasource = datasourceService.getDatasource(id);
|
||||
return success(BeanUtils.toBean(datasource, ReportDatasourceRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/datasources")
|
||||
@Operation(summary = "获取报表模板下的报表数据源")
|
||||
@PreAuthorize("@ss.hasPermission('report:datasource:query')")
|
||||
public CommonResult<List<ReportDatasourceRespVO>> getDatasourcePage(@Valid ReportDatasourceReqVO pageReqVO) {
|
||||
return success(BeanUtils.toBean(datasourceService.getTemplateDatasourceList(pageReqVO), ReportDatasourceRespVO.class));
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package com.cf.imes.module.report.controller.admin.template;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateReqVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateRespVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateSaveReqVO;
|
||||
import com.cf.imes.module.report.dal.dataobject.template.ReportTemplateDO;
|
||||
import com.cf.imes.module.report.service.template.ReportTemplateService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 报表模板信息控制器
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/7/3 14:22
|
||||
*/
|
||||
@Tag(name = "管理后台 - 报表模板信息")
|
||||
@RestController
|
||||
@RequestMapping("/report")
|
||||
@Validated
|
||||
public class ReportTemplateController {
|
||||
@Autowired
|
||||
private ReportTemplateService templateService;
|
||||
|
||||
@PutMapping("/template")
|
||||
@Operation(summary = "创建报表模板信息")
|
||||
@PreAuthorize("@ss.hasPermission('report:template:create')")
|
||||
@PermitAll
|
||||
public CommonResult<Long> createTemplate(@Valid @RequestBody ReportTemplateSaveReqVO createReqVO) {
|
||||
OrganContextHolder.setOrganId(1L);
|
||||
return success(templateService.createReportTemplate(createReqVO));
|
||||
}
|
||||
|
||||
@PostMapping("/template")
|
||||
@Operation(summary = "更新报表模板信息")
|
||||
@PreAuthorize("@ss.hasPermission('report:template:update')")
|
||||
public CommonResult<Boolean> updateTemplate(@Valid @RequestBody ReportTemplateSaveReqVO updateReqVO) {
|
||||
templateService.updateReportTemplate(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/template/{id}")
|
||||
@Operation(summary = "删除报表模板信息")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('report:template:delete')")
|
||||
public CommonResult<Boolean> deleteReportTemplate(@PathVariable("id") Long id) {
|
||||
templateService.deleteReportTemplate(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/template/{id}")
|
||||
@Operation(summary = "获得报表模板信息")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1")
|
||||
@PreAuthorize("@ss.hasPermission('report:template:query')")
|
||||
public CommonResult<ReportTemplateRespVO> getReportTemplate(@PathVariable("id") Long id) {
|
||||
ReportTemplateDO template = templateService.getReportTemplate(id);
|
||||
return success(BeanUtils.toBean(template, ReportTemplateRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/templates")
|
||||
@Operation(summary = "获得报表模板信息列表")
|
||||
@PreAuthorize("@ss.hasPermission('report:template:query')")
|
||||
@PermitAll
|
||||
public CommonResult<List<ReportTemplateRespVO>> getTemplatePage(@Valid ReportTemplateReqVO pageReqVO) {
|
||||
return success(BeanUtils.toBean(templateService.getReportTemplateList(pageReqVO), ReportTemplateRespVO.class));
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.cf.imes.module.report.controller.admin.template.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/7/8 11:36
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ReportDatasetParameterVO {
|
||||
/**
|
||||
* 参数名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 默认值
|
||||
*/
|
||||
private String defaultValue;
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.cf.imes.module.report.controller.admin.template.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/7/8 10:58
|
||||
*/
|
||||
@Schema(description = "管理后台 - 报表数据集 Request VO")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class ReportDatasetReqVO {
|
||||
@Schema(description = "数据集名称", example = "测试数据集")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "数据源id", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Long datasourceId;
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.cf.imes.module.report.controller.admin.template.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/7/8 11:01
|
||||
*/
|
||||
@Schema(description = "管理后台 - 报表数据集 Response VO")
|
||||
@Data
|
||||
public class ReportDatasetRespVO {
|
||||
@Schema(description = "数据集id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "数据集名称", example = "测试数据集")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "数据源id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long datasourceId;
|
||||
|
||||
@Schema(description = "动态查询SQL")
|
||||
private String dbSql;
|
||||
|
||||
@Schema(description = "参数列表")
|
||||
private List<ReportDatasetParameterVO> params;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.cf.imes.module.report.controller.admin.template.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/7/8 11:01
|
||||
*/
|
||||
@Schema(description = "管理后台 - 报表数据集新增/修改 Request VO")
|
||||
@Data
|
||||
@Builder
|
||||
public class ReportDatasetSaveReqVO {
|
||||
@Schema(description = "数据集id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "数据集名称", example = "测试数据集")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "数据源id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "数据源id不能为空")
|
||||
private Long datasourceId;
|
||||
|
||||
@Schema(description = "动态查询SQL")
|
||||
private String dbSql;
|
||||
|
||||
@Schema(description = "参数列表")
|
||||
private List<ReportDatasetParameterVO> params;
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.cf.imes.module.report.controller.admin.template.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/7/8 11:01
|
||||
*/
|
||||
@Schema(description = "管理后台 - 报表数据源 Request VO")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class ReportDatasourceReqVO {
|
||||
@Schema(description = "模板id", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Long reportId;
|
||||
|
||||
@Schema(description = "数据源名称", example = "测试库")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "模板类型,0内置、1自定义", example = "0")
|
||||
private Integer type;
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package com.cf.imes.module.report.controller.admin.template.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/7/5 16:34
|
||||
*/
|
||||
@Schema(description = "管理后台 - 报表数据源 Response VO")
|
||||
@Data
|
||||
public class ReportDatasourceRespVO {
|
||||
|
||||
@Schema(description = "数据源id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "模板id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long reportId;
|
||||
|
||||
@Schema(description = "数据源名称", example = "测试库")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "模板类型,0内置、1自定义", example = "0")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "数据源驱动类",example = "com.mysql.cj.jdbc.Driver")
|
||||
private String dbDriver;
|
||||
|
||||
@Schema(description = "数据源地址", example = "https://www.cf.com")
|
||||
private String dbUrl;
|
||||
|
||||
@Schema(description = "数据源用户名", example = "晨丰")
|
||||
private String dbUsername;
|
||||
|
||||
@Schema(description = "数据源密码", example = "晨丰")
|
||||
private String dbPassword;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "备注", example = "该模板仅供生产使用")
|
||||
private String remark;
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.cf.imes.module.report.controller.admin.template.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/7/8 11:01
|
||||
*/
|
||||
@Schema(description = "管理后台 - 报表数据源新增/修改 Request VO")
|
||||
@Data
|
||||
@Builder
|
||||
public class ReportDatasourceSaveReqVO {
|
||||
@Schema(description = "数据源id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "模板id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "模板id不能为空")
|
||||
private Long reportId;
|
||||
|
||||
@Schema(description = "数据源名称", example = "测试库")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "模板类型,0内置、1自定义", example = "0")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "数据源驱动类",example = "com.mysql.cj.jdbc.Driver")
|
||||
private String dbDriver;
|
||||
|
||||
@Schema(description = "数据源地址", example = "https://www.cf.com")
|
||||
private String dbUrl;
|
||||
|
||||
@Schema(description = "数据源用户名", example = "晨丰")
|
||||
private String dbUsername;
|
||||
|
||||
@Schema(description = "数据源密码", example = "晨丰")
|
||||
private String dbPassword;
|
||||
|
||||
@Schema(description = "备注", example = "该模板仅供生产使用")
|
||||
private String remark;
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.cf.imes.module.report.controller.admin.template.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/7/3 11:49
|
||||
*/
|
||||
@Schema(description = "管理后台 - 报表模板信息列表 Request VO")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class ReportTemplateReqVO {
|
||||
@Schema(description = "模板名称", example = "生产单模板")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "模板类型,0内置、1自定义", example = "1")
|
||||
private Integer type;
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.cf.imes.module.report.controller.admin.template.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/7/3 11:53
|
||||
*/
|
||||
@Schema(description = "管理后台 - 报表模板信息 Response VO")
|
||||
@Data
|
||||
public class ReportTemplateRespVO {
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "15176")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "模板名称", example = "生产单模板")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "报表模板")
|
||||
private String template;
|
||||
|
||||
@Schema(description = "模板类型,0内置、1自定义", example = "2")
|
||||
private Long type;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "备注", example = "该模板仅供生产使用")
|
||||
private String remark;
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.cf.imes.module.report.controller.admin.template.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/7/3 11:58
|
||||
*/
|
||||
@Schema(description = "管理后台 - 报表模板信息新增/修改 Request VO")
|
||||
@Data
|
||||
@Builder
|
||||
public class ReportTemplateSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "模板名称", example = "生产单模板")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "报表模板")
|
||||
private String template;
|
||||
|
||||
@Schema(description = "模板类型,0内置、1自定义", example = "1")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "备注", example = "该模板仅供生产使用")
|
||||
private String remark;
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.cf.imes.module.report.dal.dataobject.template;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.cf.imes.framework.mybatis.core.type.ObjectListTypeHandler;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportDatasetParameterVO;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 报表数据集DO
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/7/8 11:01
|
||||
*/
|
||||
@TableName(value = "report_dataset", autoResultMap = true)
|
||||
@KeySequence("report_dataset_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ReportDatasetDO extends BaseDO {
|
||||
/**
|
||||
* 数据集id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 数据集名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 数据源id
|
||||
*/
|
||||
private Long datasourceId;
|
||||
/**
|
||||
* 动态查询SQL
|
||||
*/
|
||||
private String dbSql;
|
||||
/**
|
||||
* 参数列表
|
||||
*/
|
||||
@TableField(typeHandler = ObjectListTypeHandler.class)
|
||||
private List<ReportDatasetParameterVO> params;
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package com.cf.imes.module.report.dal.dataobject.template;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 报表数据源DO
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/7/8 11:01
|
||||
*/
|
||||
@TableName("report_datasource")
|
||||
@KeySequence("report_datasource_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ReportDatasourceDO extends BaseDO {
|
||||
/**
|
||||
* 数据源id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 模板id
|
||||
*/
|
||||
private Long reportId;
|
||||
/**
|
||||
* 数据源名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 模板类型,0内置、1自定义
|
||||
*/
|
||||
private Long type;
|
||||
/**
|
||||
* 数据库类型
|
||||
*/
|
||||
private String dbType;
|
||||
/**
|
||||
* 数据源驱动类
|
||||
*/
|
||||
private String dbDriver;
|
||||
/**
|
||||
* 数据源地址
|
||||
*/
|
||||
private String dbUrl;
|
||||
/**
|
||||
* 数据源用户名
|
||||
*/
|
||||
private String dbUsername;
|
||||
/**
|
||||
* 数据源密码
|
||||
*/
|
||||
private String dbPassword;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 组织id
|
||||
*/
|
||||
private Long organId;
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.cf.imes.module.report.dal.dataobject.template;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 报表模板信息DO
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/7/8 11:01
|
||||
*/
|
||||
@TableName("report_template")
|
||||
@KeySequence("report_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ReportTemplateDO extends BaseDO {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 模板名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 报表模板
|
||||
*/
|
||||
private String template;
|
||||
/**
|
||||
* 模板类型,0内置、1自定义
|
||||
*/
|
||||
private Long type;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 组织id
|
||||
*/
|
||||
private Long organId;
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.cf.imes.module.report.dal.mysql.template;
|
||||
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.module.report.dal.dataobject.template.ReportDatasetDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 报表数据集 Mapper
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/7/8 11:55
|
||||
*/
|
||||
@Mapper
|
||||
public interface ReportDatasetMapper extends BaseMapperX<ReportDatasetDO> {
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.cf.imes.module.report.dal.mysql.template;
|
||||
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.module.report.dal.dataobject.template.ReportDatasourceDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 报表数据源 Mapper
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/7/8 11:01
|
||||
*/
|
||||
@Mapper
|
||||
public interface ReportDatasourceMapper extends BaseMapperX<ReportDatasourceDO> {
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.cf.imes.module.report.dal.mysql.template;
|
||||
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.module.report.dal.dataobject.template.ReportTemplateDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 报表模板信息 Mapper
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/7/3 11:43
|
||||
*/
|
||||
@Mapper
|
||||
public interface ReportTemplateMapper extends BaseMapperX<ReportTemplateDO> {
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package com.cf.imes.module.report.service.template;
|
||||
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportDatasetReqVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportDatasetSaveReqVO;
|
||||
import com.cf.imes.module.report.dal.dataobject.template.ReportDatasetDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 报表数据集 Service 接口
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/7/8 11:51
|
||||
*/
|
||||
public interface ReportDatasetService {
|
||||
/**
|
||||
* 创建报表数据集
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDataset(@Valid ReportDatasetSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新报表数据集
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDataset(@Valid ReportDatasetSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除报表数据集
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDataset(Long id);
|
||||
|
||||
/**
|
||||
* 获得报表数据集
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 报表数据集
|
||||
*/
|
||||
ReportDatasetDO getDataset(Long id);
|
||||
|
||||
/**
|
||||
* 获得报表数据集分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 报表数据集分页
|
||||
*/
|
||||
List<ReportDatasetDO> getDatasetList(ReportDatasetReqVO reqVO);
|
||||
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package com.cf.imes.module.report.service.template;
|
||||
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportDatasetReqVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportDatasetSaveReqVO;
|
||||
import com.cf.imes.module.report.dal.dataobject.template.ReportDatasetDO;
|
||||
import com.cf.imes.module.report.dal.mysql.template.ReportDatasetMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASET_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 报表数据集 Service 实现类
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/7/8 11:01
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ReportDatasetServiceImpl implements ReportDatasetService {
|
||||
@Resource
|
||||
private ReportDatasetMapper datasetMapper;
|
||||
|
||||
@Override
|
||||
public Long createDataset(ReportDatasetSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
ReportDatasetDO dataset = BeanUtils.toBean(createReqVO, ReportDatasetDO.class);
|
||||
datasetMapper.insert(dataset);
|
||||
// 返回
|
||||
return dataset.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDataset(ReportDatasetSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDatasetExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ReportDatasetDO updateObj = BeanUtils.toBean(updateReqVO, ReportDatasetDO.class);
|
||||
datasetMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDataset(Long id) {
|
||||
// 校验存在
|
||||
validateDatasetExists(id);
|
||||
// 删除
|
||||
datasetMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateDatasetExists(Long id) {
|
||||
if (datasetMapper.selectById(id) == null) {
|
||||
throw exception(DATASET_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReportDatasetDO getDataset(Long id) {
|
||||
return datasetMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReportDatasetDO> getDatasetList(ReportDatasetReqVO reqVO) {
|
||||
return datasetMapper.selectList(new LambdaQueryWrapperX<ReportDatasetDO>()
|
||||
.eq(ReportDatasetDO::getDatasourceId, reqVO.getDatasourceId())
|
||||
.likeIfPresent(ReportDatasetDO::getName, reqVO.getName())
|
||||
.orderByDesc(ReportDatasetDO::getCreateTime));
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package com.cf.imes.module.report.service.template;
|
||||
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportDatasourceReqVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportDatasourceSaveReqVO;
|
||||
import com.cf.imes.module.report.dal.dataobject.template.ReportDatasourceDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 报表数据源 Service 接口
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/7/8 11:01
|
||||
*/
|
||||
public interface ReportDatasourceService {
|
||||
/**
|
||||
* 创建报表数据源
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDatasource(@Valid ReportDatasourceSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新报表数据源
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDatasource(@Valid ReportDatasourceSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除报表数据源
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDatasource(Long id);
|
||||
|
||||
/**
|
||||
* 获得报表数据源
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 报表数据源
|
||||
*/
|
||||
ReportDatasourceDO getDatasource(Long id);
|
||||
|
||||
/**
|
||||
* 获取模板下的数据源列表
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 报表数据源分页
|
||||
*/
|
||||
List<ReportDatasourceDO> getTemplateDatasourceList(ReportDatasourceReqVO pageReqVO);
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
package com.cf.imes.module.report.service.template;
|
||||
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportDatasourceReqVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportDatasourceSaveReqVO;
|
||||
import com.cf.imes.module.report.dal.dataobject.template.ReportDatasourceDO;
|
||||
import com.cf.imes.module.report.dal.mysql.template.ReportDatasourceMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASOURCE_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 报表数据源 Service 实现类
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/7/8 11:01
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ReportDatasourceServiceImpl implements ReportDatasourceService {
|
||||
@Resource
|
||||
private ReportDatasourceMapper datasourceMapper;
|
||||
|
||||
@Override
|
||||
public Long createDatasource(ReportDatasourceSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
ReportDatasourceDO datasource = BeanUtils.toBean(createReqVO, ReportDatasourceDO.class);
|
||||
datasourceMapper.insert(datasource);
|
||||
// 返回
|
||||
return datasource.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDatasource(ReportDatasourceSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDatasourceExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ReportDatasourceDO updateObj = BeanUtils.toBean(updateReqVO, ReportDatasourceDO.class);
|
||||
datasourceMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDatasource(Long id) {
|
||||
// 校验存在
|
||||
validateDatasourceExists(id);
|
||||
// 删除
|
||||
datasourceMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验数据源是否存在
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
private void validateDatasourceExists(Long id) {
|
||||
if (datasourceMapper.selectById(id) == null) {
|
||||
throw exception(DATASOURCE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReportDatasourceDO getDatasource(Long id) {
|
||||
return datasourceMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReportDatasourceDO> getTemplateDatasourceList(ReportDatasourceReqVO reqVO) {
|
||||
return datasourceMapper.selectList(new LambdaQueryWrapperX<ReportDatasourceDO>()
|
||||
.eq(ReportDatasourceDO::getReportId, reqVO.getReportId())
|
||||
.likeIfPresent(ReportDatasourceDO::getName, reqVO.getName())
|
||||
.eq(ReportDatasourceDO::getType, reqVO.getType())
|
||||
.orderByDesc(ReportDatasourceDO::getCreateTime));
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package com.cf.imes.module.report.service.template;
|
||||
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateReqVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateSaveReqVO;
|
||||
import com.cf.imes.module.report.dal.dataobject.template.ReportTemplateDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 报表模板信息 Service 接口
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/7/3 11:56
|
||||
*/
|
||||
public interface ReportTemplateService {
|
||||
/**
|
||||
* 创建报表模板信息
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createReportTemplate(@Valid ReportTemplateSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新报表模板信息
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateReportTemplate(@Valid ReportTemplateSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除报表模板信息
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteReportTemplate(Long id);
|
||||
|
||||
/**
|
||||
* 获得报表模板信息
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 报表模板信息
|
||||
*/
|
||||
ReportTemplateDO getReportTemplate(Long id);
|
||||
|
||||
/**
|
||||
* 获得报表模板信息列表
|
||||
*
|
||||
* @param pageReqVO 查询参数
|
||||
* @return 报表模板信息列表
|
||||
*/
|
||||
List<ReportTemplateDO> getReportTemplateList(ReportTemplateReqVO pageReqVO);
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
package com.cf.imes.module.report.service.template;
|
||||
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateReqVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateSaveReqVO;
|
||||
import com.cf.imes.module.report.dal.dataobject.template.ReportTemplateDO;
|
||||
import com.cf.imes.module.report.dal.mysql.template.ReportTemplateMapper;
|
||||
import com.cf.imes.module.report.enums.ErrorCodeConstants;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 报表模板信息 Service 实现类
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/7/3 12:00
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ReportTemplateServiceImpl implements ReportTemplateService {
|
||||
@Resource
|
||||
private ReportTemplateMapper templateMapper;
|
||||
|
||||
@Override
|
||||
public Long createReportTemplate(ReportTemplateSaveReqVO createReqVO) {
|
||||
String templateContent = createReqVO.getTemplate();
|
||||
if(StringUtils.isNotEmpty(templateContent)) {
|
||||
// todo template压缩待完善
|
||||
}
|
||||
// 插入
|
||||
ReportTemplateDO template = BeanUtils.toBean(createReqVO, ReportTemplateDO.class);
|
||||
templateMapper.insert(template);
|
||||
// 返回主键
|
||||
return template.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateReportTemplate(ReportTemplateSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateTemplateExists(updateReqVO.getId());
|
||||
String templateContent = updateReqVO.getTemplate();
|
||||
if (StringUtils.isNotEmpty(templateContent)) {
|
||||
// todo template压缩待完善
|
||||
}
|
||||
// 更新
|
||||
ReportTemplateDO updateObj = BeanUtils.toBean(updateReqVO, ReportTemplateDO.class);
|
||||
templateMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteReportTemplate(Long id) {
|
||||
// 校验存在
|
||||
validateTemplateExists(id);
|
||||
// 删除
|
||||
templateMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验模板是否存在
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
private void validateTemplateExists(Long id) {
|
||||
if (templateMapper.selectById(id) == null) {
|
||||
throw exception(ErrorCodeConstants.TEMPLATE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReportTemplateDO getReportTemplate(Long id) {
|
||||
return templateMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReportTemplateDO> getReportTemplateList(ReportTemplateReqVO reqVO) {
|
||||
return templateMapper.selectList(new LambdaQueryWrapperX<ReportTemplateDO>()
|
||||
.likeIfPresent(ReportTemplateDO::getName, reqVO.getName())
|
||||
.eq(ReportTemplateDO::getType, reqVO.getType())
|
||||
.orderByDesc(ReportTemplateDO::getCreateTime));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user