Explorar el Código

perf:【INFRA 基础设施】vben5-antd-schema 主主子表erp代码生成时,可生成批量删除

puhui999 hace 5 meses
padre
commit
ef1e7b312b
Se han modificado 19 ficheros con 285 adiciones y 154 borrados
  1. 35 24
      yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/Demo03StudentController.java
  2. 1 1
      yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentPageReqVO.java
  3. 1 1
      yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentRespVO.java
  4. 2 9
      yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentSaveReqVO.java
  5. 0 1
      yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/package-info.java
  6. 8 8
      yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03CourseMapper.java
  7. 12 7
      yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03GradeMapper.java
  8. 3 3
      yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03StudentMapper.java
  9. 3 2
      yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants.java
  10. 36 34
      yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentService.java
  11. 82 58
      yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentServiceImpl.java
  12. 1 0
      yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/package-info.java
  13. 14 1
      yudao-module-infra/src/main/resources/codegen/java/controller/controller.vm
  14. 9 0
      yudao-module-infra/src/main/resources/codegen/java/service/service.vm
  15. 19 0
      yudao-module-infra/src/main/resources/codegen/java/service/serviceImpl.vm
  16. 7 0
      yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/api/api.ts.vm
  17. 3 0
      yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/data.ts.vm
  18. 1 1
      yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/index.vue.vm
  19. 48 4
      yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/modules/list_sub_erp.vue.vm

+ 35 - 24
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/Demo03StudentController.java → yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/Demo03StudentController.java

@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03;
+package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp;
 
 import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
@@ -6,13 +6,13 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
-import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentPageReqVO;
-import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentRespVO;
-import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentSaveReqVO;
+import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentPageReqVO;
+import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentRespVO;
+import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentSaveReqVO;
 import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
 import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
 import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
-import cn.iocoder.yudao.module.infra.service.demo.demo03.Demo03StudentService;
+import cn.iocoder.yudao.module.infra.service.demo.demo03.erp.Demo03StudentService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -31,7 +31,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
 @Tag(name = "管理后台 - 学生")
 @RestController
-@RequestMapping("/infra/demo03-student")
+@RequestMapping("/infra/demo03-student-erp")
 @Validated
 public class Demo03StudentController {
 
@@ -62,6 +62,15 @@ public class Demo03StudentController {
         return success(true);
     }
 
+    @DeleteMapping("/delete-batch")
+    @Parameter(name = "ids", description = "编号", required = true)
+    @Operation(summary = "批量删除学生")
+    @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
+    public CommonResult<Boolean> deleteDemo03Student(@RequestParam("ids") List<Long> ids) {
+        demo03StudentService.deleteDemo03StudentByIds(ids);
+        return success(true);
+    }
+
     @GetMapping("/get")
     @Operation(summary = "获得学生")
     @Parameter(name = "id", description = "编号", required = true, example = "1024")
@@ -84,12 +93,12 @@ public class Demo03StudentController {
     @PreAuthorize("@ss.hasPermission('infra:demo03-student:export')")
     @ApiAccessLog(operateType = EXPORT)
     public void exportDemo03StudentExcel(@Valid Demo03StudentPageReqVO pageReqVO,
-              HttpServletResponse response) throws IOException {
+                                         HttpServletResponse response) throws IOException {
         pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
         List<Demo03StudentDO> list = demo03StudentService.getDemo03StudentPage(pageReqVO).getList();
         // 导出 Excel
         ExcelUtils.write(response, "学生.xls", "数据", Demo03StudentRespVO.class,
-                        BeanUtils.toBean(list, Demo03StudentRespVO.class));
+                BeanUtils.toBean(list, Demo03StudentRespVO.class));
     }
 
     // ==================== 子表(学生课程) ====================
@@ -127,6 +136,15 @@ public class Demo03StudentController {
         return success(true);
     }
 
+    @DeleteMapping("/demo03-course/delete-batch")
+    @Parameter(name = "ids", description = "编号", required = true)
+    @Operation(summary = "批量删除学生课程")
+    @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
+    public CommonResult<Boolean> deleteDemo03Course(@RequestParam("ids") List<Long> ids) {
+        demo03StudentService.deleteDemo03CourseByIds(ids);
+        return success(true);
+    }
+
     @GetMapping("/demo03-course/get")
     @Operation(summary = "获得学生课程")
     @Parameter(name = "id", description = "编号", required = true)
@@ -135,14 +153,6 @@ public class Demo03StudentController {
         return success(demo03StudentService.getDemo03Course(id));
     }
 
-    @GetMapping("/demo03-course/list-by-student-id")
-    @Operation(summary = "获得学生课程列表")
-    @Parameter(name = "studentId", description = "学生编号")
-    @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
-    public CommonResult<List<Demo03CourseDO>> getDemo03CourseListByStudentId(@RequestParam("studentId") Long studentId) {
-        return success(demo03StudentService.getDemo03CourseListByStudentId(studentId));
-    }
-
     // ==================== 子表(学生班级) ====================
 
     @GetMapping("/demo03-grade/page")
@@ -178,6 +188,15 @@ public class Demo03StudentController {
         return success(true);
     }
 
+    @DeleteMapping("/demo03-grade/delete-batch")
+    @Parameter(name = "ids", description = "编号", required = true)
+    @Operation(summary = "批量删除学生班级")
+    @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
+    public CommonResult<Boolean> deleteDemo03Grade(@RequestParam("ids") List<Long> ids) {
+        demo03StudentService.deleteDemo03GradeByIds(ids);
+        return success(true);
+    }
+
     @GetMapping("/demo03-grade/get")
     @Operation(summary = "获得学生班级")
     @Parameter(name = "id", description = "编号", required = true)
@@ -186,12 +205,4 @@ public class Demo03StudentController {
         return success(demo03StudentService.getDemo03Grade(id));
     }
 
-    @GetMapping("/demo03-grade/get-by-student-id")
-    @Operation(summary = "获得学生班级")
-    @Parameter(name = "studentId", description = "学生编号")
-    @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
-    public CommonResult<Demo03GradeDO> getDemo03GradeByStudentId(@RequestParam("studentId") Long studentId) {
-        return success(demo03StudentService.getDemo03GradeByStudentId(studentId));
-    }
-
 }

+ 1 - 1
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/vo/Demo03StudentPageReqVO.java → yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentPageReqVO.java

@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo;
+package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo;
 
 import lombok.*;
 import io.swagger.v3.oas.annotations.media.Schema;

+ 1 - 1
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/vo/Demo03StudentRespVO.java → yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentRespVO.java

@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo;
+package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo;
 
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.*;

+ 2 - 9
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/vo/Demo03StudentSaveReqVO.java → yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentSaveReqVO.java

@@ -1,12 +1,10 @@
-package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo;
+package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo;
 
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.*;
-import java.util.*;
 import jakarta.validation.constraints.*;
+
 import java.time.LocalDateTime;
-import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
-import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
 
 @Schema(description = "管理后台 - 学生新增/修改 Request VO")
 @Data
@@ -31,9 +29,4 @@ public class Demo03StudentSaveReqVO {
     @NotEmpty(message = "简介不能为空")
     private String description;
 
-
-    private List<Demo03CourseDO> demo03Courses;
-
-    private Demo03GradeDO demo03Grade;
-
 }

+ 0 - 1
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/package-info.java

@@ -1 +0,0 @@
-package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03;

+ 8 - 8
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/Demo03CourseMapper.java → yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03CourseMapper.java

@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03;
+package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp;
 
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
@@ -19,16 +19,16 @@ public interface Demo03CourseMapper extends BaseMapperX<Demo03CourseDO> {
 
     default PageResult<Demo03CourseDO> selectPage(PageParam reqVO, Long studentId) {
         return selectPage(reqVO, new LambdaQueryWrapperX<Demo03CourseDO>()
-                .eq(Demo03CourseDO::getStudentId, studentId)
-                .orderByDesc(Demo03CourseDO::getId));
-    }
-
-    default List<Demo03CourseDO> selectListByStudentId(Long studentId) {
-        return selectList(Demo03CourseDO::getStudentId, studentId);
+            .eq(Demo03CourseDO::getStudentId, studentId)
+            .orderByDesc(Demo03CourseDO::getId));
     }
 
     default int deleteByStudentId(Long studentId) {
         return delete(Demo03CourseDO::getStudentId, studentId);
     }
 
-}
+	default int deleteByStudentIds(List<Long> studentIds) {
+	    return delete(Demo03CourseDO::getStudentId, studentIds);
+	}
+
+}

+ 12 - 7
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/Demo03GradeMapper.java → yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03GradeMapper.java

@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03;
+package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp;
 
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
@@ -7,6 +7,8 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 /**
  * 学生班级 Mapper
  *
@@ -17,16 +19,19 @@ public interface Demo03GradeMapper extends BaseMapperX<Demo03GradeDO> {
 
     default PageResult<Demo03GradeDO> selectPage(PageParam reqVO, Long studentId) {
         return selectPage(reqVO, new LambdaQueryWrapperX<Demo03GradeDO>()
-                .eq(Demo03GradeDO::getStudentId, studentId)
-                .orderByDesc(Demo03GradeDO::getId));
+            .eq(Demo03GradeDO::getStudentId, studentId)
+            .orderByDesc(Demo03GradeDO::getId));
     }
-
-    default Demo03GradeDO selectByStudentId(Long studentId) {
+        default Demo03GradeDO selectByStudentId(Long studentId) {
         return selectOne(Demo03GradeDO::getStudentId, studentId);
-    }
+        }
 
     default int deleteByStudentId(Long studentId) {
         return delete(Demo03GradeDO::getStudentId, studentId);
     }
 
-}
+	default int deleteByStudentIds(List<Long> studentIds) {
+	    return delete(Demo03GradeDO::getStudentId, studentIds);
+	}
+
+}

+ 3 - 3
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/Demo03StudentMapper.java → yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03StudentMapper.java

@@ -1,11 +1,11 @@
-package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03;
+package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp;
 
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.*;
 import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
 import org.apache.ibatis.annotations.Mapper;
-import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.*;
 
 /**
  * 学生 Mapper

+ 3 - 2
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants.java

@@ -65,7 +65,8 @@ public interface ErrorCodeConstants {
     ErrorCode DEMO02_CATEGORY_NAME_DUPLICATE = new ErrorCode(1_001_201_005, "已经存在该名字的示例分类");
     ErrorCode DEMO02_CATEGORY_PARENT_IS_CHILD = new ErrorCode(1_001_201_006, "不能设置自己的子示例分类为父示例分类");
     ErrorCode DEMO03_STUDENT_NOT_EXISTS = new ErrorCode(1_001_201_007, "学生不存在");
-    ErrorCode DEMO03_GRADE_NOT_EXISTS = new ErrorCode(1_001_201_008, "学生班级不存在");
-    ErrorCode DEMO03_GRADE_EXISTS = new ErrorCode(1_001_201_009, "学生班级已存在");
+    ErrorCode DEMO03_COURSE_NOT_EXISTS = new ErrorCode(1_001_201_008, "学生课程不存在");
+    ErrorCode DEMO03_GRADE_NOT_EXISTS = new ErrorCode(1_001_201_009, "学生班级不存在");
+    ErrorCode DEMO03_GRADE_EXISTS = new ErrorCode(1_001_201_010, "学生班级已存在");
 
 }

+ 36 - 34
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/Demo03StudentService.java → yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentService.java

@@ -1,15 +1,13 @@
-package cn.iocoder.yudao.module.infra.service.demo.demo03;
+package cn.iocoder.yudao.module.infra.service.demo.demo03.erp;
 
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentPageReqVO;
-import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentSaveReqVO;
+import java.util.*;
+import jakarta.validation.*;
+import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.*;
+import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
 import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
 import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
-import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
-
-import jakarta.validation.Valid;
-import java.util.List;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
 
 /**
  * 学生 Service 接口
@@ -40,6 +38,13 @@ public interface Demo03StudentService {
      */
     void deleteDemo03Student(Long id);
 
+    /**
+    * 批量删除学生
+    *
+    * @param ids 编号
+    */
+    void deleteDemo03StudentByIds(List<Long> ids);
+
     /**
      * 获得学生
      *
@@ -56,17 +61,8 @@ public interface Demo03StudentService {
      */
     PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentPageReqVO pageReqVO);
 
-
     // ==================== 子表(学生课程) ====================
 
-    /**
-     * 获得学生课程列表
-     *
-     * @param studentId 学生编号
-     * @return 学生课程列表
-     */
-    List<Demo03CourseDO> getDemo03CourseListByStudentId(Long studentId);
-
     /**
      * 获得学生课程分页
      *
@@ -99,23 +95,22 @@ public interface Demo03StudentService {
     void deleteDemo03Course(Long id);
 
     /**
-     * 获得学生课程
-     *
-     * @param id 编号
+    * 批量删除学生课程
+    *
+    * @param ids 编号
+    */
+    void deleteDemo03CourseByIds(List<Long> ids);
+
+	/**
+	 * 获得学生课程
+	 *
+	 * @param id 编号
      * @return 学生课程
-     */
+	 */
     Demo03CourseDO getDemo03Course(Long id);
 
     // ==================== 子表(学生班级) ====================
 
-    /**
-     * 获得学生班级
-     *
-     * @param studentId 学生编号
-     * @return 学生班级
-     */
-    Demo03GradeDO getDemo03GradeByStudentId(Long studentId);
-
     /**
      * 获得学生班级分页
      *
@@ -148,11 +143,18 @@ public interface Demo03StudentService {
     void deleteDemo03Grade(Long id);
 
     /**
-     * 获得学生班级
-     *
-     * @param id 编号
+    * 批量删除学生班级
+    *
+    * @param ids 编号
+    */
+    void deleteDemo03GradeByIds(List<Long> ids);
+
+	/**
+	 * 获得学生班级
+	 *
+	 * @param id 编号
      * @return 学生班级
-     */
+	 */
     Demo03GradeDO getDemo03Grade(Long id);
 
 }

+ 82 - 58
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/Demo03StudentServiceImpl.java → yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentServiceImpl.java

@@ -1,21 +1,22 @@
-package cn.iocoder.yudao.module.infra.service.demo.demo03;
+package cn.iocoder.yudao.module.infra.service.demo.demo03.erp;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
-import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentPageReqVO;
-import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentSaveReqVO;
+import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentPageReqVO;
+import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentSaveReqVO;
 import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
 import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
 import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
-import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.Demo03CourseMapper;
-import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.Demo03GradeMapper;
-import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.Demo03StudentMapper;
+import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp.Demo03CourseMapper;
+import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp.Demo03GradeMapper;
+import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp.Demo03StudentMapper;
+import jakarta.annotation.Resource;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
 
