Commit fb8f5b6339883a164bed515a89a8e2711eee7fa8
1 parent
8bcc732c
report:code review ureport 的集成
Showing
17 changed files
with
118 additions
and
105 deletions
yudao-dependencies/pom.xml
yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/enums/ErrorCodeConstants.java
| ... | ... | @@ -9,9 +9,11 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode; |
| 9 | 9 | */ |
| 10 | 10 | public interface ErrorCodeConstants { |
| 11 | 11 | |
| 12 | - // ========== AUTH 模块 1-003-000-000 ========== | |
| 12 | + // ========== GoView 模块 1-003-000-000 ========== | |
| 13 | 13 | ErrorCode GO_VIEW_PROJECT_NOT_EXISTS = new ErrorCode(1_003_000_000, "GoView 项目不存在"); |
| 14 | 14 | |
| 15 | - ErrorCode UREPORT_FILE_NOT_EXISTS = new ErrorCode(1_003_001_000, "打印文件不存在,请检查Ureport报表文件"); | |
| 15 | + // ========== UREPORT 模块 1-003-001-000 ========== | |
| 16 | + ErrorCode UREPORT_FILE_NOT_EXISTS = new ErrorCode(1_003_001_000, "打印文件不存在,请检查 UReport 报表文件"); | |
| 16 | 17 | ErrorCode UREPORT_FILE_EXISTS = new ErrorCode(1_003_001_001, "报表名字已存在,请修改后再保存"); |
| 18 | + | |
| 17 | 19 | } | ... | ... |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ureport/UreportFileController.java
| 1 | 1 | package cn.iocoder.yudao.module.report.controller.admin.ureport; |
| 2 | 2 | |
| 3 | -import org.springframework.web.bind.annotation.*; | |
| 4 | -import javax.annotation.Resource; | |
| 5 | -import org.springframework.validation.annotation.Validated; | |
| 6 | -import org.springframework.security.access.prepost.PreAuthorize; | |
| 7 | -import io.swagger.v3.oas.annotations.tags.Tag; | |
| 8 | -import io.swagger.v3.oas.annotations.Parameter; | |
| 9 | -import io.swagger.v3.oas.annotations.Operation; | |
| 10 | - | |
| 11 | -import javax.validation.constraints.*; | |
| 12 | -import javax.validation.*; | |
| 13 | -import javax.servlet.http.*; | |
| 14 | -import java.util.*; | |
| 15 | -import java.io.IOException; | |
| 16 | - | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 17 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 18 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 19 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 20 | 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 21 | -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 22 | - | |
| 23 | 7 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 24 | - | |
| 25 | 8 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 26 | -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | |
| 27 | - | |
| 28 | -import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.*; | |
| 9 | +import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UreportFilePageReqVO; | |
| 10 | +import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UreportFileRespVO; | |
| 11 | +import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UreportFileSaveReqVO; | |
| 29 | 12 | import cn.iocoder.yudao.module.report.dal.dataobject.ureport.UreportFileDO; |
| 30 | 13 | import cn.iocoder.yudao.module.report.service.ureport.UreportFileService; |
| 14 | +import io.swagger.v3.oas.annotations.Operation; | |
| 15 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 16 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 17 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 18 | +import org.springframework.validation.annotation.Validated; | |
| 19 | +import org.springframework.web.bind.annotation.*; | |
| 20 | + | |
| 21 | +import javax.annotation.Resource; | |
| 22 | +import javax.servlet.http.HttpServletResponse; | |
| 23 | +import javax.validation.Valid; | |
| 24 | +import java.io.IOException; | |
| 25 | +import java.util.List; | |
| 26 | + | |
| 27 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 28 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | |
| 31 | 29 | |
| 32 | -@Tag(name = "管理后台 - Ureport2报表") | |
| 30 | +// TODO @赤焰: Ureport 改成 UReport | |
| 31 | +@Tag(name = "管理后台 - UReport2 报表") | |
| 33 | 32 | @RestController |
| 34 | 33 | @RequestMapping("/report/ureport-file") |
| 35 | 34 | @Validated |
| ... | ... | @@ -39,14 +38,14 @@ public class UreportFileController { |
| 39 | 38 | private UreportFileService ureportFileService; |
| 40 | 39 | |
| 41 | 40 | @PostMapping("/create") |
| 42 | - @Operation(summary = "创建Ureport2报表") | |
| 41 | + @Operation(summary = "创建 UReport2 报表") | |
| 43 | 42 | @PreAuthorize("@ss.hasPermission('report:ureport-file:create')") |
| 44 | 43 | public CommonResult<Long> createUreportFile(@Valid @RequestBody UreportFileSaveReqVO createReqVO) { |
| 45 | 44 | return success(ureportFileService.createUreportFile(createReqVO)); |
| 46 | 45 | } |
| 47 | 46 | |
| 48 | 47 | @PutMapping("/update") |
| 49 | - @Operation(summary = "更新Ureport2报表") | |
| 48 | + @Operation(summary = "更新 UReport2 报表") | |
| 50 | 49 | @PreAuthorize("@ss.hasPermission('report:ureport-file:update')") |
| 51 | 50 | public CommonResult<Boolean> updateUreportFile(@Valid @RequestBody UreportFileSaveReqVO updateReqVO) { |
| 52 | 51 | ureportFileService.updateUreportFile(updateReqVO); |
| ... | ... | @@ -54,7 +53,7 @@ public class UreportFileController { |
| 54 | 53 | } |
| 55 | 54 | |
| 56 | 55 | @DeleteMapping("/delete") |
| 57 | - @Operation(summary = "删除Ureport2报表") | |
| 56 | + @Operation(summary = "删除 UReport2 报表") | |
| 58 | 57 | @Parameter(name = "id", description = "编号", required = true) |
| 59 | 58 | @PreAuthorize("@ss.hasPermission('report:ureport-file:delete')") |
| 60 | 59 | public CommonResult<Boolean> deleteUreportFile(@RequestParam("id") Long id) { |
| ... | ... | @@ -63,7 +62,7 @@ public class UreportFileController { |
| 63 | 62 | } |
| 64 | 63 | |
| 65 | 64 | @GetMapping("/get") |
| 66 | - @Operation(summary = "获得Ureport2报表") | |
| 65 | + @Operation(summary = "获得 UReport2 报表") | |
| 67 | 66 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| 68 | 67 | @PreAuthorize("@ss.hasPermission('report:ureport-file:query')") |
| 69 | 68 | public CommonResult<UreportFileRespVO> getUreportFile(@RequestParam("id") Long id) { |
| ... | ... | @@ -72,15 +71,16 @@ public class UreportFileController { |
| 72 | 71 | } |
| 73 | 72 | |
| 74 | 73 | @GetMapping("/page") |
| 75 | - @Operation(summary = "获得Ureport2报表分页") | |
| 74 | + @Operation(summary = "获得 UReport2 报表分页") | |
| 76 | 75 | @PreAuthorize("@ss.hasPermission('report:ureport-file:query')") |
| 77 | 76 | public CommonResult<PageResult<UreportFileRespVO>> getUreportFilePage(@Valid UreportFilePageReqVO pageReqVO) { |
| 78 | 77 | PageResult<UreportFileDO> pageResult = ureportFileService.getUreportFilePage(pageReqVO); |
| 79 | 78 | return success(BeanUtils.toBean(pageResult, UreportFileRespVO.class)); |
| 80 | 79 | } |
| 81 | 80 | |
| 81 | + // TODO @赤焰:导出是必须的么?没用可以删除哈 | |
| 82 | 82 | @GetMapping("/export-excel") |
| 83 | - @Operation(summary = "导出Ureport2报表 Excel") | |
| 83 | + @Operation(summary = "导出 UReport2 报表 Excel") | |
| 84 | 84 | @PreAuthorize("@ss.hasPermission('report:ureport-file:export')") |
| 85 | 85 | @OperateLog(type = EXPORT) |
| 86 | 86 | public void exportUreportFileExcel(@Valid UreportFilePageReqVO pageReqVO, | ... | ... |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ureport/vo/UreportFileRespVO.java
| 1 | 1 | package cn.iocoder.yudao.module.report.controller.admin.ureport.vo; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | |
| 4 | +import cn.iocoder.yudao.module.system.enums.DictTypeConstants; | |
| 5 | +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | |
| 6 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 3 | 7 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | -import lombok.*; | |
| 5 | -import java.util.*; | |
| 6 | -import java.util.*; | |
| 7 | -import org.springframework.format.annotation.DateTimeFormat; | |
| 8 | +import lombok.Data; | |
| 9 | + | |
| 8 | 10 | import java.time.LocalDateTime; |
| 9 | -import com.alibaba.excel.annotation.*; | |
| 10 | 11 | |
| 11 | 12 | @Schema(description = "管理后台 - Ureport2报表 Response VO") |
| 12 | 13 | @Data |
| ... | ... | @@ -23,6 +24,7 @@ public class UreportFileRespVO { |
| 23 | 24 | |
| 24 | 25 | @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 25 | 26 | @ExcelProperty("状态") |
| 27 | + @DictFormat(DictTypeConstants.COMMON_STATUS) | |
| 26 | 28 | private Integer status; |
| 27 | 29 | |
| 28 | 30 | @Schema(description = "备注", example = "随便") | ... | ... |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ureport/vo/UreportFileSaveReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.report.controller.admin.ureport.vo; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 3 | 5 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | -import lombok.*; | |
| 5 | -import java.util.*; | |
| 6 | -import javax.validation.constraints.*; | |
| 7 | -import java.util.*; | |
| 6 | +import lombok.Data; | |
| 7 | + | |
| 8 | +import javax.validation.constraints.NotEmpty; | |
| 9 | +import javax.validation.constraints.NotNull; | |
| 8 | 10 | |
| 9 | 11 | @Schema(description = "管理后台 - Ureport2报表新增/修改 Request VO") |
| 10 | 12 | @Data |
| ... | ... | @@ -19,6 +21,7 @@ public class UreportFileSaveReqVO { |
| 19 | 21 | |
| 20 | 22 | @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 21 | 23 | @NotNull(message = "状态不能为空") |
| 24 | + @InEnum(CommonStatusEnum.class) | |
| 22 | 25 | private Integer status; |
| 23 | 26 | |
| 24 | 27 | @Schema(description = "文件内容") | ... | ... |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/ureport/UreportFileDO.java
| 1 | 1 | package cn.iocoder.yudao.module.report.dal.dataobject.ureport; |
| 2 | 2 | |
| 3 | -import lombok.*; | |
| 4 | -import java.util.*; | |
| 5 | -import java.time.LocalDateTime; | |
| 6 | -import java.time.LocalDateTime; | |
| 7 | -import com.baomidou.mybatisplus.annotation.*; | |
| 8 | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 7 | +import lombok.*; | |
| 9 | 8 | |
| 10 | 9 | /** |
| 11 | 10 | * Ureport2报表 DO |
| ... | ... | @@ -27,6 +26,7 @@ public class UreportFileDO extends BaseDO { |
| 27 | 26 | */ |
| 28 | 27 | @TableId |
| 29 | 28 | private Long id; |
| 29 | + // TODO @赤焰:是不是用 name 就可以了。 | |
| 30 | 30 | /** |
| 31 | 31 | * 文件名称 |
| 32 | 32 | */ |
| ... | ... | @@ -35,6 +35,7 @@ public class UreportFileDO extends BaseDO { |
| 35 | 35 | * 状态 |
| 36 | 36 | */ |
| 37 | 37 | private Integer status; |
| 38 | + // TODO @赤焰:是不是用 string 就可以了。然后字段名用 content? | |
| 38 | 39 | /** |
| 39 | 40 | * 文件内容 |
| 40 | 41 | */ | ... | ... |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/config/SecurityConfiguration.java
| ... | ... | @@ -18,9 +18,8 @@ public class SecurityConfiguration { |
| 18 | 18 | |
| 19 | 19 | @Override |
| 20 | 20 | public void customize(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry) { |
| 21 | - //积木报表 | |
| 22 | - registry.antMatchers("/jmreport/**").permitAll(); | |
| 23 | - registry.antMatchers("/ureport/**").permitAll(); | |
| 21 | + registry.antMatchers("/jmreport/**").permitAll(); // 积木报表 | |
| 22 | + registry.antMatchers("/ureport/**").permitAll(); // UReport 报表 | |
| 24 | 23 | } |
| 25 | 24 | |
| 26 | 25 | }; | ... | ... |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/config/UreportConfiguration.java
| ... | ... | @@ -10,15 +10,16 @@ import org.springframework.context.annotation.PropertySource; |
| 10 | 10 | import javax.servlet.Servlet; |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * Ureport 配置类 | |
| 14 | - * 加载ureport对应的xml配置文件 | |
| 15 | - * @author 赤焰 | |
| 13 | + * UReport2 配置类 | |
| 14 | + * | |
| 15 | + * @author 赤焰 | |
| 16 | 16 | */ |
| 17 | 17 | @Configuration |
| 18 | -@ImportResource({"classpath:ureport-console-context.xml"}) | |
| 19 | -@PropertySource(value = {"classpath:ureport.properties"}) | |
| 18 | +@ImportResource({"classpath:ureport-console-context.xml"}) // Bean 配置 | |
| 19 | +@PropertySource(value = {"classpath:ureport.properties"}) // 配置文件 | |
| 20 | 20 | public class UreportConfiguration { |
| 21 | 21 | |
| 22 | + // TODO @赤焰:bean 是不是取个和 ureport 相关的名字好点哈? | |
| 22 | 23 | @Bean |
| 23 | 24 | public ServletRegistrationBean<Servlet> registrationBean() { |
| 24 | 25 | return new ServletRegistrationBean<>(new UReportServlet(), "/ureport/*"); | ... | ... |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/config/UreportDataSource.java
| ... | ... | @@ -10,7 +10,7 @@ import java.sql.Connection; |
| 10 | 10 | import java.sql.SQLException; |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * ureport内置数据源 | |
| 13 | + * UReport 内置数据源 | |
| 14 | 14 | */ |
| 15 | 15 | @Slf4j |
| 16 | 16 | @Component |
| ... | ... | @@ -22,18 +22,17 @@ public class UreportDataSource implements BuildinDatasource { |
| 22 | 22 | private DataSource dataSource; |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | - * 数据源名称 | |
| 26 | - * | |
| 27 | - **/ | |
| 25 | + * @return 数据源名称 | |
| 26 | + */ | |
| 28 | 27 | @Override |
| 29 | 28 | public String name() { |
| 30 | 29 | return NAME; |
| 31 | 30 | } |
| 32 | 31 | |
| 32 | + // TODO @赤焰:这个方法,如果拿不到连接,是不是抛出异常比较好? | |
| 33 | 33 | /** |
| 34 | - * * 获取连接 | |
| 35 | - * | |
| 36 | - **/ | |
| 34 | + * @return 获取连接 | |
| 35 | + */ | |
| 37 | 36 | @Override |
| 38 | 37 | public Connection getConnection() { |
| 39 | 38 | try { | ... | ... |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/provider/UreportDatabaseProvider.java renamed to yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/core/UreportDatabaseProvider.java
| 1 | -package cn.iocoder.yudao.module.report.framework.ureport.provider; | |
| 1 | +package cn.iocoder.yudao.module.report.framework.ureport.core; | |
| 2 | 2 | |
| 3 | -import cn.hutool.core.bean.BeanUtil; | |
| 4 | 3 | import cn.hutool.core.collection.CollUtil; |
| 5 | 4 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 6 | 5 | import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UreportFileSaveReqVO; |
| ... | ... | @@ -28,30 +27,37 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU |
| 28 | 27 | import static cn.iocoder.yudao.module.report.enums.ErrorCodeConstants.UREPORT_FILE_EXISTS; |
| 29 | 28 | import static cn.iocoder.yudao.module.report.enums.ErrorCodeConstants.UREPORT_FILE_NOT_EXISTS; |
| 30 | 29 | |
| 30 | +// TODO @赤焰:有了这个功能,是不是就不需要 UreportFileController? | |
| 31 | 31 | /** |
| 32 | - * 提供数据库的存储方式 | |
| 32 | + * 基于数据库的 {@link ReportProvider} 实现类 | |
| 33 | + * | |
| 33 | 34 | * @author 赤焰 |
| 34 | 35 | */ |
| 36 | +@Component | |
| 35 | 37 | @Slf4j |
| 36 | 38 | @Setter |
| 37 | -@Component | |
| 38 | -@ConfigurationProperties(prefix = "ureport.provider.database") | |
| 39 | -public class UreportDatabaseProvider implements ReportProvider{ | |
| 39 | +@ConfigurationProperties(prefix = "ureport.provider.database") // TODO @赤焰:是不是单独搞个 UReportProperties 用来注入 prefix、disabled 等属性 | |
| 40 | +public class UreportDatabaseProvider implements ReportProvider { | |
| 40 | 41 | |
| 41 | 42 | private static final String NAME = "mysql-provider"; |
| 42 | 43 | |
| 44 | + // TODO @赤焰:IdTypeEnvironmentPostProcessor 参考下,通过 primary 数据源获取 | |
| 43 | 45 | private String prefix = "mysql:"; |
| 44 | 46 | |
| 45 | 47 | private boolean disabled = false; |
| 48 | + | |
| 46 | 49 | @Resource |
| 47 | 50 | private UreportFileService ureportFileService; |
| 48 | 51 | |
| 49 | 52 | @Override |
| 50 | 53 | public InputStream loadReport(String file) { |
| 54 | + // TODO @赤焰:是不是不需要这个 check 接口?直接使用 name 查询就 ok 了? | |
| 55 | + // TODO @赤焰:变量的命名要注意,这里 reportDo 是不是叫 count 就好了?还有,这个方法的命名也不太对。 | |
| 51 | 56 | Long reportDo = ureportFileService.checkExistByName(getCorrectName(file)); |
| 52 | - if (reportDo <=0) { | |
| 57 | + if (reportDo <=0) { // TODO 赤焰:<= 0 注释空格 | |
| 53 | 58 | throw exception(UREPORT_FILE_NOT_EXISTS); |
| 54 | 59 | } |
| 60 | + // TODO @赤焰:queryUreportFileDoByName 改成 getUreportFileDoByName 更合适,保持整个项目的命名风格一致性。 | |
| 55 | 61 | UreportFileDO ureportFileDO = ureportFileService.queryUreportFileDoByName(getCorrectName(file)); |
| 56 | 62 | byte[] content = ureportFileDO.getFileContent(); |
| 57 | 63 | return new ByteArrayInputStream(content); |
| ... | ... | @@ -64,12 +70,16 @@ public class UreportDatabaseProvider implements ReportProvider{ |
| 64 | 70 | |
| 65 | 71 | @Override |
| 66 | 72 | public List<ReportFile> getReportFiles() { |
| 73 | + // TODO @赤焰:queryReportFileList 改成 getReportFileList 更合适,保持整个项目的命名风格一致性。 | |
| 67 | 74 | List<UreportFileDO> list = ureportFileService.queryReportFileList(); |
| 68 | 75 | List<ReportFile> reportList = new ArrayList<>(); |
| 69 | - if(CollUtil.isEmpty(list)){ | |
| 76 | + if(CollUtil.isEmpty(list)){ // TODO 赤焰:CollUtil.isEmpty(list) 注意空格 | |
| 77 | + // TODO @赤焰:这里可以直接返回 Collections.emptyList(); | |
| 70 | 78 | return reportList; |
| 71 | 79 | } |
| 80 | + // TODO 赤焰:可以使用 CollectionUtils.converList | |
| 72 | 81 | for (UreportFileDO reportFile : list) { |
| 82 | + // TODO 赤焰:可以使用 DateUtils.of() 么? | |
| 73 | 83 | LocalDateTime updateTime = reportFile.getUpdateTime(); |
| 74 | 84 | ZonedDateTime zdt = updateTime.atZone(ZoneId.systemDefault()); |
| 75 | 85 | Date date = Date.from(zdt.toInstant()); |
| ... | ... | @@ -82,6 +92,7 @@ public class UreportDatabaseProvider implements ReportProvider{ |
| 82 | 92 | @Override |
| 83 | 93 | public void saveReport(String file, String content) { |
| 84 | 94 | file = getCorrectName(file); |
| 95 | + // TODO @赤焰:这里的逻辑,应该封装到 ureportFileService 中,这里只负责调用即可 | |
| 85 | 96 | LambdaQueryWrapper<UreportFileDO> queryWrapper = new LambdaQueryWrapper<>(); |
| 86 | 97 | queryWrapper.eq(UreportFileDO::getFileName, file); |
| 87 | 98 | Long count = ureportFileService.checkExistByName(file); |
| ... | ... | @@ -119,10 +130,13 @@ public class UreportDatabaseProvider implements ReportProvider{ |
| 119 | 130 | return prefix; |
| 120 | 131 | } |
| 121 | 132 | |
| 133 | + // TODO @赤焰:这个方法的注释,最好写下哈; | |
| 122 | 134 | private String getCorrectName(String name) { |
| 135 | + // TODO 赤焰:一些常用方法,可以用 hutool StrUtil.removePrefix() | |
| 123 | 136 | if (name.startsWith(getPrefix())) { |
| 124 | 137 | name = name.substring(getPrefix().length()); |
| 125 | 138 | } |
| 126 | 139 | return name; |
| 127 | 140 | } |
| 141 | + | |
| 128 | 142 | } | ... | ... |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/provider/UreportFileReportProvider.java renamed to yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/core/UreportFileReportProvider.java
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/ureport/UreportFileServiceImpl.java
| ... | ... | @@ -73,6 +73,7 @@ public class UreportFileServiceImpl implements UreportFileService { |
| 73 | 73 | |
| 74 | 74 | @Override |
| 75 | 75 | public Long checkExistByName(String name) { |
| 76 | + // TODO @赤焰:Service 处理业务逻辑,不能出现 Mapper 层的东西,收敛成 mapper 的一个操作方法 | |
| 76 | 77 | LambdaQueryWrapper<UreportFileDO> queryWrapper = new LambdaQueryWrapper<>(); |
| 77 | 78 | queryWrapper.eq(UreportFileDO::getFileName,name); |
| 78 | 79 | return ureportFileMapper.selectCount(queryWrapper); |
| ... | ... | @@ -80,8 +81,10 @@ public class UreportFileServiceImpl implements UreportFileService { |
| 80 | 81 | |
| 81 | 82 | @Override |
| 82 | 83 | public UreportFileDO queryUreportFileDoByName(String name) { |
| 84 | + // TODO @赤焰:Service 处理业务逻辑,不能出现 Mapper 层的东西,收敛成 mapper 的一个操作方法 | |
| 83 | 85 | LambdaQueryWrapper<UreportFileDO> queryWrapper = new LambdaQueryWrapper<>(); |
| 84 | 86 | queryWrapper.eq(UreportFileDO::getFileName,name); |
| 87 | + // TODO @赤焰:这里,可以用 selectByName 即可 | |
| 85 | 88 | List<UreportFileDO> list = ureportFileMapper.selectList(queryWrapper); |
| 86 | 89 | if(CollectionUtil.isNotEmpty(list)){ |
| 87 | 90 | return list.get(0); |
| ... | ... | @@ -91,14 +94,17 @@ public class UreportFileServiceImpl implements UreportFileService { |
| 91 | 94 | |
| 92 | 95 | @Override |
| 93 | 96 | public List<UreportFileDO> queryReportFileList() { |
| 97 | + // TODO @赤焰:Service 处理业务逻辑,不能出现 Mapper 层的东西,收敛成 mapper 的一个操作方法 | |
| 94 | 98 | LambdaQueryWrapper<UreportFileDO> queryWrapper = new LambdaQueryWrapper<>(); |
| 95 | 99 | return ureportFileMapper.selectList(queryWrapper); |
| 96 | 100 | } |
| 97 | 101 | |
| 98 | 102 | @Override |
| 99 | 103 | public int deleteReportFileByName(String name) { |
| 104 | + // TODO @赤焰:Service 处理业务逻辑,不能出现 Mapper 层的东西,收敛成 mapper 的一个操作方法 | |
| 100 | 105 | LambdaQueryWrapper<UreportFileDO> queryWrapper = new LambdaQueryWrapper<>(); |
| 101 | 106 | queryWrapper.eq(UreportFileDO::getFileName,name); |
| 102 | 107 | return ureportFileMapper.delete(queryWrapper); |
| 103 | 108 | } |
| 109 | + | |
| 104 | 110 | } | ... | ... |
yudao-module-report/yudao-module-report-biz/src/main/resources/mapper/ureport/UreportFileMapper.xml deleted
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
| 3 | -<mapper namespace="cn.iocoder.yudao.module.report.dal.mysql.ureport.UreportFileMapper"> | |
| 4 | - | |
| 5 | - <!-- | |
| 6 | - 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 | |
| 7 | - 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 | |
| 8 | - 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 | |
| 9 | - 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ | |
| 10 | - --> | |
| 11 | - | |
| 12 | -</mapper> | |
| 13 | 0 | \ No newline at end of file |
yudao-module-report/yudao-module-report-biz/src/main/resources/ureport.properties
yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/ureport/UreportFileServiceImplTest.java
| 1 | 1 | package cn.iocoder.yudao.module.report.service.ureport; |
| 2 | 2 | |
| 3 | -import org.junit.jupiter.api.Disabled; | |
| 4 | -import org.junit.jupiter.api.Test; | |
| 5 | -import org.springframework.boot.test.mock.mockito.MockBean; | |
| 6 | - | |
| 7 | -import javax.annotation.Resource; | |
| 8 | - | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 9 | 4 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 10 | - | |
| 11 | -import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.*; | |
| 5 | +import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UreportFilePageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UreportFileSaveReqVO; | |
| 12 | 7 | import cn.iocoder.yudao.module.report.dal.dataobject.ureport.UreportFileDO; |
| 13 | 8 | import cn.iocoder.yudao.module.report.dal.mysql.ureport.UreportFileMapper; |
| 14 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 9 | +import org.junit.jupiter.api.Disabled; | |
| 10 | +import org.junit.jupiter.api.Test; | |
| 11 | +import org.springframework.context.annotation.Import; | |
| 15 | 12 | |
| 16 | 13 | import javax.annotation.Resource; |
| 17 | -import org.springframework.context.annotation.Import; | |
| 18 | -import java.util.*; | |
| 19 | -import java.time.LocalDateTime; | |
| 20 | - | |
| 21 | -import static cn.hutool.core.util.RandomUtil.*; | |
| 22 | -import static cn.iocoder.yudao.module.report.enums.ErrorCodeConstants.*; | |
| 23 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; | |
| 24 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | |
| 25 | -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; | |
| 26 | -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; | |
| 27 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; | |
| 14 | + | |
| 15 | +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; | |
| 16 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | |
| 17 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 18 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | |
| 19 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | |
| 20 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | |
| 21 | +import static cn.iocoder.yudao.module.report.enums.ErrorCodeConstants.UREPORT_FILE_NOT_EXISTS; | |
| 28 | 22 | import static org.junit.jupiter.api.Assertions.*; |
| 29 | -import static org.mockito.Mockito.*; | |
| 30 | 23 | |
| 24 | +// TODO 芋艿:但愿测试后面补 | |
| 31 | 25 | /** |
| 32 | 26 | * {@link UreportFileServiceImpl} 的单元测试类 |
| 33 | 27 | * | ... | ... |
yudao-server/src/main/resources/application-local.yaml
| ... | ... | @@ -264,6 +264,7 @@ justauth: |
| 264 | 264 | prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE:: |
| 265 | 265 | timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟 |
| 266 | 266 | |
| 267 | +# TODO 赤焰:这个配置的目的是? | |
| 267 | 268 | #ureport配置 |
| 268 | 269 | #ureport: |
| 269 | 270 | # disableHttpSessionReportCache: true #是否禁用 | ... | ... |
yudao-server/src/main/resources/application.yaml
| ... | ... | @@ -182,7 +182,7 @@ yudao: |
| 182 | 182 | - /admin-api/system/sms/callback/* # 短信回调接口,无法带上租户编号 |
| 183 | 183 | - /admin-api/pay/notify/** # 支付回调通知,不携带租户编号 |
| 184 | 184 | - /jmreport/* # 积木报表,无法携带租户编号 |
| 185 | - - /ureport/* # ureport报表,无法携带租户编号 | |
| 185 | + - /ureport/* # UReport 报表,无法携带租户编号 | |
| 186 | 186 | - /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,无法携带租户编号 |
| 187 | 187 | ignore-tables: |
| 188 | 188 | - system_tenant |
| ... | ... | @@ -251,11 +251,12 @@ yudao: |
| 251 | 251 | |
| 252 | 252 | debug: false |
| 253 | 253 | |
| 254 | -#积木报表配置 | |
| 254 | +# 积木报表配置 | |
| 255 | 255 | minidao : |
| 256 | 256 | base-package: org.jeecg.modules.jmreport.desreport.dao* |
| 257 | 257 | db-type: mysql |
| 258 | -#ureport配置 | |
| 258 | + | |
| 259 | +# UReport 配置 | |
| 259 | 260 | ureport: |
| 260 | 261 | provider: |
| 261 | 262 | database: | ... | ... |