Commit 15e2121078a4f47560bab4bd39c6292f0a4f96f4

Authored by puhui999
2 parents 3e3dbce0 61cfcc28

Merge remote-tracking branch 'origin/vben5-antd-schema' into vben5-antd-schema

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
... ... @@ -49,4 +49,10 @@ public class CodegenProperties {
49 49 @NotNull(message = "是否生成单元测试不能为空")
50 50 private Boolean unitTestEnable;
51 51  
  52 + /**
  53 + * 是否生成批量删除接口
  54 + */
  55 + @NotNull(message = "是否生成批量删除接口不能为空")
  56 + private Boolean deleteBatchEnable;
  57 +
52 58 }
... ...
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java
... ... @@ -382,7 +382,7 @@ public class CodegenEngine {
382 382 bindingMap.put("columns", columns);
383 383 bindingMap.put("primaryColumn", CollectionUtils.findFirst(columns, CodegenColumnDO::getPrimaryKey)); // 主键字段
384 384 bindingMap.put("sceneEnum", CodegenSceneEnum.valueOf(table.getScene()));
385   -
  385 + bindingMap.put("deleteBatchEnable", codegenProperties.getDeleteBatchEnable());
386 386 // className 相关
387 387 // 去掉指定前缀,将 TestDictType 转换成 DictType. 因为在 create 等方法后,不需要带上 Test 前缀
388 388 String className = 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}")
... ... @@ -243,7 +243,7 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
243 243 return success(true);
244 244 }
245 245  
246   -#if ($table.deleteBatch)
  246 +#if ($deleteBatchEnable)
247 247 @DeleteMapping("/${subSimpleClassName_strikeCase}/delete-batch")
248 248 @Parameter(name = "ids", description = "编号", required = true)
249 249 @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
... ... @@ -161,7 +161,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
161 161 #end
162 162 }
163 163  
164   -#if ( $table.templateType != 2 && $table.deleteBatch)
  164 +#if ( $table.templateType != 2 && $deleteBatchEnable)
165 165 @Override
166 166 ## 特殊:主子表专属逻辑
167 167 #if ( $subTables && $subTables.size() > 0)
... ... @@ -338,7 +338,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
338 338 ${subClassNameVars.get($index)}Mapper.deleteById(id);
339 339 }
340 340  
341   -#if ($table.deleteBatch)
  341 +#if ($deleteBatchEnable)
342 342 @Override
343 343 public void delete${subSimpleClassName}ByIds(List<${subPrimaryColumn.javaType}> ids) {
344 344 // 校验存在
... ... @@ -359,7 +359,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
359 359 }
360 360 }
361 361  
362   -#if ($table.deleteBatch)
  362 +#if ($deleteBatchEnable)
363 363 private void validate${subSimpleClassName}Exists(List<${subPrimaryColumn.javaType}> ids) {
364 364 List<${subTable.className}DO> list = ${subClassNameVar}Mapper.selectByIds(ids);
365 365 if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
... ... @@ -406,7 +406,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
406 406 ${subClassNameVars.get($index)}Mapper.deleteBy${SubJoinColumnName}(${subJoinColumn.javaField});
407 407 }
408 408  
409   -#if ( $table.templateType != 2 && $table.deleteBatch)
  409 +#if ( $table.templateType != 2 && $deleteBatchEnable)
410 410 private void delete${subSimpleClassName}By${SubJoinColumnName}s(List<${primaryColumn.javaType}> ${subJoinColumn.javaField}s) {
411 411 ${subClassNameVars.get($index)}Mapper.deleteBy${SubJoinColumnName}s(${subJoinColumn.javaField}s);
412 412 }
... ...
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 &#39;#/adapter/vxe-table&#39;;
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 ()=&gt; {
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
... ... @@ -271,6 +271,7 @@ yudao:
271 271 front-type: 20 # 前端模版的类型,参见 CodegenFrontTypeEnum 枚举类
272 272 vo-type: 10 # VO 的类型,参见 CodegenVOTypeEnum 枚举类
273 273 unit-test-enable: false # 是否生成单元测试
  274 + delete-batch-enable: false # 是否生成批量删除接口
274 275 tenant: # 多租户相关配置项
275 276 enable: true
276 277 ignore-urls:
... ...