-import jakarta.annotation.Resource;
 import java.util.List;
 
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@@ -38,31 +39,21 @@ public class Demo03StudentServiceImpl implements Demo03StudentService {
     private Demo03GradeMapper demo03GradeMapper;
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
     public Long createDemo03Student(Demo03StudentSaveReqVO createReqVO) {
         // 插入
         Demo03StudentDO demo03Student = BeanUtils.toBean(createReqVO, Demo03StudentDO.class);
         demo03StudentMapper.insert(demo03Student);
-
-        // 插入子表
-        createDemo03CourseList(demo03Student.getId(), createReqVO.getDemo03Courses());
-        createDemo03Grade(demo03Student.getId(), createReqVO.getDemo03Grade());
         // 返回
         return demo03Student.getId();
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
     public void updateDemo03Student(Demo03StudentSaveReqVO updateReqVO) {
         // 校验存在
         validateDemo03StudentExists(updateReqVO.getId());
         // 更新
         Demo03StudentDO updateObj = BeanUtils.toBean(updateReqVO, Demo03StudentDO.class);
         demo03StudentMapper.updateById(updateObj);
-
-        // 更新子表
-        updateDemo03CourseList(updateReqVO.getId(), updateReqVO.getDemo03Courses());
-        updateDemo03Grade(updateReqVO.getId(), updateReqVO.getDemo03Grade());
     }
 
     @Override
@@ -78,6 +69,26 @@ public class Demo03StudentServiceImpl implements Demo03StudentService {
         deleteDemo03GradeByStudentId(id);
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void deleteDemo03StudentByIds(List<Long> ids) {
+        // 校验存在
+        validateDemo03StudentExists(ids);
+        // 删除
+        demo03StudentMapper.deleteByIds(ids);
+
+        // 删除子表
+        deleteDemo03CourseByStudentIds(ids);
+        deleteDemo03GradeByStudentIds(ids);
+    }
+
+    private void validateDemo03StudentExists(List<Long> ids) {
+        List<Demo03StudentDO> list = demo03StudentMapper.selectByIds(ids);
+        if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
+            throw exception(DEMO03_STUDENT_NOT_EXISTS);
+        }
+    }
+
     private void validateDemo03StudentExists(Long id) {
         if (demo03StudentMapper.selectById(id) == null) {
             throw exception(DEMO03_STUDENT_NOT_EXISTS);
@@ -96,28 +107,6 @@ public class Demo03StudentServiceImpl implements Demo03StudentService {
 
     // ==================== 子表(学生课程) ====================
 
-    @Override
-    public List<Demo03CourseDO> getDemo03CourseListByStudentId(Long studentId) {
-        return demo03CourseMapper.selectListByStudentId(studentId);
-    }
-
-    private void createDemo03CourseList(Long studentId, List<Demo03CourseDO> list) {
-        if (list != null) {
-            list.forEach(o -> o.setStudentId(studentId));
-        }
-        demo03CourseMapper.insertBatch(list);
-    }
-
-    private void updateDemo03CourseList(Long studentId, List<Demo03CourseDO> list) {
-        deleteDemo03CourseByStudentId(studentId);
-		list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新
-        createDemo03CourseList(studentId, list);
-    }
-
-    private void deleteDemo03CourseByStudentId(Long studentId) {
-        demo03CourseMapper.deleteByStudentId(studentId);
-    }
-
     @Override
     public PageResult<Demo03CourseDO> getDemo03CoursePage(PageParam pageReqVO, Long studentId) {
         return demo03CourseMapper.selectPage(pageReqVO, studentId);
@@ -131,47 +120,57 @@ public class Demo03StudentServiceImpl implements Demo03StudentService {
 
     @Override
     public void updateDemo03Course(Demo03CourseDO demo03Course) {
+        // 校验存在
+        validateDemo03CourseExists(demo03Course.getId());
+        // 更新
+        demo03Course.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新
         demo03CourseMapper.updateById(demo03Course);
     }
 
     @Override
     public void deleteDemo03Course(Long id) {
+        // 校验存在
+        validateDemo03CourseExists(id);
+        // 删除
         demo03CourseMapper.deleteById(id);
     }
 
     @Override
-    public Demo03CourseDO getDemo03Course(Long id) {
-        return demo03CourseMapper.selectById(id);
+    public void deleteDemo03CourseByIds(List<Long> ids) {
+        // 校验存在
+        validateDemo03CourseExists(ids);
+        // 删除
+        demo03CourseMapper.deleteByIds(ids);
     }
 
-    // ==================== 子表(学生班级) ====================
-
     @Override
-    public Demo03GradeDO getDemo03GradeByStudentId(Long studentId) {
-        return demo03GradeMapper.selectByStudentId(studentId);
+    public Demo03CourseDO getDemo03Course(Long id) {
+        return demo03CourseMapper.selectById(id);
     }
 
-    private void createDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) {
-        if (demo03Grade == null) {
-            return;
+    private void validateDemo03CourseExists(Long id) {
+        if (demo03CourseMapper.selectById(id) == null) {
+            throw exception(DEMO03_COURSE_NOT_EXISTS);
         }
-        demo03Grade.setStudentId(studentId);
-        demo03GradeMapper.insert(demo03Grade);
     }
 
-    private void updateDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) {
-        if (demo03Grade == null) {
-			return;
+    private void validateDemo03CourseExists(List<Long> ids) {
+        List<Demo03CourseDO> list = demo03CourseMapper.selectByIds(ids);
+        if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
+            throw exception(DEMO03_COURSE_NOT_EXISTS);
         }
-        demo03Grade.setStudentId(studentId);
-        demo03Grade.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新
-        demo03GradeMapper.insertOrUpdate(demo03Grade);
     }
 
-    private void deleteDemo03GradeByStudentId(Long studentId) {
-        demo03GradeMapper.deleteByStudentId(studentId);
+    private void deleteDemo03CourseByStudentId(Long studentId) {
+        demo03CourseMapper.deleteByStudentId(studentId);
     }
 
+    private void deleteDemo03CourseByStudentIds(List<Long> studentIds) {
+        demo03CourseMapper.deleteByStudentIds(studentIds);
+    }
+
+    // ==================== 子表(学生班级) ====================
+
     @Override
     public PageResult<Demo03GradeDO> getDemo03GradePage(PageParam pageReqVO, Long studentId) {
         return demo03GradeMapper.selectPage(pageReqVO, studentId);
@@ -183,6 +182,7 @@ public class Demo03StudentServiceImpl implements Demo03StudentService {
         if (demo03GradeMapper.selectByStudentId(demo03Grade.getStudentId()) != null) {
             throw exception(DEMO03_GRADE_EXISTS);
         }
+        // 插入
         demo03GradeMapper.insert(demo03Grade);
         return demo03Grade.getId();
     }
@@ -192,6 +192,7 @@ public class Demo03StudentServiceImpl implements Demo03StudentService {
         // 校验存在
         validateDemo03GradeExists(demo03Grade.getId());
         // 更新
+        demo03Grade.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新
         demo03GradeMapper.updateById(demo03Grade);
     }
 
@@ -203,6 +204,14 @@ public class Demo03StudentServiceImpl implements Demo03StudentService {
         demo03GradeMapper.deleteById(id);
     }
 
+    @Override
+    public void deleteDemo03GradeByIds(List<Long> ids) {
+        // 校验存在
+        validateDemo03GradeExists(ids);
+        // 删除
+        demo03GradeMapper.deleteByIds(ids);
+    }
+
     @Override
     public Demo03GradeDO getDemo03Grade(Long id) {
         return demo03GradeMapper.selectById(id);
@@ -214,4 +223,19 @@ public class Demo03StudentServiceImpl implements Demo03StudentService {
         }
     }
 
+    private void validateDemo03GradeExists(List<Long> ids) {
+        List<Demo03GradeDO> list = demo03GradeMapper.selectByIds(ids);
+        if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
+            throw exception(DEMO03_GRADE_NOT_EXISTS);
+        }
+    }
+
+    private void deleteDemo03GradeByStudentId(Long studentId) {
+        demo03GradeMapper.deleteByStudentId(studentId);
+    }
+
+    private void deleteDemo03GradeByStudentIds(List<Long> studentIds) {
+        demo03GradeMapper.deleteByStudentIds(studentIds);
+    }
+
 }

+ 1 - 0
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/package-info.java

@@ -0,0 +1 @@
+package cn.iocoder.yudao.module.infra.service.demo.demo03;

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

@@ -81,7 +81,7 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
     #if ($sceneEnum.scene == 1)
                 @PreAuthorize("@ss.hasPermission('${permissionPrefix}:delete')")
     #end
-    public CommonResult<Boolean> delete${simpleClassName}(@RequestParam("ids") @Size(max = 100, message = "最多允许100个") List<${primaryColumn.javaType}> ids) {
+    public CommonResult<Boolean> delete${simpleClassName}(@RequestParam("ids") List<${primaryColumn.javaType}> ids) {
         ${classNameVar}Service.delete${simpleClassName}ByIds(ids);
         return success(true);
     }
@@ -231,6 +231,19 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
         return success(true);
     }
 
+#if ($table.deleteBatch)
+    @DeleteMapping("/${subSimpleClassName_strikeCase}/delete-batch")
+    @Parameter(name = "ids", description = "编号", required = true)
+    @Operation(summary = "批量删除${subTable.classComment}")
+#if ($sceneEnum.scene == 1)
+    @PreAuthorize("@ss.hasPermission('${permissionPrefix}:delete')")
+#end
+    public CommonResult<Boolean> delete${subSimpleClassName}(@RequestParam("ids") List<${subPrimaryColumn.javaType}> ids) {
+        ${classNameVar}Service.delete${subSimpleClassName}ByIds(ids);
+        return success(true);
+    }
+#end
+
 	@GetMapping("/${subSimpleClassName_strikeCase}/get")
 	@Operation(summary = "获得${subTable.classComment}")
 	@Parameter(name = "id", description = "编号", required = true)

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

@@ -143,6 +143,15 @@ public interface ${table.className}Service {
      */
     void delete${subSimpleClassName}(${subPrimaryColumn.javaType} id);
 
+#if ($table.deleteBatch)
+    /**
+    * 批量删除${subTable.classComment}
+    *
+    * @param ids 编号
+    */
+    void delete${subSimpleClassName}ByIds(List<${subPrimaryColumn.javaType}> ids);
+#end
+
 	/**
 	 * 获得${subTable.classComment}
 	 *

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

@@ -332,6 +332,16 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
         ${subClassNameVars.get($index)}Mapper.deleteById(id);
     }
 
+#if ($table.deleteBatch)
+	@Override
+	public void delete${subSimpleClassName}ByIds(List<${subPrimaryColumn.javaType}> ids) {
+        // 校验存在
+        validate${subSimpleClassName}Exists(ids);
+        // 删除
+        ${subClassNameVars.get($index)}Mapper.deleteByIds(ids);
+	}
+#end
+
     @Override
     public ${subTable.className}DO get${subSimpleClassName}(${subPrimaryColumn.javaType} id) {
         return ${subClassNameVars.get($index)}Mapper.selectById(id);
@@ -343,6 +353,15 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
         }
     }
 
+#if ($table.deleteBatch)
+	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()) {
+            throw exception(${simpleClassNameUnderlineCase.toUpperCase()}_NOT_EXISTS);
+        }
+	}
+#end
+
 ## 情况二:非 MASTER_ERP 时,支持批量的新增、修改操作
 #else
     #if ( $subTable.subJoinMany)

+ 7 - 0
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/api/api.ts.vm

@@ -151,6 +151,13 @@ export function delete${subSimpleClassName}(id: number) {
   return requestClient.delete(`${baseURL}/${subSimpleClassName_strikeCase}/delete?id=${id}`);
 }
 
+#if ($table.deleteBatch)
+// 批量删除${subTable.classComment}
+export function delete${subSimpleClassName}ByIds(ids: number[]) {
+  return requestClient.delete(`${baseURL}/${subSimpleClassName_strikeCase}/delete-batch?ids=${ids.join(',')}`)
+}
+#end
+
 /** 获得${subTable.classComment} */
 export function get${subSimpleClassName}(id: number) {
   return requestClient.get<${simpleClassName}Api.${subSimpleClassName}>(`${baseURL}/${subSimpleClassName_strikeCase}/get?id=${id}`);

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

@@ -431,6 +431,9 @@ export function use${subSimpleClassName}GridColumns(
     onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>,
 ): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] {
     return [
+        #if ($table.templateType != 2 && $table.deleteBatch)
+            { type: 'checkbox', width: 40 },
+        #end
         #foreach($column in $subColumns)
             #if ($column.listOperationResult)
                 #set ($dictType = $column.dictType)

+ 1 - 1
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},delete${simpleClassName}ByIds, export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
+import { get${simpleClassName}Page, delete${simpleClassName},#if ($table.deleteBatch) delete${simpleClassName}ByIds,#end export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
 #end
 import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
 

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

@@ -14,15 +14,16 @@
 #end
   import { useVbenModal } from '@vben/common-ui';
   import { Button, message } from 'ant-design-vue';
-  import { Plus } from '@vben/icons';
-  import { #if($table.templateType != 11)ref,#end h, nextTick,watch } from 'vue';
+  import { Plus, Trash2 } from '@vben/icons';
+  import { ref, computed, h, nextTick,watch } from 'vue';
   import { $t } from '#/locales';
   import { useVbenVxeGrid } from '#/adapter/vxe-table';
 
 
 #if ($table.templateType == 11) ## erp
-  import { delete${subSimpleClassName}, get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${table.businessName}';
+  import { delete${subSimpleClassName},#if ($table.deleteBatch) 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
   #if ($subTable.subJoinMany) ## 一对多
   import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
@@ -67,11 +68,31 @@ async function onDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
     await delete${subSimpleClassName}(row.id as number);
     message.success( $t('ui.actionMessage.deleteSuccess', [row.id]) );
     onRefresh();
-  } catch {
+  } finally {
     hideLoading();
   }
 }
 
+#if ($table.deleteBatch)
+const deleteIds = ref<number[]>([]) // 待删除${subTable.classComment} ID
+const showDeleteBatchBtn = computed(() => isEmpty(deleteIds.value));
+/** 批量删除${subTable.classComment} */
+async function onDeleteBatch() {
+  const hideLoading = message.loading({
+    content: $t('ui.actionMessage.deleting'),
+    duration: 0,
+    key: 'action_process_msg',
+  });
+  try {
+    await delete${subSimpleClassName}ByIds(deleteIds.value);
+    message.success( $t('ui.actionMessage.deleteSuccess') );
+    onRefresh();
+  } finally {
+    hideLoading();
+  }
+}
+#end
+
 /** 表格操作按钮的回调函数 */
 function onActionClick({
  code,
@@ -136,6 +157,16 @@ function onActionClick({
         isHover: true,
     },
     } as VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>,
+    #if (${table.templateType} == 11 && $table.deleteBatch)
+    gridEvents:{
+      checkboxAll: ({records,}: { records: ${simpleClassName}Api.${subSimpleClassName}[];}) => {
+        deleteIds.value = records.map((item) => item.id);
+      },
+      checkboxChange: ({records,}: { records: ${simpleClassName}Api.${subSimpleClassName}[];}) => {
+        deleteIds.value = records.map((item) => item.id);
+      },
+    }
+    #end
   });
 
 /** 刷新表格 */
@@ -173,6 +204,19 @@ 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)
+              <Button
+                  :icon="h(Trash2)"
+                  type="primary"
+                  danger
+                  class="ml-2"
+                  :disabled="showDeleteBatchBtn"
+                  @click="onDeleteBatch"
+                  v-access:code="['${table.moduleName}:${simpleClassName_strikeCase}:delete']"
+              >
+                批量删除
+              </Button>
+            #end
         </template>
       </Grid>
     #else