Commit 61cfcc283b426dd69e3f479a5600be3c6e1f382b
1 parent
05bf229a
perf:【INFRA 基础设施】代码生成配置 delete-batch-enable: false # 是否生成批量删除接口
Showing
14 changed files
with
30 additions
and
37 deletions
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/vo/table/CodegenTableRespVO.java
| 1 | 1 | package cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.table; |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | -import jakarta.validation.constraints.NotNull; | |
| 5 | 4 | import lombok.Data; |
| 6 | 5 | |
| 7 | 6 | import java.time.LocalDateTime; |
| ... | ... | @@ -46,9 +45,6 @@ public class CodegenTableRespVO { |
| 46 | 45 | @Schema(description = "前端类型,参见 CodegenFrontTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") |
| 47 | 46 | private Integer frontType; |
| 48 | 47 | |
| 49 | - @Schema(description = "是否生成批量删除接口", example = "true") | |
| 50 | - private Boolean deleteBatch; | |
| 51 | - | |
| 52 | 48 | @Schema(description = "父菜单编号", example = "1024") |
| 53 | 49 | private Long parentMenuId; |
| 54 | 50 | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/vo/table/CodegenTableSaveReqVO.java
| ... | ... | @@ -60,10 +60,6 @@ public class CodegenTableSaveReqVO { |
| 60 | 60 | @NotNull(message = "前端类型不能为空") |
| 61 | 61 | private Integer frontType; |
| 62 | 62 | |
| 63 | - @Schema(description = "是否生成批量删除接口", example = "true") | |
| 64 | - @NotNull(message = "是否生成批量删除接口不能为空") | |
| 65 | - private Boolean deleteBatch; | |
| 66 | - | |
| 67 | 63 | @Schema(description = "父菜单编号", example = "1024") |
| 68 | 64 | private Long parentMenuId; |
| 69 | 65 | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/codegen/CodegenTableDO.java
| ... | ... | @@ -108,12 +108,6 @@ public class CodegenTableDO extends BaseDO { |
| 108 | 108 | * 枚举 {@link CodegenFrontTypeEnum} |
| 109 | 109 | */ |
| 110 | 110 | private Integer frontType; |
| 111 | - /** | |
| 112 | - * 是否生成批量删除接口 | |
| 113 | - * -true 是 | |
| 114 | - * -false 否 | |
| 115 | - */ | |
| 116 | - private Boolean deleteBatch; | |
| 117 | 111 | |
| 118 | 112 | // ========== 菜单相关字段 ========== |
| 119 | 113 | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/codegen/config/CodegenProperties.java
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java
| ... | ... | @@ -380,7 +380,7 @@ public class CodegenEngine { |
| 380 | 380 | bindingMap.put("columns", columns); |
| 381 | 381 | bindingMap.put("primaryColumn", CollectionUtils.findFirst(columns, CodegenColumnDO::getPrimaryKey)); // 主键字段 |
| 382 | 382 | bindingMap.put("sceneEnum", CodegenSceneEnum.valueOf(table.getScene())); |
| 383 | - | |
| 383 | + bindingMap.put("deleteBatchEnable", codegenProperties.getDeleteBatchEnable()); | |
| 384 | 384 | // className 相关 |
| 385 | 385 | // 去掉指定前缀,将 TestDictType 转换成 DictType. 因为在 create 等方法后,不需要带上 Test 前缀 |
| 386 | 386 | String simpleClassName = equalsAnyIgnoreCase(table.getClassName(), table.getModuleName()) ? table.getClassName() | ... | ... |
yudao-module-infra/src/main/resources/codegen/java/controller/controller.vm
| ... | ... | @@ -74,7 +74,7 @@ public class ${sceneEnum.prefixClass}${table.className}Controller { |
| 74 | 74 | return success(true); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | -#if ( $table.templateType != 2 && $table.deleteBatch) | |
| 77 | +#if ( $table.templateType != 2 && $deleteBatchEnable) | |
| 78 | 78 | @DeleteMapping("/delete-batch") |
| 79 | 79 | @Parameter(name = "ids", description = "编号", required = true) |
| 80 | 80 | @Operation(summary = "批量删除${table.classComment}") |
| ... | ... | @@ -231,7 +231,7 @@ public class ${sceneEnum.prefixClass}${table.className}Controller { |
| 231 | 231 | return success(true); |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | -#if ($table.deleteBatch) | |
| 234 | +#if ($deleteBatchEnable) | |
| 235 | 235 | @DeleteMapping("/${subSimpleClassName_strikeCase}/delete-batch") |
| 236 | 236 | @Parameter(name = "ids", description = "编号", required = true) |
| 237 | 237 | @Operation(summary = "批量删除${subTable.classComment}") | ... | ... |
yudao-module-infra/src/main/resources/codegen/java/dal/mapper_sub.vm
| ... | ... | @@ -54,7 +54,7 @@ public interface ${subTable.className}Mapper extends BaseMapperX<${subTable.clas |
| 54 | 54 | return delete(${subTable.className}DO::get${SubJoinColumnName}, ${subJoinColumn.javaField}); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | -#if ( $table.templateType != 2 && $table.deleteBatch) | |
| 57 | +#if ( $table.templateType != 2 && $deleteBatchEnable) | |
| 58 | 58 | default int deleteBy${SubJoinColumnName}s(List<${subJoinColumn.javaType}> ${subJoinColumn.javaField}s) { |
| 59 | 59 | return delete(${subTable.className}DO::get${SubJoinColumnName}, ${subJoinColumn.javaField}s); |
| 60 | 60 | } | ... | ... |
yudao-module-infra/src/main/resources/codegen/java/service/service.vm
| ... | ... | @@ -40,7 +40,7 @@ public interface ${table.className}Service { |
| 40 | 40 | */ |
| 41 | 41 | void delete${simpleClassName}(${primaryColumn.javaType} id); |
| 42 | 42 | |
| 43 | -#if ( $table.templateType != 2 && $table.deleteBatch) | |
| 43 | +#if ( $table.templateType != 2 && $deleteBatchEnable) | |
| 44 | 44 | /** |
| 45 | 45 | * 批量删除${table.classComment} |
| 46 | 46 | * |
| ... | ... | @@ -143,7 +143,7 @@ public interface ${table.className}Service { |
| 143 | 143 | */ |
| 144 | 144 | void delete${subSimpleClassName}(${subPrimaryColumn.javaType} id); |
| 145 | 145 | |
| 146 | -#if ($table.deleteBatch) | |
| 146 | +#if ($deleteBatchEnable) | |
| 147 | 147 | /** |
| 148 | 148 | * 批量删除${subTable.classComment} |
| 149 | 149 | * | ... | ... |
yudao-module-infra/src/main/resources/codegen/java/service/serviceImpl.vm
| ... | ... | @@ -155,7 +155,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service |
| 155 | 155 | #end |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | -#if ( $table.templateType != 2 && $table.deleteBatch) | |
| 158 | +#if ( $table.templateType != 2 && $deleteBatchEnable) | |
| 159 | 159 | @Override |
| 160 | 160 | ## 特殊:主子表专属逻辑 |
| 161 | 161 | #if ( $subTables && $subTables.size() > 0) |
| ... | ... | @@ -332,7 +332,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service |
| 332 | 332 | ${subClassNameVars.get($index)}Mapper.deleteById(id); |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | -#if ($table.deleteBatch) | |
| 335 | +#if ($deleteBatchEnable) | |
| 336 | 336 | @Override |
| 337 | 337 | public void delete${subSimpleClassName}ByIds(List<${subPrimaryColumn.javaType}> ids) { |
| 338 | 338 | // 校验存在 |
| ... | ... | @@ -353,7 +353,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service |
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | -#if ($table.deleteBatch) | |
| 356 | +#if ($deleteBatchEnable) | |
| 357 | 357 | private void validate${subSimpleClassName}Exists(List<${subPrimaryColumn.javaType}> ids) { |
| 358 | 358 | List<${subTable.className}DO> list = ${subClassNameVar}Mapper.selectByIds(ids); |
| 359 | 359 | if (CollUtil.isEmpty(list) || list.size() != ids.size()) { |
| ... | ... | @@ -400,7 +400,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service |
| 400 | 400 | ${subClassNameVars.get($index)}Mapper.deleteBy${SubJoinColumnName}(${subJoinColumn.javaField}); |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | -#if ( $table.templateType != 2 && $table.deleteBatch) | |
| 403 | +#if ( $table.templateType != 2 && $deleteBatchEnable) | |
| 404 | 404 | private void delete${subSimpleClassName}By${SubJoinColumnName}s(List<${primaryColumn.javaType}> ${subJoinColumn.javaField}s) { |
| 405 | 405 | ${subClassNameVars.get($index)}Mapper.deleteBy${SubJoinColumnName}s(${subJoinColumn.javaField}s); |
| 406 | 406 | } | ... | ... |
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/api/api.ts.vm
| ... | ... | @@ -89,7 +89,7 @@ export function delete${simpleClassName}(id: number) { |
| 89 | 89 | return requestClient.delete(`${baseURL}/delete?id=${id}`); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | -#if ( $table.templateType != 2 && $table.deleteBatch) | |
| 92 | +#if ( $table.templateType != 2 && $deleteBatchEnable) | |
| 93 | 93 | // 批量删除${table.classComment} |
| 94 | 94 | export function delete${simpleClassName}ByIds(ids: number[]) { |
| 95 | 95 | return requestClient.delete(`${baseURL}/delete-batch?ids=${ids.join(',')}`) |
| ... | ... | @@ -151,7 +151,7 @@ export function delete${subSimpleClassName}(id: number) { |
| 151 | 151 | return requestClient.delete(`${baseURL}/${subSimpleClassName_strikeCase}/delete?id=${id}`); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | -#if ($table.deleteBatch) | |
| 154 | +#if ($deleteBatchEnable) | |
| 155 | 155 | // 批量删除${subTable.classComment} |
| 156 | 156 | export function delete${subSimpleClassName}ByIds(ids: number[]) { |
| 157 | 157 | return requestClient.delete(`${baseURL}/${subSimpleClassName_strikeCase}/delete-batch?ids=${ids.join(',')}`) | ... | ... |
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/data.ts.vm
| ... | ... | @@ -193,7 +193,7 @@ export function useGridColumns( |
| 193 | 193 | onActionClick?: OnActionClickFn<${simpleClassName}Api.${simpleClassName}>, |
| 194 | 194 | ): VxeTableGridOptions<${simpleClassName}Api.${simpleClassName}>['columns'] { |
| 195 | 195 | return [ |
| 196 | -#if ($table.templateType != 2 && $table.deleteBatch) | |
| 196 | +#if ($table.templateType != 2 && $deleteBatchEnable) | |
| 197 | 197 | { type: 'checkbox', width: 40 }, |
| 198 | 198 | #end |
| 199 | 199 | #if ($table.templateType == 12) ## 内嵌情况 |
| ... | ... | @@ -431,7 +431,7 @@ export function use${subSimpleClassName}GridColumns( |
| 431 | 431 | onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>, |
| 432 | 432 | ): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] { |
| 433 | 433 | return [ |
| 434 | - #if ($table.templateType != 2 && $table.deleteBatch) | |
| 434 | + #if ($table.templateType != 2 && $deleteBatchEnable) | |
| 435 | 435 | { type: 'checkbox', width: 40 }, |
| 436 | 436 | #end |
| 437 | 437 | #foreach($column in $subColumns) | ... | ... |
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/index.vue.vm
| ... | ... | @@ -22,7 +22,7 @@ import { useVbenVxeGrid } from '#/adapter/vxe-table'; |
| 22 | 22 | #if (${table.templateType} == 2)## 树表接口 |
| 23 | 23 | import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}'; |
| 24 | 24 | #else## 标准表接口 |
| 25 | -import { get${simpleClassName}Page, delete${simpleClassName},#if ($table.deleteBatch) delete${simpleClassName}ByIds,#end export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}'; | |
| 25 | +import { get${simpleClassName}Page, delete${simpleClassName},#if ($deleteBatchEnable) delete${simpleClassName}ByIds,#end export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}'; | |
| 26 | 26 | #end |
| 27 | 27 | import { downloadFileFromBlobPart, isEmpty } from '@vben/utils'; |
| 28 | 28 | |
| ... | ... | @@ -92,7 +92,7 @@ async function onDelete(row: ${simpleClassName}Api.${simpleClassName}) { |
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | -#if ($table.templateType != 2 && $table.deleteBatch) | |
| 95 | +#if ($table.templateType != 2 && $deleteBatchEnable) | |
| 96 | 96 | const deleteIds = ref<number[]>([]) // 待删除${table.classComment} ID |
| 97 | 97 | const showDeleteBatchBtn = computed(() => isEmpty(deleteIds.value)); |
| 98 | 98 | function setDeleteIds({ |
| ... | ... | @@ -204,14 +204,14 @@ const [Grid, gridApi] = useVbenVxeGrid({ |
| 204 | 204 | search: true, |
| 205 | 205 | }, |
| 206 | 206 | } as VxeTableGridOptions<${simpleClassName}Api.${simpleClassName}>, |
| 207 | -#if (${table.templateType} == 11 || $table.deleteBatch) | |
| 207 | +#if (${table.templateType} == 11 || $deleteBatchEnable) | |
| 208 | 208 | gridEvents:{ |
| 209 | 209 | #if(${table.templateType} == 11) |
| 210 | 210 | cellClick: ({ row }: { row: ${simpleClassName}Api.${simpleClassName}}) => { |
| 211 | 211 | select${simpleClassName}.value = row; |
| 212 | 212 | }, |
| 213 | 213 | #end |
| 214 | - #if($table.deleteBatch) | |
| 214 | + #if($deleteBatchEnable) | |
| 215 | 215 | checkboxAll: setDeleteIds, |
| 216 | 216 | checkboxChange: setDeleteIds, |
| 217 | 217 | #end |
| ... | ... | @@ -262,7 +262,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ |
| 262 | 262 | > |
| 263 | 263 | {{ $t('ui.actionTitle.export') }} |
| 264 | 264 | </Button> |
| 265 | -#if ($table.templateType != 2 && $table.deleteBatch) | |
| 265 | +#if ($table.templateType != 2 && $deleteBatchEnable) | |
| 266 | 266 | <Button |
| 267 | 267 | :icon="h(Trash2)" |
| 268 | 268 | type="primary" | ... | ... |
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/modules/list_sub_erp.vue.vm
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | |
| 22 | 22 | |
| 23 | 23 | #if ($table.templateType == 11) ## erp |
| 24 | - import { delete${subSimpleClassName},#if ($table.deleteBatch) delete${subSimpleClassName}ByIds,#end get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${table.businessName}'; | |
| 24 | + import { delete${subSimpleClassName},#if ($deleteBatchEnable) delete${subSimpleClassName}ByIds,#end get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${table.businessName}'; | |
| 25 | 25 | import { use${subSimpleClassName}GridFormSchema, use${subSimpleClassName}GridColumns } from '../data'; |
| 26 | 26 | import { isEmpty } from '@vben/utils'; |
| 27 | 27 | #else |
| ... | ... | @@ -73,7 +73,7 @@ async function onDelete(row: ${simpleClassName}Api.${subSimpleClassName}) { |
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | -#if ($table.deleteBatch) | |
| 76 | +#if ($deleteBatchEnable) | |
| 77 | 77 | const deleteIds = ref<number[]>([]) // 待删除${subTable.classComment} ID |
| 78 | 78 | const showDeleteBatchBtn = computed(() => isEmpty(deleteIds.value)); |
| 79 | 79 | function setDeleteIds({ |
| ... | ... | @@ -164,7 +164,7 @@ function onActionClick({ |
| 164 | 164 | isHover: true, |
| 165 | 165 | }, |
| 166 | 166 | } as VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>, |
| 167 | - #if (${table.templateType} == 11 && $table.deleteBatch) | |
| 167 | + #if (${table.templateType} == 11 && $deleteBatchEnable) | |
| 168 | 168 | gridEvents:{ |
| 169 | 169 | checkboxAll: setDeleteIds, |
| 170 | 170 | checkboxChange: setDeleteIds, |
| ... | ... | @@ -207,7 +207,7 @@ const onRefresh = async ()=> { |
| 207 | 207 | <Button :icon="h(Plus)" type="primary" @click="onCreate" v-access:code="['${table.moduleName}:${simpleClassName_strikeCase}:create']"> |
| 208 | 208 | {{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }} |
| 209 | 209 | </Button> |
| 210 | - #if ($table.templateType == 11 && $table.deleteBatch) | |
| 210 | + #if ($table.templateType == 11 && $deleteBatchEnable) | |
| 211 | 211 | <Button |
| 212 | 212 | :icon="h(Trash2)" |
| 213 | 213 | type="primary" | ... | ... |
yudao-server/src/main/resources/application.yaml
| ... | ... | @@ -270,6 +270,7 @@ yudao: |
| 270 | 270 | db-schemas: ${spring.datasource.dynamic.datasource.master.name} |
| 271 | 271 | front-type: 20 # 前端模版的类型,参见 CodegenFrontTypeEnum 枚举类 |
| 272 | 272 | unit-test-enable: false # 是否生成单元测试 |
| 273 | + delete-batch-enable: false # 是否生成批量删除接口 | |
| 273 | 274 | tenant: # 多租户相关配置项 |
| 274 | 275 | enable: true |
| 275 | 276 | ignore-urls: | ... | ... |