Commit 0c68962a97c9910c86de5a66ba4c4e7f688fe78f
1 parent
d14aaae6
review:【INFRA 基础设施】代码生成的 review
Showing
8 changed files
with
13 additions
and
8 deletions
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/Demo01ContactController.java
| @@ -60,6 +60,7 @@ public class Demo01ContactController { | @@ -60,6 +60,7 @@ public class Demo01ContactController { | ||
| 60 | return success(true); | 60 | return success(true); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | + // TODO @puhui999:要不要 deleteDemo01ContactList?url 也叫 delete-list | ||
| 63 | @DeleteMapping("/delete-batch") | 64 | @DeleteMapping("/delete-batch") |
| 64 | @Parameter(name = "ids", description = "编号", required = true) | 65 | @Parameter(name = "ids", description = "编号", required = true) |
| 65 | @Operation(summary = "批量删除示例联系人") | 66 | @Operation(summary = "批量删除示例联系人") |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/vo/Demo01ContactPageReqVO.java
| @@ -13,6 +13,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ | @@ -13,6 +13,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ | ||
| 13 | 13 | ||
| 14 | @Schema(description = "管理后台 - 示例联系人分页 Request VO") | 14 | @Schema(description = "管理后台 - 示例联系人分页 Request VO") |
| 15 | @Data | 15 | @Data |
| 16 | +// TODO @puhui999:要不要去掉所有 pojo 里的 @EqualsAndHashCode、@ToString,代码生成里的。因为 lombok.config 已经处理了全局了; | ||
| 16 | @EqualsAndHashCode(callSuper = true) | 17 | @EqualsAndHashCode(callSuper = true) |
| 17 | @ToString(callSuper = true) | 18 | @ToString(callSuper = true) |
| 18 | public class Demo01ContactPageReqVO extends PageParam { | 19 | public class Demo01ContactPageReqVO extends PageParam { |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/codegen/config/CodegenProperties.java
| @@ -44,15 +44,15 @@ public class CodegenProperties { | @@ -44,15 +44,15 @@ public class CodegenProperties { | ||
| 44 | private Integer voType; | 44 | private Integer voType; |
| 45 | 45 | ||
| 46 | /** | 46 | /** |
| 47 | - * 是否生成单元测试 | ||
| 48 | - */ | ||
| 49 | - @NotNull(message = "是否生成单元测试不能为空") | ||
| 50 | - private Boolean unitTestEnable; | ||
| 51 | - | ||
| 52 | - /** | ||
| 53 | * 是否生成批量删除接口 | 47 | * 是否生成批量删除接口 |
| 54 | */ | 48 | */ |
| 55 | @NotNull(message = "是否生成批量删除接口不能为空") | 49 | @NotNull(message = "是否生成批量删除接口不能为空") |
| 56 | private Boolean deleteBatchEnable; | 50 | private Boolean deleteBatchEnable; |
| 57 | 51 | ||
| 52 | + /** | ||
| 53 | + * 是否生成单元测试 | ||
| 54 | + */ | ||
| 55 | + @NotNull(message = "是否生成单元测试不能为空") | ||
| 56 | + private Boolean unitTestEnable; | ||
| 57 | + | ||
| 58 | } | 58 | } |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/normal/Demo03StudentNormalServiceImpl.java
| @@ -135,6 +135,8 @@ public class Demo03StudentNormalServiceImpl implements Demo03StudentNormalServic | @@ -135,6 +135,8 @@ public class Demo03StudentNormalServiceImpl implements Demo03StudentNormalServic | ||
| 135 | List<List<Demo03CourseDO>> diffList = diffList(oldList, list, (oldVal, newVal) -> { | 135 | List<List<Demo03CourseDO>> diffList = diffList(oldList, list, (oldVal, newVal) -> { |
| 136 | boolean same = ObjectUtil.equal(oldVal.getId(), newVal.getId()); | 136 | boolean same = ObjectUtil.equal(oldVal.getId(), newVal.getId()); |
| 137 | if (same) { | 137 | if (same) { |
| 138 | + // TODO @puhui999:BaseDO 增加一个 clean 方法,里面把 creator、updator、updateTime、updater 都清空? | ||
| 139 | + // TODO @puhui999:然后 DO 模式新增、更新,以及主子表,都 clean 下。避免前端直接传递 creator 之类的字段,直接就被更新了。 | ||
| 138 | newVal.setId(oldVal.getId()).setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 | 140 | newVal.setId(oldVal.getId()).setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 |
| 139 | } | 141 | } |
| 140 | return same; | 142 | return same; |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/package-info.java deleted
yudao-module-infra/src/main/resources/codegen/java/dal/do.vm
| @@ -79,6 +79,7 @@ public class ${table.className}DO extends BaseDO { | @@ -79,6 +79,7 @@ public class ${table.className}DO extends BaseDO { | ||
| 79 | #end | 79 | #end |
| 80 | 80 | ||
| 81 | ## 特殊:主子表专属逻辑(非 ERP 模式) | 81 | ## 特殊:主子表专属逻辑(非 ERP 模式) |
| 82 | +## TODO @puhui999:这里空行看看,会不会多了一个哈 | ||
| 82 | #if ( $voType == 20 && $subTables && $subTables.size() > 0 && $table.templateType != 11 ) | 83 | #if ( $voType == 20 && $subTables && $subTables.size() > 0 && $table.templateType != 11 ) |
| 83 | #foreach ($subTable in $subTables) | 84 | #foreach ($subTable in $subTables) |
| 84 | #set ($index = $foreach.count - 1) | 85 | #set ($index = $foreach.count - 1) |
yudao-module-infra/src/main/resources/codegen/java/service/serviceImpl.vm
| @@ -340,6 +340,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service | @@ -340,6 +340,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service | ||
| 340 | ${subClassNameVars.get($index)}Mapper.deleteById(id); | 340 | ${subClassNameVars.get($index)}Mapper.deleteById(id); |
| 341 | } | 341 | } |
| 342 | 342 | ||
| 343 | +## TODO @puhui999:批量删除的时候,要不直接删除,就不“校验存在”;ps:主子表删除的时候,子表的处理,也要处理下哈; | ||
| 343 | #if ($deleteBatchEnable) | 344 | #if ($deleteBatchEnable) |
| 344 | @Override | 345 | @Override |
| 345 | public void delete${subSimpleClassName}ByIds(List<${subPrimaryColumn.javaType}> ids) { | 346 | public void delete${subSimpleClassName}ByIds(List<${subPrimaryColumn.javaType}> ids) { |
yudao-server/src/main/resources/application.yaml
| @@ -270,8 +270,8 @@ yudao: | @@ -270,8 +270,8 @@ yudao: | ||
| 270 | db-schemas: ${spring.datasource.dynamic.datasource.master.name} | 270 | db-schemas: ${spring.datasource.dynamic.datasource.master.name} |
| 271 | front-type: 20 # 前端模版的类型,参见 CodegenFrontTypeEnum 枚举类 | 271 | front-type: 20 # 前端模版的类型,参见 CodegenFrontTypeEnum 枚举类 |
| 272 | vo-type: 10 # VO 的类型,参见 CodegenVOTypeEnum 枚举类 | 272 | vo-type: 10 # VO 的类型,参见 CodegenVOTypeEnum 枚举类 |
| 273 | + delete-batch-enable: true # 是否生成批量删除接口 | ||
| 273 | unit-test-enable: false # 是否生成单元测试 | 274 | unit-test-enable: false # 是否生成单元测试 |
| 274 | - delete-batch-enable: false # 是否生成批量删除接口 | ||
| 275 | tenant: # 多租户相关配置项 | 275 | tenant: # 多租户相关配置项 |
| 276 | enable: true | 276 | enable: true |
| 277 | ignore-urls: | 277 | ignore-urls: |