Selaa lähdekoodia

perf:【INFRA 基础设施】代码生成配置 delete-batch-enable: false # 是否生成批量删除接口

puhui999 5 kuukautta sitten
vanhempi
sitoutus
61cfcc283b

+ 0 - 4
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/vo/table/CodegenTableRespVO.java

@@ -1,7 +1,6 @@
 package cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.table;
 
 import io.swagger.v3.oas.annotations.media.Schema;
-import jakarta.validation.constraints.NotNull;
 import lombok.Data;
 
 import java.time.LocalDateTime;
@@ -46,9 +45,6 @@ public class CodegenTableRespVO {
     @Schema(description = "前端类型,参见 CodegenFrontTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "20")
     private Integer frontType;
 
-    @Schema(description = "是否生成批量删除接口", example = "true")
-    private Boolean deleteBatch;
-
     @Schema(description = "父菜单编号", example = "1024")
     private Long parentMenuId;
 

+ 0 - 4
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 {
     @NotNull(message = "前端类型不能为空")
     private Integer frontType;
 
-    @Schema(description = "是否生成批量删除接口", example = "true")
-    @NotNull(message = "是否生成批量删除接口不能为空")
-    private Boolean deleteBatch;
-
     @Schema(description = "父菜单编号", example = "1024")
     private Long parentMenuId;
 

+ 0 - 6
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 {
      * 枚举 {@link CodegenFrontTypeEnum}
      */
     private Integer frontType;
-    /**
-     * 是否生成批量删除接口
-     * -true 是
-     * -false 否
-     */
-    private Boolean deleteBatch;
 
     // ========== 菜单相关字段 ==========
 

+ 6 - 0
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/codegen/config/CodegenProperties.java

@@ -40,4 +40,10 @@ public class CodegenProperties {
     @NotNull(message = "是否生成单元测试不能为空")
     private Boolean unitTestEnable;
 
+    /**
+     * 是否生成批量删除接口
+     */
+    @NotNull(message = "是否生成批量删除接口不能为空")
+    private Boolean deleteBatchEnable;
+
 }

+ 1 - 1
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java

@@ -380,7 +380,7 @@ public class CodegenEngine {
         bindingMap.put("columns", columns);
         bindingMap.put("primaryColumn", CollectionUtils.findFirst(columns, CodegenColumnDO::getPrimaryKey)); // 主键字段
         bindingMap.put("sceneEnum", CodegenSceneEnum.valueOf(table.getScene()));
-
+        bindingMap.put("deleteBatchEnable", codegenProperties.getDeleteBatchEnable());
         // className 相关
         // 去掉指定前缀,将 TestDictType 转换成 DictType. 因为在 create 等方法后,不需要带上 Test 前缀
         String simpleClassName = equalsAnyIgnoreCase(table.getClassName(), table.getModuleName()) ? table.getClassName()

+ 2 - 2
yudao-module-infra/src/main/resources/codegen/java/controller/controller.vm

@@ -74,7 +74,7 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
         return success(true);
     }
 
-#if ( $table.templateType != 2 && $table.deleteBatch)
+#if ( $table.templateType != 2 && $deleteBatchEnable)
     @DeleteMapping("/delete-batch")
     @Parameter(name = "ids", description = "编号", required = true)
     @Operation(summary = "批量删除${table.classComment}")
@@ -231,7 +231,7 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
         return success(true);
     }
 
-#if ($table.deleteBatch)
+#if ($deleteBatchEnable)
     @DeleteMapping("/${subSimpleClassName_strikeCase}/delete-batch")
     @Parameter(name = "ids", description = "编号", required = true)
     @Operation(summary = "批量删除${subTable.classComment}")

+ 1 - 1
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
         return delete(${subTable.className}DO::get${SubJoinColumnName}, ${subJoinColumn.javaField});
     }
 
-#if ( $table.templateType != 2 && $table.deleteBatch)
+#if ( $table.templateType != 2 && $deleteBatchEnable)
 	default int deleteBy${SubJoinColumnName}s(List<${subJoinColumn.javaType}> ${subJoinColumn.javaField}s) {
 	    return delete(${subTable.className}DO::get${SubJoinColumnName}, ${subJoinColumn.javaField}s);
 	}

+ 2 - 2
yudao-module-infra/src/main/resources/codegen/java/service/service.vm

@@ -40,7 +40,7 @@ public interface ${table.className}Service {
      */
     void delete${simpleClassName}(${primaryColumn.javaType} id);
 
-#if ( $table.templateType != 2 && $table.deleteBatch)
+#if ( $table.templateType != 2 && $deleteBatchEnable)
     /**
     * 批量删除${table.classComment}
     *
@@ -143,7 +143,7 @@ public interface ${table.className}Service {
      */
     void delete${subSimpleClassName}(${subPrimaryColumn.javaType} id);
 
-#if ($table.deleteBatch)
+#if ($deleteBatchEnable)
     /**
     * 批量删除${subTable.classComment}
     *

+ 4 - 4
yudao-module-infra/src/main/resources/codegen/java/service/serviceImpl.vm

@@ -155,7 +155,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
 #end
     }
 
-#if ( $table.templateType != 2 && $table.deleteBatch)
+#if ( $table.templateType != 2 && $deleteBatchEnable)
     @Override
     ## 特殊:主子表专属逻辑
     #if ( $subTables && $subTables.size() > 0)
@@ -332,7 +332,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
         ${subClassNameVars.get($index)}Mapper.deleteById(id);
     }
 
-#if ($table.deleteBatch)
+#if ($deleteBatchEnable)
 	@Override
 	public void delete${subSimpleClassName}ByIds(List<${subPrimaryColumn.javaType}> ids) {
         // 校验存在
@@ -353,7 +353,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
         }
     }
 
-#if ($table.deleteBatch)
+#if ($deleteBatchEnable)
 	private void validate${subSimpleClassName}Exists(List<${subPrimaryColumn.javaType}> ids) {
         List<${subTable.className}DO> list = ${subClassNameVar}Mapper.selectByIds(ids);
         if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
@@ -400,7 +400,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
         ${subClassNameVars.get($index)}Mapper.deleteBy${SubJoinColumnName}(${subJoinColumn.javaField});
     }
 
-#if ( $table.templateType != 2 && $table.deleteBatch)
+#if ( $table.templateType != 2 && $deleteBatchEnable)
 	private void delete${subSimpleClassName}By${SubJoinColumnName}s(List<${primaryColumn.javaType}> ${subJoinColumn.javaField}s) {
         ${subClassNameVars.get($index)}Mapper.deleteBy${SubJoinColumnName}s(${subJoinColumn.javaField}s);
 	}

+ 2 - 2
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) {
   return requestClient.delete(`${baseURL}/delete?id=${id}`);
 }
 
-#if ( $table.templateType != 2 && $table.deleteBatch)
+#if ( $table.templateType != 2 && $deleteBatchEnable)
 // 批量删除${table.classComment}
 export function delete${simpleClassName}ByIds(ids: number[]) {
   return requestClient.delete(`${baseURL}/delete-batch?ids=${ids.join(',')}`)
@@ -151,7 +151,7 @@ export function delete${subSimpleClassName}(id: number) {
   return requestClient.delete(`${baseURL}/${subSimpleClassName_strikeCase}/delete?id=${id}`);
 }
 
-#if ($table.deleteBatch)
+#if ($deleteBatchEnable)
 // 批量删除${subTable.classComment}
 export function delete${subSimpleClassName}ByIds(ids: number[]) {
   return requestClient.delete(`${baseURL}/${subSimpleClassName_strikeCase}/delete-batch?ids=${ids.join(',')}`)

+ 2 - 2
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/data.ts.vm

@@ -193,7 +193,7 @@ export function useGridColumns(
   onActionClick?: OnActionClickFn<${simpleClassName}Api.${simpleClassName}>,
 ): VxeTableGridOptions<${simpleClassName}Api.${simpleClassName}>['columns'] {
   return [
-#if ($table.templateType != 2 && $table.deleteBatch)
+#if ($table.templateType != 2 && $deleteBatchEnable)
   { type: 'checkbox', width: 40 },
 #end
 #if ($table.templateType == 12) ## 内嵌情况
@@ -431,7 +431,7 @@ export function use${subSimpleClassName}GridColumns(
     onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>,
 ): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] {
     return [
-        #if ($table.templateType != 2 && $table.deleteBatch)
+        #if ($table.templateType != 2 && $deleteBatchEnable)
             { type: 'checkbox', width: 40 },
         #end
         #foreach($column in $subColumns)

+ 5 - 5
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';
 #if (${table.templateType} == 2)## 树表接口
 import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
 #else## 标准表接口
-import { get${simpleClassName}Page, delete${simpleClassName},#if ($table.deleteBatch) delete${simpleClassName}ByIds,#end export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
+import { get${simpleClassName}Page, delete${simpleClassName},#if ($deleteBatchEnable) delete${simpleClassName}ByIds,#end export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
 #end
 import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
 
@@ -92,7 +92,7 @@ async function onDelete(row: ${simpleClassName}Api.${simpleClassName}) {
   }
 }
 
-#if ($table.templateType != 2 && $table.deleteBatch)
+#if ($table.templateType != 2 && $deleteBatchEnable)
 const deleteIds = ref<number[]>([]) // 待删除${table.classComment} ID
 const showDeleteBatchBtn = computed(() => isEmpty(deleteIds.value));
 function setDeleteIds({
@@ -204,14 +204,14 @@ const [Grid, gridApi] = useVbenVxeGrid({
       search: true,
     },
   } as VxeTableGridOptions<${simpleClassName}Api.${simpleClassName}>,
-#if (${table.templateType} == 11 || $table.deleteBatch)
+#if (${table.templateType} == 11 || $deleteBatchEnable)
   gridEvents:{
     #if(${table.templateType} == 11)
     cellClick: ({ row }: { row: ${simpleClassName}Api.${simpleClassName}}) => {
       select${simpleClassName}.value = row;
     },
     #end
-    #if($table.deleteBatch)
+    #if($deleteBatchEnable)
       checkboxAll: setDeleteIds,
       checkboxChange: setDeleteIds,
     #end
@@ -262,7 +262,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
         >
           {{ $t('ui.actionTitle.export') }}
         </Button>
-#if ($table.templateType != 2 && $table.deleteBatch)
+#if ($table.templateType != 2 && $deleteBatchEnable)
         <Button
             :icon="h(Trash2)"
             type="primary"

+ 4 - 4
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/modules/list_sub_erp.vue.vm

@@ -21,7 +21,7 @@
 
 
 #if ($table.templateType == 11) ## erp
-  import { delete${subSimpleClassName},#if ($table.deleteBatch) delete${subSimpleClassName}ByIds,#end get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${table.businessName}';
+  import { delete${subSimpleClassName},#if ($deleteBatchEnable) delete${subSimpleClassName}ByIds,#end get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${table.businessName}';
   import { use${subSimpleClassName}GridFormSchema, use${subSimpleClassName}GridColumns } from '../data';
   import { isEmpty } from '@vben/utils';
   #else
@@ -73,7 +73,7 @@ async function onDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
   }
 }
 
-#if ($table.deleteBatch)
+#if ($deleteBatchEnable)
 const deleteIds = ref<number[]>([]) // 待删除${subTable.classComment} ID
 const showDeleteBatchBtn = computed(() => isEmpty(deleteIds.value));
 function setDeleteIds({
@@ -164,7 +164,7 @@ function onActionClick({
         isHover: true,
     },
     } as VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>,
-    #if (${table.templateType} == 11 && $table.deleteBatch)
+    #if (${table.templateType} == 11 && $deleteBatchEnable)
     gridEvents:{
       checkboxAll: setDeleteIds,
       checkboxChange: setDeleteIds,
@@ -207,7 +207,7 @@ const onRefresh = async ()=> {
           <Button :icon="h(Plus)" type="primary" @click="onCreate" v-access:code="['${table.moduleName}:${simpleClassName_strikeCase}:create']">
             {{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
           </Button>
-            #if ($table.templateType == 11 && $table.deleteBatch)
+            #if ($table.templateType == 11 && $deleteBatchEnable)
               <Button
                   :icon="h(Trash2)"
                   type="primary"

+ 1 - 0
yudao-server/src/main/resources/application.yaml

@@ -270,6 +270,7 @@ yudao:
     db-schemas: ${spring.datasource.dynamic.datasource.master.name}
     front-type: 20 # 前端模版的类型,参见 CodegenFrontTypeEnum 枚举类
     unit-test-enable: false # 是否生成单元测试
+    delete-batch-enable: false # 是否生成批量删除接口
   tenant: # 多租户相关配置项
     enable: true
     ignore-urls: