Commit e10425e049daac247b77b4fc4b193d14298c9e11
1 parent
ef1e7b31
perf:【INFRA 基础设施】vben5-antd-schema 主主子表normal代码生成时,可生成批量删除
Showing
21 changed files
with
685 additions
and
100 deletions
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/Demo01ContactController.java
| ... | ... | @@ -17,7 +17,6 @@ import io.swagger.v3.oas.annotations.tags.Tag; |
| 17 | 17 | import jakarta.annotation.Resource; |
| 18 | 18 | import jakarta.servlet.http.HttpServletResponse; |
| 19 | 19 | import jakarta.validation.Valid; |
| 20 | -import jakarta.validation.constraints.Size; | |
| 21 | 20 | import org.springframework.security.access.prepost.PreAuthorize; |
| 22 | 21 | import org.springframework.validation.annotation.Validated; |
| 23 | 22 | import org.springframework.web.bind.annotation.*; |
| ... | ... | @@ -65,7 +64,7 @@ public class Demo01ContactController { |
| 65 | 64 | @Parameter(name = "ids", description = "编号", required = true) |
| 66 | 65 | @Operation(summary = "批量删除示例联系人") |
| 67 | 66 | @PreAuthorize("@ss.hasPermission('infra:demo01-contact:delete')") |
| 68 | - public CommonResult<Boolean> deleteDemo01Contact(@RequestParam("ids") @Size(max = 100, message = "最多允许100个") List<Long> ids) { | |
| 67 | + public CommonResult<Boolean> deleteDemo01Contact(@RequestParam("ids") List<Long> ids) { | |
| 69 | 68 | demo01ContactService.deleteDemo01ContactByIds(ids); |
| 70 | 69 | return success(true); |
| 71 | 70 | } | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/Demo03StudentController.java renamed to yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/Demo03StudentErpController.java
| ... | ... | @@ -6,13 +6,13 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 8 | 8 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 9 | -import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentPageReqVO; | |
| 10 | -import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentRespVO; | |
| 11 | -import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentSaveReqVO; | |
| 9 | +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpPageReqVO; | |
| 10 | +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpRespVO; | |
| 11 | +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpSaveReqVO; | |
| 12 | 12 | import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO; |
| 13 | 13 | import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO; |
| 14 | 14 | import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO; |
| 15 | -import cn.iocoder.yudao.module.infra.service.demo.demo03.erp.Demo03StudentService; | |
| 15 | +import cn.iocoder.yudao.module.infra.service.demo.demo03.erp.Demo03StudentErpService; | |
| 16 | 16 | import io.swagger.v3.oas.annotations.Operation; |
| 17 | 17 | import io.swagger.v3.oas.annotations.Parameter; |
| 18 | 18 | import io.swagger.v3.oas.annotations.tags.Tag; |
| ... | ... | @@ -33,23 +33,23 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 33 | 33 | @RestController |
| 34 | 34 | @RequestMapping("/infra/demo03-student-erp") |
| 35 | 35 | @Validated |
| 36 | -public class Demo03StudentController { | |
| 36 | +public class Demo03StudentErpController { | |
| 37 | 37 | |
| 38 | 38 | @Resource |
| 39 | - private Demo03StudentService demo03StudentService; | |
| 39 | + private Demo03StudentErpService demo03StudentErpService; | |
| 40 | 40 | |
| 41 | 41 | @PostMapping("/create") |
| 42 | 42 | @Operation(summary = "创建学生") |
| 43 | 43 | @PreAuthorize("@ss.hasPermission('infra:demo03-student:create')") |
| 44 | - public CommonResult<Long> createDemo03Student(@Valid @RequestBody Demo03StudentSaveReqVO createReqVO) { | |
| 45 | - return success(demo03StudentService.createDemo03Student(createReqVO)); | |
| 44 | + public CommonResult<Long> createDemo03Student(@Valid @RequestBody Demo03StudentErpSaveReqVO createReqVO) { | |
| 45 | + return success(demo03StudentErpService.createDemo03Student(createReqVO)); | |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | @PutMapping("/update") |
| 49 | 49 | @Operation(summary = "更新学生") |
| 50 | 50 | @PreAuthorize("@ss.hasPermission('infra:demo03-student:update')") |
| 51 | - public CommonResult<Boolean> updateDemo03Student(@Valid @RequestBody Demo03StudentSaveReqVO updateReqVO) { | |
| 52 | - demo03StudentService.updateDemo03Student(updateReqVO); | |
| 51 | + public CommonResult<Boolean> updateDemo03Student(@Valid @RequestBody Demo03StudentErpSaveReqVO updateReqVO) { | |
| 52 | + demo03StudentErpService.updateDemo03Student(updateReqVO); | |
| 53 | 53 | return success(true); |
| 54 | 54 | } |
| 55 | 55 | |
| ... | ... | @@ -58,7 +58,7 @@ public class Demo03StudentController { |
| 58 | 58 | @Parameter(name = "id", description = "编号", required = true) |
| 59 | 59 | @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')") |
| 60 | 60 | public CommonResult<Boolean> deleteDemo03Student(@RequestParam("id") Long id) { |
| 61 | - demo03StudentService.deleteDemo03Student(id); | |
| 61 | + demo03StudentErpService.deleteDemo03Student(id); | |
| 62 | 62 | return success(true); |
| 63 | 63 | } |
| 64 | 64 | |
| ... | ... | @@ -67,7 +67,7 @@ public class Demo03StudentController { |
| 67 | 67 | @Operation(summary = "批量删除学生") |
| 68 | 68 | @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')") |
| 69 | 69 | public CommonResult<Boolean> deleteDemo03Student(@RequestParam("ids") List<Long> ids) { |
| 70 | - demo03StudentService.deleteDemo03StudentByIds(ids); | |
| 70 | + demo03StudentErpService.deleteDemo03StudentByIds(ids); | |
| 71 | 71 | return success(true); |
| 72 | 72 | } |
| 73 | 73 | |
| ... | ... | @@ -75,30 +75,30 @@ public class Demo03StudentController { |
| 75 | 75 | @Operation(summary = "获得学生") |
| 76 | 76 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| 77 | 77 | @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") |
| 78 | - public CommonResult<Demo03StudentRespVO> getDemo03Student(@RequestParam("id") Long id) { | |
| 79 | - Demo03StudentDO demo03Student = demo03StudentService.getDemo03Student(id); | |
| 80 | - return success(BeanUtils.toBean(demo03Student, Demo03StudentRespVO.class)); | |
| 78 | + public CommonResult<Demo03StudentErpRespVO> getDemo03Student(@RequestParam("id") Long id) { | |
| 79 | + Demo03StudentDO demo03Student = demo03StudentErpService.getDemo03Student(id); | |
| 80 | + return success(BeanUtils.toBean(demo03Student, Demo03StudentErpRespVO.class)); | |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | @GetMapping("/page") |
| 84 | 84 | @Operation(summary = "获得学生分页") |
| 85 | 85 | @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") |
| 86 | - public CommonResult<PageResult<Demo03StudentRespVO>> getDemo03StudentPage(@Valid Demo03StudentPageReqVO pageReqVO) { | |
| 87 | - PageResult<Demo03StudentDO> pageResult = demo03StudentService.getDemo03StudentPage(pageReqVO); | |
| 88 | - return success(BeanUtils.toBean(pageResult, Demo03StudentRespVO.class)); | |
| 86 | + public CommonResult<PageResult<Demo03StudentErpRespVO>> getDemo03StudentPage(@Valid Demo03StudentErpPageReqVO pageReqVO) { | |
| 87 | + PageResult<Demo03StudentDO> pageResult = demo03StudentErpService.getDemo03StudentPage(pageReqVO); | |
| 88 | + return success(BeanUtils.toBean(pageResult, Demo03StudentErpRespVO.class)); | |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | @GetMapping("/export-excel") |
| 92 | 92 | @Operation(summary = "导出学生 Excel") |
| 93 | 93 | @PreAuthorize("@ss.hasPermission('infra:demo03-student:export')") |
| 94 | 94 | @ApiAccessLog(operateType = EXPORT) |
| 95 | - public void exportDemo03StudentExcel(@Valid Demo03StudentPageReqVO pageReqVO, | |
| 95 | + public void exportDemo03StudentExcel(@Valid Demo03StudentErpPageReqVO pageReqVO, | |
| 96 | 96 | HttpServletResponse response) throws IOException { |
| 97 | 97 | pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
| 98 | - List<Demo03StudentDO> list = demo03StudentService.getDemo03StudentPage(pageReqVO).getList(); | |
| 98 | + List<Demo03StudentDO> list = demo03StudentErpService.getDemo03StudentPage(pageReqVO).getList(); | |
| 99 | 99 | // 导出 Excel |
| 100 | - ExcelUtils.write(response, "学生.xls", "数据", Demo03StudentRespVO.class, | |
| 101 | - BeanUtils.toBean(list, Demo03StudentRespVO.class)); | |
| 100 | + ExcelUtils.write(response, "学生.xls", "数据", Demo03StudentErpRespVO.class, | |
| 101 | + BeanUtils.toBean(list, Demo03StudentErpRespVO.class)); | |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | // ==================== 子表(学生课程) ==================== |
| ... | ... | @@ -109,21 +109,21 @@ public class Demo03StudentController { |
| 109 | 109 | @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") |
| 110 | 110 | public CommonResult<PageResult<Demo03CourseDO>> getDemo03CoursePage(PageParam pageReqVO, |
| 111 | 111 | @RequestParam("studentId") Long studentId) { |
| 112 | - return success(demo03StudentService.getDemo03CoursePage(pageReqVO, studentId)); | |
| 112 | + return success(demo03StudentErpService.getDemo03CoursePage(pageReqVO, studentId)); | |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | @PostMapping("/demo03-course/create") |
| 116 | 116 | @Operation(summary = "创建学生课程") |
| 117 | 117 | @PreAuthorize("@ss.hasPermission('infra:demo03-student:create')") |
| 118 | 118 | public CommonResult<Long> createDemo03Course(@Valid @RequestBody Demo03CourseDO demo03Course) { |
| 119 | - return success(demo03StudentService.createDemo03Course(demo03Course)); | |
| 119 | + return success(demo03StudentErpService.createDemo03Course(demo03Course)); | |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | @PutMapping("/demo03-course/update") |
| 123 | 123 | @Operation(summary = "更新学生课程") |
| 124 | 124 | @PreAuthorize("@ss.hasPermission('infra:demo03-student:update')") |
| 125 | 125 | public CommonResult<Boolean> updateDemo03Course(@Valid @RequestBody Demo03CourseDO demo03Course) { |
| 126 | - demo03StudentService.updateDemo03Course(demo03Course); | |
| 126 | + demo03StudentErpService.updateDemo03Course(demo03Course); | |
| 127 | 127 | return success(true); |
| 128 | 128 | } |
| 129 | 129 | |
| ... | ... | @@ -132,7 +132,7 @@ public class Demo03StudentController { |
| 132 | 132 | @Operation(summary = "删除学生课程") |
| 133 | 133 | @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')") |
| 134 | 134 | public CommonResult<Boolean> deleteDemo03Course(@RequestParam("id") Long id) { |
| 135 | - demo03StudentService.deleteDemo03Course(id); | |
| 135 | + demo03StudentErpService.deleteDemo03Course(id); | |
| 136 | 136 | return success(true); |
| 137 | 137 | } |
| 138 | 138 | |
| ... | ... | @@ -141,7 +141,7 @@ public class Demo03StudentController { |
| 141 | 141 | @Operation(summary = "批量删除学生课程") |
| 142 | 142 | @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')") |
| 143 | 143 | public CommonResult<Boolean> deleteDemo03Course(@RequestParam("ids") List<Long> ids) { |
| 144 | - demo03StudentService.deleteDemo03CourseByIds(ids); | |
| 144 | + demo03StudentErpService.deleteDemo03CourseByIds(ids); | |
| 145 | 145 | return success(true); |
| 146 | 146 | } |
| 147 | 147 | |
| ... | ... | @@ -150,7 +150,7 @@ public class Demo03StudentController { |
| 150 | 150 | @Parameter(name = "id", description = "编号", required = true) |
| 151 | 151 | @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") |
| 152 | 152 | public CommonResult<Demo03CourseDO> getDemo03Course(@RequestParam("id") Long id) { |
| 153 | - return success(demo03StudentService.getDemo03Course(id)); | |
| 153 | + return success(demo03StudentErpService.getDemo03Course(id)); | |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | // ==================== 子表(学生班级) ==================== |
| ... | ... | @@ -161,21 +161,21 @@ public class Demo03StudentController { |
| 161 | 161 | @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") |
| 162 | 162 | public CommonResult<PageResult<Demo03GradeDO>> getDemo03GradePage(PageParam pageReqVO, |
| 163 | 163 | @RequestParam("studentId") Long studentId) { |
| 164 | - return success(demo03StudentService.getDemo03GradePage(pageReqVO, studentId)); | |
| 164 | + return success(demo03StudentErpService.getDemo03GradePage(pageReqVO, studentId)); | |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | @PostMapping("/demo03-grade/create") |
| 168 | 168 | @Operation(summary = "创建学生班级") |
| 169 | 169 | @PreAuthorize("@ss.hasPermission('infra:demo03-student:create')") |
| 170 | 170 | public CommonResult<Long> createDemo03Grade(@Valid @RequestBody Demo03GradeDO demo03Grade) { |
| 171 | - return success(demo03StudentService.createDemo03Grade(demo03Grade)); | |
| 171 | + return success(demo03StudentErpService.createDemo03Grade(demo03Grade)); | |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | @PutMapping("/demo03-grade/update") |
| 175 | 175 | @Operation(summary = "更新学生班级") |
| 176 | 176 | @PreAuthorize("@ss.hasPermission('infra:demo03-student:update')") |
| 177 | 177 | public CommonResult<Boolean> updateDemo03Grade(@Valid @RequestBody Demo03GradeDO demo03Grade) { |
| 178 | - demo03StudentService.updateDemo03Grade(demo03Grade); | |
| 178 | + demo03StudentErpService.updateDemo03Grade(demo03Grade); | |
| 179 | 179 | return success(true); |
| 180 | 180 | } |
| 181 | 181 | |
| ... | ... | @@ -184,7 +184,7 @@ public class Demo03StudentController { |
| 184 | 184 | @Operation(summary = "删除学生班级") |
| 185 | 185 | @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')") |
| 186 | 186 | public CommonResult<Boolean> deleteDemo03Grade(@RequestParam("id") Long id) { |
| 187 | - demo03StudentService.deleteDemo03Grade(id); | |
| 187 | + demo03StudentErpService.deleteDemo03Grade(id); | |
| 188 | 188 | return success(true); |
| 189 | 189 | } |
| 190 | 190 | |
| ... | ... | @@ -193,7 +193,7 @@ public class Demo03StudentController { |
| 193 | 193 | @Operation(summary = "批量删除学生班级") |
| 194 | 194 | @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')") |
| 195 | 195 | public CommonResult<Boolean> deleteDemo03Grade(@RequestParam("ids") List<Long> ids) { |
| 196 | - demo03StudentService.deleteDemo03GradeByIds(ids); | |
| 196 | + demo03StudentErpService.deleteDemo03GradeByIds(ids); | |
| 197 | 197 | return success(true); |
| 198 | 198 | } |
| 199 | 199 | |
| ... | ... | @@ -202,7 +202,7 @@ public class Demo03StudentController { |
| 202 | 202 | @Parameter(name = "id", description = "编号", required = true) |
| 203 | 203 | @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") |
| 204 | 204 | public CommonResult<Demo03GradeDO> getDemo03Grade(@RequestParam("id") Long id) { |
| 205 | - return success(demo03StudentService.getDemo03Grade(id)); | |
| 205 | + return success(demo03StudentErpService.getDemo03Grade(id)); | |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | } |
| 209 | 209 | \ No newline at end of file | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentPageReqVO.java renamed to yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentErpPageReqVO.java
| ... | ... | @@ -12,7 +12,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ |
| 12 | 12 | @Data |
| 13 | 13 | @EqualsAndHashCode(callSuper = true) |
| 14 | 14 | @ToString(callSuper = true) |
| 15 | -public class Demo03StudentPageReqVO extends PageParam { | |
| 15 | +public class Demo03StudentErpPageReqVO extends PageParam { | |
| 16 | 16 | |
| 17 | 17 | @Schema(description = "名字", example = "芋艿") |
| 18 | 18 | private String name; | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentRespVO.java renamed to yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentErpRespVO.java
| ... | ... | @@ -11,7 +11,7 @@ import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; |
| 11 | 11 | @Schema(description = "管理后台 - 学生 Response VO") |
| 12 | 12 | @Data |
| 13 | 13 | @ExcelIgnoreUnannotated |
| 14 | -public class Demo03StudentRespVO { | |
| 14 | +public class Demo03StudentErpRespVO { | |
| 15 | 15 | |
| 16 | 16 | @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525") |
| 17 | 17 | @ExcelProperty("编号") | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentSaveReqVO.java renamed to yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentErpSaveReqVO.java
| ... | ... | @@ -8,7 +8,7 @@ import java.time.LocalDateTime; |
| 8 | 8 | |
| 9 | 9 | @Schema(description = "管理后台 - 学生新增/修改 Request VO") |
| 10 | 10 | @Data |
| 11 | -public class Demo03StudentSaveReqVO { | |
| 11 | +public class Demo03StudentErpSaveReqVO { | |
| 12 | 12 | |
| 13 | 13 | @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525") |
| 14 | 14 | private Long id; | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/Demo03StudentNormalController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal; | |
| 2 | + | |
| 3 | +import org.springframework.web.bind.annotation.*; | |
| 4 | +import jakarta.annotation.Resource; | |
| 5 | +import org.springframework.validation.annotation.Validated; | |
| 6 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 7 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 8 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 9 | +import io.swagger.v3.oas.annotations.Operation; | |
| 10 | + | |
| 11 | +import jakarta.validation.*; | |
| 12 | +import jakarta.servlet.http.*; | |
| 13 | +import java.util.*; | |
| 14 | +import java.io.IOException; | |
| 15 | + | |
| 16 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 17 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 18 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 19 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 20 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 21 | + | |
| 22 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 23 | + | |
| 24 | +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; | |
| 25 | +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; | |
| 26 | + | |
| 27 | +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo.*; | |
| 28 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO; | |
| 29 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO; | |
| 30 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO; | |
| 31 | +import cn.iocoder.yudao.module.infra.service.demo.demo03.normal.Demo03StudentNormalService; | |
| 32 | + | |
| 33 | +@Tag(name = "管理后台 - 学生") | |
| 34 | +@RestController | |
| 35 | +@RequestMapping("/infra/demo03-student-normal") | |
| 36 | +@Validated | |
| 37 | +public class Demo03StudentNormalController { | |
| 38 | + | |
| 39 | + @Resource | |
| 40 | + private Demo03StudentNormalService demo03StudentNormalService; | |
| 41 | + | |
| 42 | + @PostMapping("/create") | |
| 43 | + @Operation(summary = "创建学生") | |
| 44 | + @PreAuthorize("@ss.hasPermission('infra:demo03-student:create')") | |
| 45 | + public CommonResult<Long> createDemo03Student(@Valid @RequestBody Demo03StudentNormalSaveReqVO createReqVO) { | |
| 46 | + return success(demo03StudentNormalService.createDemo03Student(createReqVO)); | |
| 47 | + } | |
| 48 | + | |
| 49 | + @PutMapping("/update") | |
| 50 | + @Operation(summary = "更新学生") | |
| 51 | + @PreAuthorize("@ss.hasPermission('infra:demo03-student:update')") | |
| 52 | + public CommonResult<Boolean> updateDemo03Student(@Valid @RequestBody Demo03StudentNormalSaveReqVO updateReqVO) { | |
| 53 | + demo03StudentNormalService.updateDemo03Student(updateReqVO); | |
| 54 | + return success(true); | |
| 55 | + } | |
| 56 | + | |
| 57 | + @DeleteMapping("/delete") | |
| 58 | + @Operation(summary = "删除学生") | |
| 59 | + @Parameter(name = "id", description = "编号", required = true) | |
| 60 | + @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')") | |
| 61 | + public CommonResult<Boolean> deleteDemo03Student(@RequestParam("id") Long id) { | |
| 62 | + demo03StudentNormalService.deleteDemo03Student(id); | |
| 63 | + return success(true); | |
| 64 | + } | |
| 65 | + | |
| 66 | + @DeleteMapping("/delete-batch") | |
| 67 | + @Parameter(name = "ids", description = "编号", required = true) | |
| 68 | + @Operation(summary = "批量删除学生") | |
| 69 | + @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')") | |
| 70 | + public CommonResult<Boolean> deleteDemo03Student(@RequestParam("ids") List<Long> ids) { | |
| 71 | + demo03StudentNormalService.deleteDemo03StudentByIds(ids); | |
| 72 | + return success(true); | |
| 73 | + } | |
| 74 | + | |
| 75 | + @GetMapping("/get") | |
| 76 | + @Operation(summary = "获得学生") | |
| 77 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 78 | + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") | |
| 79 | + public CommonResult<Demo03StudentNormalRespVO> getDemo03Student(@RequestParam("id") Long id) { | |
| 80 | + Demo03StudentDO demo03Student = demo03StudentNormalService.getDemo03Student(id); | |
| 81 | + return success(BeanUtils.toBean(demo03Student, Demo03StudentNormalRespVO.class)); | |
| 82 | + } | |
| 83 | + | |
| 84 | + @GetMapping("/page") | |
| 85 | + @Operation(summary = "获得学生分页") | |
| 86 | + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") | |
| 87 | + public CommonResult<PageResult<Demo03StudentNormalRespVO>> getDemo03StudentPage(@Valid Demo03StudentNormalPageReqVO pageReqVO) { | |
| 88 | + PageResult<Demo03StudentDO> pageResult = demo03StudentNormalService.getDemo03StudentPage(pageReqVO); | |
| 89 | + return success(BeanUtils.toBean(pageResult, Demo03StudentNormalRespVO.class)); | |
| 90 | + } | |
| 91 | + | |
| 92 | + @GetMapping("/export-excel") | |
| 93 | + @Operation(summary = "导出学生 Excel") | |
| 94 | + @PreAuthorize("@ss.hasPermission('infra:demo03-student:export')") | |
| 95 | + @ApiAccessLog(operateType = EXPORT) | |
| 96 | + public void exportDemo03StudentExcel(@Valid Demo03StudentNormalPageReqVO pageReqVO, | |
| 97 | + HttpServletResponse response) throws IOException { | |
| 98 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | |
| 99 | + List<Demo03StudentDO> list = demo03StudentNormalService.getDemo03StudentPage(pageReqVO).getList(); | |
| 100 | + // 导出 Excel | |
| 101 | + ExcelUtils.write(response, "学生.xls", "数据", Demo03StudentNormalRespVO.class, | |
| 102 | + BeanUtils.toBean(list, Demo03StudentNormalRespVO.class)); | |
| 103 | + } | |
| 104 | + | |
| 105 | + // ==================== 子表(学生课程) ==================== | |
| 106 | + | |
| 107 | + @GetMapping("/demo03-course/list-by-student-id") | |
| 108 | + @Operation(summary = "获得学生课程列表") | |
| 109 | + @Parameter(name = "studentId", description = "学生编号") | |
| 110 | + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") | |
| 111 | + public CommonResult<List<Demo03CourseDO>> getDemo03CourseListByStudentId(@RequestParam("studentId") Long studentId) { | |
| 112 | + return success(demo03StudentNormalService.getDemo03CourseListByStudentId(studentId)); | |
| 113 | + } | |
| 114 | + | |
| 115 | + // ==================== 子表(学生班级) ==================== | |
| 116 | + | |
| 117 | + @GetMapping("/demo03-grade/get-by-student-id") | |
| 118 | + @Operation(summary = "获得学生班级") | |
| 119 | + @Parameter(name = "studentId", description = "学生编号") | |
| 120 | + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") | |
| 121 | + public CommonResult<Demo03GradeDO> getDemo03GradeByStudentId(@RequestParam("studentId") Long studentId) { | |
| 122 | + return success(demo03StudentNormalService.getDemo03GradeByStudentId(studentId)); | |
| 123 | + } | |
| 124 | + | |
| 125 | +} | |
| 0 | 126 | \ No newline at end of file | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/vo/Demo03StudentNormalPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 6 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 7 | +import java.time.LocalDateTime; | |
| 8 | + | |
| 9 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 10 | + | |
| 11 | +@Schema(description = "管理后台 - 学生分页 Request VO") | |
| 12 | +@Data | |
| 13 | +@EqualsAndHashCode(callSuper = true) | |
| 14 | +@ToString(callSuper = true) | |
| 15 | +public class Demo03StudentNormalPageReqVO extends PageParam { | |
| 16 | + | |
| 17 | + @Schema(description = "名字", example = "芋艿") | |
| 18 | + private String name; | |
| 19 | + | |
| 20 | + @Schema(description = "性别") | |
| 21 | + private Integer sex; | |
| 22 | + | |
| 23 | + @Schema(description = "简介", example = "随便") | |
| 24 | + private String description; | |
| 25 | + | |
| 26 | + @Schema(description = "创建时间") | |
| 27 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 28 | + private LocalDateTime[] createTime; | |
| 29 | + | |
| 30 | +} | |
| 0 | 31 | \ No newline at end of file | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/vo/Demo03StudentNormalRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.*; | |
| 5 | + | |
| 6 | +import java.time.LocalDateTime; | |
| 7 | +import com.alibaba.excel.annotation.*; | |
| 8 | +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | |
| 9 | +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | |
| 10 | + | |
| 11 | +@Schema(description = "管理后台 - 学生 Response VO") | |
| 12 | +@Data | |
| 13 | +@ExcelIgnoreUnannotated | |
| 14 | +public class Demo03StudentNormalRespVO { | |
| 15 | + | |
| 16 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525") | |
| 17 | + @ExcelProperty("编号") | |
| 18 | + private Long id; | |
| 19 | + | |
| 20 | + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | |
| 21 | + @ExcelProperty("名字") | |
| 22 | + private String name; | |
| 23 | + | |
| 24 | + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 25 | + @ExcelProperty(value = "性别", converter = DictConvert.class) | |
| 26 | + @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 | |
| 27 | + private Integer sex; | |
| 28 | + | |
| 29 | + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 30 | + @ExcelProperty("出生日期") | |
| 31 | + private LocalDateTime birthday; | |
| 32 | + | |
| 33 | + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便") | |
| 34 | + @ExcelProperty("简介") | |
| 35 | + private String description; | |
| 36 | + | |
| 37 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 38 | + @ExcelProperty("创建时间") | |
| 39 | + private LocalDateTime createTime; | |
| 40 | + | |
| 41 | +} | |
| 0 | 42 | \ No newline at end of file | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/vo/Demo03StudentNormalSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.*; | |
| 5 | +import java.util.*; | |
| 6 | +import jakarta.validation.constraints.*; | |
| 7 | + | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO; | |
| 10 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO; | |
| 11 | + | |
| 12 | +@Schema(description = "管理后台 - 学生新增/修改 Request VO") | |
| 13 | +@Data | |
| 14 | +public class Demo03StudentNormalSaveReqVO { | |
| 15 | + | |
| 16 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525") | |
| 17 | + private Long id; | |
| 18 | + | |
| 19 | + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | |
| 20 | + @NotEmpty(message = "名字不能为空") | |
| 21 | + private String name; | |
| 22 | + | |
| 23 | + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 24 | + @NotNull(message = "性别不能为空") | |
| 25 | + private Integer sex; | |
| 26 | + | |
| 27 | + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 28 | + @NotNull(message = "出生日期不能为空") | |
| 29 | + private LocalDateTime birthday; | |
| 30 | + | |
| 31 | + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便") | |
| 32 | + @NotEmpty(message = "简介不能为空") | |
| 33 | + private String description; | |
| 34 | + | |
| 35 | + @Schema(description = "学生课程列表") | |
| 36 | + private List<Demo03CourseDO> demo03Courses; | |
| 37 | + | |
| 38 | + @Schema(description = "学生班级") | |
| 39 | + private Demo03GradeDO demo03Grade; | |
| 40 | + | |
| 41 | +} | |
| 0 | 42 | \ No newline at end of file | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03CourseMapper.java renamed to yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03CourseErpMapper.java
| ... | ... | @@ -15,7 +15,7 @@ import java.util.List; |
| 15 | 15 | * @author 芋道源码 |
| 16 | 16 | */ |
| 17 | 17 | @Mapper |
| 18 | -public interface Demo03CourseMapper extends BaseMapperX<Demo03CourseDO> { | |
| 18 | +public interface Demo03CourseErpMapper extends BaseMapperX<Demo03CourseDO> { | |
| 19 | 19 | |
| 20 | 20 | default PageResult<Demo03CourseDO> selectPage(PageParam reqVO, Long studentId) { |
| 21 | 21 | return selectPage(reqVO, new LambdaQueryWrapperX<Demo03CourseDO>() | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03GradeMapper.java renamed to yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03GradeErpMapper.java
| ... | ... | @@ -15,7 +15,7 @@ import java.util.List; |
| 15 | 15 | * @author 芋道源码 |
| 16 | 16 | */ |
| 17 | 17 | @Mapper |
| 18 | -public interface Demo03GradeMapper extends BaseMapperX<Demo03GradeDO> { | |
| 18 | +public interface Demo03GradeErpMapper extends BaseMapperX<Demo03GradeDO> { | |
| 19 | 19 | |
| 20 | 20 | default PageResult<Demo03GradeDO> selectPage(PageParam reqVO, Long studentId) { |
| 21 | 21 | return selectPage(reqVO, new LambdaQueryWrapperX<Demo03GradeDO>() | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03StudentMapper.java renamed to yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03StudentErpMapper.java
| ... | ... | @@ -13,9 +13,9 @@ import org.apache.ibatis.annotations.Mapper; |
| 13 | 13 | * @author 芋道源码 |
| 14 | 14 | */ |
| 15 | 15 | @Mapper |
| 16 | -public interface Demo03StudentMapper extends BaseMapperX<Demo03StudentDO> { | |
| 16 | +public interface Demo03StudentErpMapper extends BaseMapperX<Demo03StudentDO> { | |
| 17 | 17 | |
| 18 | - default PageResult<Demo03StudentDO> selectPage(Demo03StudentPageReqVO reqVO) { | |
| 18 | + default PageResult<Demo03StudentDO> selectPage(Demo03StudentErpPageReqVO reqVO) { | |
| 19 | 19 | return selectPage(reqVO, new LambdaQueryWrapperX<Demo03StudentDO>() |
| 20 | 20 | .likeIfPresent(Demo03StudentDO::getName, reqVO.getName()) |
| 21 | 21 | .eqIfPresent(Demo03StudentDO::getSex, reqVO.getSex()) | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/normal/Demo03CourseNormalMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.normal; | |
| 2 | + | |
| 3 | +import java.util.*; | |
| 4 | + | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 6 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO; | |
| 7 | +import org.apache.ibatis.annotations.Mapper; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 学生课程 Mapper | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +@Mapper | |
| 15 | +public interface Demo03CourseNormalMapper extends BaseMapperX<Demo03CourseDO> { | |
| 16 | + | |
| 17 | + default List<Demo03CourseDO> selectListByStudentId(Long studentId) { | |
| 18 | + return selectList(Demo03CourseDO::getStudentId, studentId); | |
| 19 | + } | |
| 20 | + | |
| 21 | + default int deleteByStudentId(Long studentId) { | |
| 22 | + return delete(Demo03CourseDO::getStudentId, studentId); | |
| 23 | + } | |
| 24 | + | |
| 25 | + default int deleteByStudentIds(List<Long> studentIds) { | |
| 26 | + return delete(Demo03CourseDO::getStudentId, studentIds); | |
| 27 | + } | |
| 28 | + | |
| 29 | +} | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/normal/Demo03GradeNormalMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.normal; | |
| 2 | + | |
| 3 | +import java.util.*; | |
| 4 | + | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 6 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO; | |
| 7 | +import org.apache.ibatis.annotations.Mapper; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 学生班级 Mapper | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +@Mapper | |
| 15 | +public interface Demo03GradeNormalMapper extends BaseMapperX<Demo03GradeDO> { | |
| 16 | + | |
| 17 | + default Demo03GradeDO selectByStudentId(Long studentId) { | |
| 18 | + return selectOne(Demo03GradeDO::getStudentId, studentId); | |
| 19 | + } | |
| 20 | + | |
| 21 | + default int deleteByStudentId(Long studentId) { | |
| 22 | + return delete(Demo03GradeDO::getStudentId, studentId); | |
| 23 | + } | |
| 24 | + | |
| 25 | + default int deleteByStudentIds(List<Long> studentIds) { | |
| 26 | + return delete(Demo03GradeDO::getStudentId, studentIds); | |
| 27 | + } | |
| 28 | + | |
| 29 | +} | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/normal/Demo03StudentNormalMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.normal; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 6 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO; | |
| 7 | +import org.apache.ibatis.annotations.Mapper; | |
| 8 | +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo.*; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 学生 Mapper | |
| 12 | + * | |
| 13 | + * @author 芋道源码 | |
| 14 | + */ | |
| 15 | +@Mapper | |
| 16 | +public interface Demo03StudentNormalMapper extends BaseMapperX<Demo03StudentDO> { | |
| 17 | + | |
| 18 | + default PageResult<Demo03StudentDO> selectPage(Demo03StudentNormalPageReqVO reqVO) { | |
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<Demo03StudentDO>() | |
| 20 | + .likeIfPresent(Demo03StudentDO::getName, reqVO.getName()) | |
| 21 | + .eqIfPresent(Demo03StudentDO::getSex, reqVO.getSex()) | |
| 22 | + .eqIfPresent(Demo03StudentDO::getDescription, reqVO.getDescription()) | |
| 23 | + .betweenIfPresent(Demo03StudentDO::getCreateTime, reqVO.getCreateTime()) | |
| 24 | + .orderByDesc(Demo03StudentDO::getId)); | |
| 25 | + } | |
| 26 | + | |
| 27 | +} | |
| 0 | 28 | \ No newline at end of file | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentService.java renamed to yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentErpService.java
| ... | ... | @@ -14,7 +14,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 14 | 14 | * |
| 15 | 15 | * @author 芋道源码 |
| 16 | 16 | */ |
| 17 | -public interface Demo03StudentService { | |
| 17 | +public interface Demo03StudentErpService { | |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * 创建学生 |
| ... | ... | @@ -22,14 +22,14 @@ public interface Demo03StudentService { |
| 22 | 22 | * @param createReqVO 创建信息 |
| 23 | 23 | * @return 编号 |
| 24 | 24 | */ |
| 25 | - Long createDemo03Student(@Valid Demo03StudentSaveReqVO createReqVO); | |
| 25 | + Long createDemo03Student(@Valid Demo03StudentErpSaveReqVO createReqVO); | |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * 更新学生 |
| 29 | 29 | * |
| 30 | 30 | * @param updateReqVO 更新信息 |
| 31 | 31 | */ |
| 32 | - void updateDemo03Student(@Valid Demo03StudentSaveReqVO updateReqVO); | |
| 32 | + void updateDemo03Student(@Valid Demo03StudentErpSaveReqVO updateReqVO); | |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * 删除学生 |
| ... | ... | @@ -59,7 +59,7 @@ public interface Demo03StudentService { |
| 59 | 59 | * @param pageReqVO 分页查询 |
| 60 | 60 | * @return 学生分页 |
| 61 | 61 | */ |
| 62 | - PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentPageReqVO pageReqVO); | |
| 62 | + PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentErpPageReqVO pageReqVO); | |
| 63 | 63 | |
| 64 | 64 | // ==================== 子表(学生课程) ==================== |
| 65 | 65 | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentServiceImpl.java renamed to yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentErpServiceImpl.java
| ... | ... | @@ -4,14 +4,14 @@ import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 7 | -import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentPageReqVO; | |
| 8 | -import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentSaveReqVO; | |
| 7 | +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpPageReqVO; | |
| 8 | +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpSaveReqVO; | |
| 9 | 9 | import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO; |
| 10 | 10 | import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO; |
| 11 | 11 | import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO; |
| 12 | -import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp.Demo03CourseMapper; | |
| 13 | -import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp.Demo03GradeMapper; | |
| 14 | -import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp.Demo03StudentMapper; | |
| 12 | +import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp.Demo03CourseErpMapper; | |
| 13 | +import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp.Demo03GradeErpMapper; | |
| 14 | +import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp.Demo03StudentErpMapper; | |
| 15 | 15 | import jakarta.annotation.Resource; |
| 16 | 16 | import org.springframework.stereotype.Service; |
| 17 | 17 | import org.springframework.transaction.annotation.Transactional; |
| ... | ... | @@ -29,31 +29,31 @@ import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; |
| 29 | 29 | */ |
| 30 | 30 | @Service |
| 31 | 31 | @Validated |
| 32 | -public class Demo03StudentServiceImpl implements Demo03StudentService { | |
| 32 | +public class Demo03StudentErpServiceImpl implements Demo03StudentErpService { | |
| 33 | 33 | |
| 34 | 34 | @Resource |
| 35 | - private Demo03StudentMapper demo03StudentMapper; | |
| 35 | + private Demo03StudentErpMapper demo03StudentErpMapper; | |
| 36 | 36 | @Resource |
| 37 | - private Demo03CourseMapper demo03CourseMapper; | |
| 37 | + private Demo03CourseErpMapper demo03CourseErpMapper; | |
| 38 | 38 | @Resource |
| 39 | - private Demo03GradeMapper demo03GradeMapper; | |
| 39 | + private Demo03GradeErpMapper demo03GradeErpMapper; | |
| 40 | 40 | |
| 41 | 41 | @Override |
| 42 | - public Long createDemo03Student(Demo03StudentSaveReqVO createReqVO) { | |
| 42 | + public Long createDemo03Student(Demo03StudentErpSaveReqVO createReqVO) { | |
| 43 | 43 | // 插入 |
| 44 | 44 | Demo03StudentDO demo03Student = BeanUtils.toBean(createReqVO, Demo03StudentDO.class); |
| 45 | - demo03StudentMapper.insert(demo03Student); | |
| 45 | + demo03StudentErpMapper.insert(demo03Student); | |
| 46 | 46 | // 返回 |
| 47 | 47 | return demo03Student.getId(); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | @Override |
| 51 | - public void updateDemo03Student(Demo03StudentSaveReqVO updateReqVO) { | |
| 51 | + public void updateDemo03Student(Demo03StudentErpSaveReqVO updateReqVO) { | |
| 52 | 52 | // 校验存在 |
| 53 | 53 | validateDemo03StudentExists(updateReqVO.getId()); |
| 54 | 54 | // 更新 |
| 55 | 55 | Demo03StudentDO updateObj = BeanUtils.toBean(updateReqVO, Demo03StudentDO.class); |
| 56 | - demo03StudentMapper.updateById(updateObj); | |
| 56 | + demo03StudentErpMapper.updateById(updateObj); | |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | @Override |
| ... | ... | @@ -62,7 +62,7 @@ public class Demo03StudentServiceImpl implements Demo03StudentService { |
| 62 | 62 | // 校验存在 |
| 63 | 63 | validateDemo03StudentExists(id); |
| 64 | 64 | // 删除 |
| 65 | - demo03StudentMapper.deleteById(id); | |
| 65 | + demo03StudentErpMapper.deleteById(id); | |
| 66 | 66 | |
| 67 | 67 | // 删除子表 |
| 68 | 68 | deleteDemo03CourseByStudentId(id); |
| ... | ... | @@ -75,7 +75,7 @@ public class Demo03StudentServiceImpl implements Demo03StudentService { |
| 75 | 75 | // 校验存在 |
| 76 | 76 | validateDemo03StudentExists(ids); |
| 77 | 77 | // 删除 |
| 78 | - demo03StudentMapper.deleteByIds(ids); | |
| 78 | + demo03StudentErpMapper.deleteByIds(ids); | |
| 79 | 79 | |
| 80 | 80 | // 删除子表 |
| 81 | 81 | deleteDemo03CourseByStudentIds(ids); |
| ... | ... | @@ -83,38 +83,38 @@ public class Demo03StudentServiceImpl implements Demo03StudentService { |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | private void validateDemo03StudentExists(List<Long> ids) { |
| 86 | - List<Demo03StudentDO> list = demo03StudentMapper.selectByIds(ids); | |
| 86 | + List<Demo03StudentDO> list = demo03StudentErpMapper.selectByIds(ids); | |
| 87 | 87 | if (CollUtil.isEmpty(list) || list.size() != ids.size()) { |
| 88 | 88 | throw exception(DEMO03_STUDENT_NOT_EXISTS); |
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | private void validateDemo03StudentExists(Long id) { |
| 93 | - if (demo03StudentMapper.selectById(id) == null) { | |
| 93 | + if (demo03StudentErpMapper.selectById(id) == null) { | |
| 94 | 94 | throw exception(DEMO03_STUDENT_NOT_EXISTS); |
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | @Override |
| 99 | 99 | public Demo03StudentDO getDemo03Student(Long id) { |
| 100 | - return demo03StudentMapper.selectById(id); | |
| 100 | + return demo03StudentErpMapper.selectById(id); | |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | @Override |
| 104 | - public PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentPageReqVO pageReqVO) { | |
| 105 | - return demo03StudentMapper.selectPage(pageReqVO); | |
| 104 | + public PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentErpPageReqVO pageReqVO) { | |
| 105 | + return demo03StudentErpMapper.selectPage(pageReqVO); | |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // ==================== 子表(学生课程) ==================== |
| 109 | 109 | |
| 110 | 110 | @Override |
| 111 | 111 | public PageResult<Demo03CourseDO> getDemo03CoursePage(PageParam pageReqVO, Long studentId) { |
| 112 | - return demo03CourseMapper.selectPage(pageReqVO, studentId); | |
| 112 | + return demo03CourseErpMapper.selectPage(pageReqVO, studentId); | |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | @Override |
| 116 | 116 | public Long createDemo03Course(Demo03CourseDO demo03Course) { |
| 117 | - demo03CourseMapper.insert(demo03Course); | |
| 117 | + demo03CourseErpMapper.insert(demo03Course); | |
| 118 | 118 | return demo03Course.getId(); |
| 119 | 119 | } |
| 120 | 120 | |
| ... | ... | @@ -124,7 +124,7 @@ public class Demo03StudentServiceImpl implements Demo03StudentService { |
| 124 | 124 | validateDemo03CourseExists(demo03Course.getId()); |
| 125 | 125 | // 更新 |
| 126 | 126 | demo03Course.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 |
| 127 | - demo03CourseMapper.updateById(demo03Course); | |
| 127 | + demo03CourseErpMapper.updateById(demo03Course); | |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | @Override |
| ... | ... | @@ -132,7 +132,7 @@ public class Demo03StudentServiceImpl implements Demo03StudentService { |
| 132 | 132 | // 校验存在 |
| 133 | 133 | validateDemo03CourseExists(id); |
| 134 | 134 | // 删除 |
| 135 | - demo03CourseMapper.deleteById(id); | |
| 135 | + demo03CourseErpMapper.deleteById(id); | |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | @Override |
| ... | ... | @@ -140,50 +140,50 @@ public class Demo03StudentServiceImpl implements Demo03StudentService { |
| 140 | 140 | // 校验存在 |
| 141 | 141 | validateDemo03CourseExists(ids); |
| 142 | 142 | // 删除 |
| 143 | - demo03CourseMapper.deleteByIds(ids); | |
| 143 | + demo03CourseErpMapper.deleteByIds(ids); | |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | @Override |
| 147 | 147 | public Demo03CourseDO getDemo03Course(Long id) { |
| 148 | - return demo03CourseMapper.selectById(id); | |
| 148 | + return demo03CourseErpMapper.selectById(id); | |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | private void validateDemo03CourseExists(Long id) { |
| 152 | - if (demo03CourseMapper.selectById(id) == null) { | |
| 152 | + if (demo03CourseErpMapper.selectById(id) == null) { | |
| 153 | 153 | throw exception(DEMO03_COURSE_NOT_EXISTS); |
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | private void validateDemo03CourseExists(List<Long> ids) { |
| 158 | - List<Demo03CourseDO> list = demo03CourseMapper.selectByIds(ids); | |
| 158 | + List<Demo03CourseDO> list = demo03CourseErpMapper.selectByIds(ids); | |
| 159 | 159 | if (CollUtil.isEmpty(list) || list.size() != ids.size()) { |
| 160 | 160 | throw exception(DEMO03_COURSE_NOT_EXISTS); |
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | private void deleteDemo03CourseByStudentId(Long studentId) { |
| 165 | - demo03CourseMapper.deleteByStudentId(studentId); | |
| 165 | + demo03CourseErpMapper.deleteByStudentId(studentId); | |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | private void deleteDemo03CourseByStudentIds(List<Long> studentIds) { |
| 169 | - demo03CourseMapper.deleteByStudentIds(studentIds); | |
| 169 | + demo03CourseErpMapper.deleteByStudentIds(studentIds); | |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | // ==================== 子表(学生班级) ==================== |
| 173 | 173 | |
| 174 | 174 | @Override |
| 175 | 175 | public PageResult<Demo03GradeDO> getDemo03GradePage(PageParam pageReqVO, Long studentId) { |
| 176 | - return demo03GradeMapper.selectPage(pageReqVO, studentId); | |
| 176 | + return demo03GradeErpMapper.selectPage(pageReqVO, studentId); | |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | @Override |
| 180 | 180 | public Long createDemo03Grade(Demo03GradeDO demo03Grade) { |
| 181 | 181 | // 校验是否已经存在 |
| 182 | - if (demo03GradeMapper.selectByStudentId(demo03Grade.getStudentId()) != null) { | |
| 182 | + if (demo03GradeErpMapper.selectByStudentId(demo03Grade.getStudentId()) != null) { | |
| 183 | 183 | throw exception(DEMO03_GRADE_EXISTS); |
| 184 | 184 | } |
| 185 | 185 | // 插入 |
| 186 | - demo03GradeMapper.insert(demo03Grade); | |
| 186 | + demo03GradeErpMapper.insert(demo03Grade); | |
| 187 | 187 | return demo03Grade.getId(); |
| 188 | 188 | } |
| 189 | 189 | |
| ... | ... | @@ -193,7 +193,7 @@ public class Demo03StudentServiceImpl implements Demo03StudentService { |
| 193 | 193 | validateDemo03GradeExists(demo03Grade.getId()); |
| 194 | 194 | // 更新 |
| 195 | 195 | demo03Grade.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 |
| 196 | - demo03GradeMapper.updateById(demo03Grade); | |
| 196 | + demo03GradeErpMapper.updateById(demo03Grade); | |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | @Override |
| ... | ... | @@ -201,7 +201,7 @@ public class Demo03StudentServiceImpl implements Demo03StudentService { |
| 201 | 201 | // 校验存在 |
| 202 | 202 | validateDemo03GradeExists(id); |
| 203 | 203 | // 删除 |
| 204 | - demo03GradeMapper.deleteById(id); | |
| 204 | + demo03GradeErpMapper.deleteById(id); | |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | @Override |
| ... | ... | @@ -209,33 +209,33 @@ public class Demo03StudentServiceImpl implements Demo03StudentService { |
| 209 | 209 | // 校验存在 |
| 210 | 210 | validateDemo03GradeExists(ids); |
| 211 | 211 | // 删除 |
| 212 | - demo03GradeMapper.deleteByIds(ids); | |
| 212 | + demo03GradeErpMapper.deleteByIds(ids); | |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | @Override |
| 216 | 216 | public Demo03GradeDO getDemo03Grade(Long id) { |
| 217 | - return demo03GradeMapper.selectById(id); | |
| 217 | + return demo03GradeErpMapper.selectById(id); | |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | private void validateDemo03GradeExists(Long id) { |
| 221 | - if (demo03GradeMapper.selectById(id) == null) { | |
| 221 | + if (demo03GradeErpMapper.selectById(id) == null) { | |
| 222 | 222 | throw exception(DEMO03_GRADE_NOT_EXISTS); |
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | private void validateDemo03GradeExists(List<Long> ids) { |
| 227 | - List<Demo03GradeDO> list = demo03GradeMapper.selectByIds(ids); | |
| 227 | + List<Demo03GradeDO> list = demo03GradeErpMapper.selectByIds(ids); | |
| 228 | 228 | if (CollUtil.isEmpty(list) || list.size() != ids.size()) { |
| 229 | 229 | throw exception(DEMO03_GRADE_NOT_EXISTS); |
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | private void deleteDemo03GradeByStudentId(Long studentId) { |
| 234 | - demo03GradeMapper.deleteByStudentId(studentId); | |
| 234 | + demo03GradeErpMapper.deleteByStudentId(studentId); | |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | private void deleteDemo03GradeByStudentIds(List<Long> studentIds) { |
| 238 | - demo03GradeMapper.deleteByStudentIds(studentIds); | |
| 238 | + demo03GradeErpMapper.deleteByStudentIds(studentIds); | |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | } |
| 242 | 242 | \ No newline at end of file | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/normal/Demo03StudentNormalService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.service.demo.demo03.normal; | |
| 2 | + | |
| 3 | +import java.util.*; | |
| 4 | +import jakarta.validation.*; | |
| 5 | +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo.*; | |
| 6 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO; | |
| 7 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO; | |
| 8 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO; | |
| 9 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 学生 Service 接口 | |
| 13 | + * | |
| 14 | + * @author 芋道源码 | |
| 15 | + */ | |
| 16 | +public interface Demo03StudentNormalService { | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 创建学生 | |
| 20 | + * | |
| 21 | + * @param createReqVO 创建信息 | |
| 22 | + * @return 编号 | |
| 23 | + */ | |
| 24 | + Long createDemo03Student(@Valid Demo03StudentNormalSaveReqVO createReqVO); | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 更新学生 | |
| 28 | + * | |
| 29 | + * @param updateReqVO 更新信息 | |
| 30 | + */ | |
| 31 | + void updateDemo03Student(@Valid Demo03StudentNormalSaveReqVO updateReqVO); | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 删除学生 | |
| 35 | + * | |
| 36 | + * @param id 编号 | |
| 37 | + */ | |
| 38 | + void deleteDemo03Student(Long id); | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * 批量删除学生 | |
| 42 | + * | |
| 43 | + * @param ids 编号 | |
| 44 | + */ | |
| 45 | + void deleteDemo03StudentByIds(List<Long> ids); | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * 获得学生 | |
| 49 | + * | |
| 50 | + * @param id 编号 | |
| 51 | + * @return 学生 | |
| 52 | + */ | |
| 53 | + Demo03StudentDO getDemo03Student(Long id); | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * 获得学生分页 | |
| 57 | + * | |
| 58 | + * @param pageReqVO 分页查询 | |
| 59 | + * @return 学生分页 | |
| 60 | + */ | |
| 61 | + PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentNormalPageReqVO pageReqVO); | |
| 62 | + | |
| 63 | + // ==================== 子表(学生课程) ==================== | |
| 64 | + | |
| 65 | + /** | |
| 66 | + * 获得学生课程列表 | |
| 67 | + * | |
| 68 | + * @param studentId 学生编号 | |
| 69 | + * @return 学生课程列表 | |
| 70 | + */ | |
| 71 | + List<Demo03CourseDO> getDemo03CourseListByStudentId(Long studentId); | |
| 72 | + | |
| 73 | + // ==================== 子表(学生班级) ==================== | |
| 74 | + | |
| 75 | + /** | |
| 76 | + * 获得学生班级 | |
| 77 | + * | |
| 78 | + * @param studentId 学生编号 | |
| 79 | + * @return 学生班级 | |
| 80 | + */ | |
| 81 | + Demo03GradeDO getDemo03GradeByStudentId(Long studentId); | |
| 82 | + | |
| 83 | +} | |
| 0 | 84 | \ No newline at end of file | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/normal/Demo03StudentNormalServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.service.demo.demo03.normal; | |
| 2 | + | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 6 | +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo.Demo03StudentNormalPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo.Demo03StudentNormalSaveReqVO; | |
| 8 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO; | |
| 9 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO; | |
| 10 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO; | |
| 11 | +import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.normal.Demo03CourseNormalMapper; | |
| 12 | +import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.normal.Demo03GradeNormalMapper; | |
| 13 | +import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.normal.Demo03StudentNormalMapper; | |
| 14 | +import jakarta.annotation.Resource; | |
| 15 | +import org.springframework.stereotype.Service; | |
| 16 | +import org.springframework.transaction.annotation.Transactional; | |
| 17 | +import org.springframework.validation.annotation.Validated; | |
| 18 | + | |
| 19 | +import java.util.List; | |
| 20 | + | |
| 21 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 22 | +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.DEMO03_STUDENT_NOT_EXISTS; | |
| 23 | + | |
| 24 | +/** | |
| 25 | + * 学生 Service 实现类 | |
| 26 | + * | |
| 27 | + * @author 芋道源码 | |
| 28 | + */ | |
| 29 | +@Service | |
| 30 | +@Validated | |
| 31 | +public class Demo03StudentNormalServiceImpl implements Demo03StudentNormalService { | |
| 32 | + | |
| 33 | + @Resource | |
| 34 | + private Demo03StudentNormalMapper demo03StudentNormalMapper; | |
| 35 | + @Resource | |
| 36 | + private Demo03CourseNormalMapper demo03CourseNormalMapper; | |
| 37 | + @Resource | |
| 38 | + private Demo03GradeNormalMapper demo03GradeNormalMapper; | |
| 39 | + | |
| 40 | + @Override | |
| 41 | + @Transactional(rollbackFor = Exception.class) | |
| 42 | + public Long createDemo03Student(Demo03StudentNormalSaveReqVO createReqVO) { | |
| 43 | + // 插入 | |
| 44 | + Demo03StudentDO demo03Student = BeanUtils.toBean(createReqVO, Demo03StudentDO.class); | |
| 45 | + demo03StudentNormalMapper.insert(demo03Student); | |
| 46 | + | |
| 47 | + // 插入子表 | |
| 48 | + createDemo03CourseList(demo03Student.getId(), createReqVO.getDemo03Courses()); | |
| 49 | + createDemo03Grade(demo03Student.getId(), createReqVO.getDemo03Grade()); | |
| 50 | + // 返回 | |
| 51 | + return demo03Student.getId(); | |
| 52 | + } | |
| 53 | + | |
| 54 | + @Override | |
| 55 | + @Transactional(rollbackFor = Exception.class) | |
| 56 | + public void updateDemo03Student(Demo03StudentNormalSaveReqVO updateReqVO) { | |
| 57 | + // 校验存在 | |
| 58 | + validateDemo03StudentExists(updateReqVO.getId()); | |
| 59 | + // 更新 | |
| 60 | + Demo03StudentDO updateObj = BeanUtils.toBean(updateReqVO, Demo03StudentDO.class); | |
| 61 | + demo03StudentNormalMapper.updateById(updateObj); | |
| 62 | + | |
| 63 | + // 更新子表 | |
| 64 | + updateDemo03CourseList(updateReqVO.getId(), updateReqVO.getDemo03Courses()); | |
| 65 | + updateDemo03Grade(updateReqVO.getId(), updateReqVO.getDemo03Grade()); | |
| 66 | + } | |
| 67 | + | |
| 68 | + @Override | |
| 69 | + @Transactional(rollbackFor = Exception.class) | |
| 70 | + public void deleteDemo03Student(Long id) { | |
| 71 | + // 校验存在 | |
| 72 | + validateDemo03StudentExists(id); | |
| 73 | + // 删除 | |
| 74 | + demo03StudentNormalMapper.deleteById(id); | |
| 75 | + | |
| 76 | + // 删除子表 | |
| 77 | + deleteDemo03CourseByStudentId(id); | |
| 78 | + deleteDemo03GradeByStudentId(id); | |
| 79 | + } | |
| 80 | + | |
| 81 | + @Override | |
| 82 | + @Transactional(rollbackFor = Exception.class) | |
| 83 | + public void deleteDemo03StudentByIds(List<Long> ids) { | |
| 84 | + // 校验存在 | |
| 85 | + validateDemo03StudentExists(ids); | |
| 86 | + // 删除 | |
| 87 | + demo03StudentNormalMapper.deleteByIds(ids); | |
| 88 | + | |
| 89 | + // 删除子表 | |
| 90 | + deleteDemo03CourseByStudentIds(ids); | |
| 91 | + deleteDemo03GradeByStudentIds(ids); | |
| 92 | + } | |
| 93 | + | |
| 94 | + private void validateDemo03StudentExists(List<Long> ids) { | |
| 95 | + List<Demo03StudentDO> list = demo03StudentNormalMapper.selectByIds(ids); | |
| 96 | + if (CollUtil.isEmpty(list) || list.size() != ids.size()) { | |
| 97 | + throw exception(DEMO03_STUDENT_NOT_EXISTS); | |
| 98 | + } | |
| 99 | + } | |
| 100 | + | |
| 101 | + private void validateDemo03StudentExists(Long id) { | |
| 102 | + if (demo03StudentNormalMapper.selectById(id) == null) { | |
| 103 | + throw exception(DEMO03_STUDENT_NOT_EXISTS); | |
| 104 | + } | |
| 105 | + } | |
| 106 | + | |
| 107 | + @Override | |
| 108 | + public Demo03StudentDO getDemo03Student(Long id) { | |
| 109 | + return demo03StudentNormalMapper.selectById(id); | |
| 110 | + } | |
| 111 | + | |
| 112 | + @Override | |
| 113 | + public PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentNormalPageReqVO pageReqVO) { | |
| 114 | + return demo03StudentNormalMapper.selectPage(pageReqVO); | |
| 115 | + } | |
| 116 | + | |
| 117 | + // ==================== 子表(学生课程) ==================== | |
| 118 | + | |
| 119 | + @Override | |
| 120 | + public List<Demo03CourseDO> getDemo03CourseListByStudentId(Long studentId) { | |
| 121 | + return demo03CourseNormalMapper.selectListByStudentId(studentId); | |
| 122 | + } | |
| 123 | + | |
| 124 | + private void createDemo03CourseList(Long studentId, List<Demo03CourseDO> list) { | |
| 125 | + list.forEach(o -> o.setStudentId(studentId)); | |
| 126 | + demo03CourseNormalMapper.insertBatch(list); | |
| 127 | + } | |
| 128 | + | |
| 129 | + private void updateDemo03CourseList(Long studentId, List<Demo03CourseDO> list) { | |
| 130 | + deleteDemo03CourseByStudentId(studentId); | |
| 131 | + list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 | |
| 132 | + createDemo03CourseList(studentId, list); | |
| 133 | + } | |
| 134 | + | |
| 135 | + private void deleteDemo03CourseByStudentId(Long studentId) { | |
| 136 | + demo03CourseNormalMapper.deleteByStudentId(studentId); | |
| 137 | + } | |
| 138 | + | |
| 139 | + private void deleteDemo03CourseByStudentIds(List<Long> studentIds) { | |
| 140 | + demo03CourseNormalMapper.deleteByStudentIds(studentIds); | |
| 141 | + } | |
| 142 | + | |
| 143 | + // ==================== 子表(学生班级) ==================== | |
| 144 | + | |
| 145 | + @Override | |
| 146 | + public Demo03GradeDO getDemo03GradeByStudentId(Long studentId) { | |
| 147 | + return demo03GradeNormalMapper.selectByStudentId(studentId); | |
| 148 | + } | |
| 149 | + | |
| 150 | + private void createDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) { | |
| 151 | + if (demo03Grade == null) { | |
| 152 | + return; | |
| 153 | + } | |
| 154 | + demo03Grade.setStudentId(studentId); | |
| 155 | + demo03GradeNormalMapper.insert(demo03Grade); | |
| 156 | + } | |
| 157 | + | |
| 158 | + private void updateDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) { | |
| 159 | + if (demo03Grade == null) { | |
| 160 | + return; | |
| 161 | + } | |
| 162 | + demo03Grade.setStudentId(studentId); | |
| 163 | + demo03Grade.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 | |
| 164 | + demo03GradeNormalMapper.insertOrUpdate(demo03Grade); | |
| 165 | + } | |
| 166 | + | |
| 167 | + private void deleteDemo03GradeByStudentId(Long studentId) { | |
| 168 | + demo03GradeNormalMapper.deleteByStudentId(studentId); | |
| 169 | + } | |
| 170 | + | |
| 171 | + private void deleteDemo03GradeByStudentIds(List<Long> studentIds) { | |
| 172 | + demo03GradeNormalMapper.deleteByStudentIds(studentIds); | |
| 173 | + } | |
| 174 | + | |
| 175 | +} | |
| 0 | 176 | \ No newline at end of file | ... | ... |
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/index.vue.vm
| ... | ... | @@ -95,6 +95,13 @@ async function onDelete(row: ${simpleClassName}Api.${simpleClassName}) { |
| 95 | 95 | #if ($table.templateType != 2 && $table.deleteBatch) |
| 96 | 96 | const deleteIds = ref<number[]>([]) // 待删除${table.classComment} ID |
| 97 | 97 | const showDeleteBatchBtn = computed(() => isEmpty(deleteIds.value)); |
| 98 | +function setDeleteIds({ | |
| 99 | + records, | |
| 100 | +}: { | |
| 101 | + records: ${simpleClassName}Api.${simpleClassName}[]; | |
| 102 | +}) { | |
| 103 | + deleteIds.value = records.map((item) => item.id); | |
| 104 | +} | |
| 98 | 105 | /** 批量删除${table.classComment} */ |
| 99 | 106 | async function onDeleteBatch() { |
| 100 | 107 | const hideLoading = message.loading({ |
| ... | ... | @@ -205,12 +212,8 @@ const [Grid, gridApi] = useVbenVxeGrid({ |
| 205 | 212 | }, |
| 206 | 213 | #end |
| 207 | 214 | #if($table.deleteBatch) |
| 208 | - checkboxAll: ({records,}: { records: ${simpleClassName}Api.${simpleClassName}[];}) => { | |
| 209 | - deleteIds.value = records.map((item) => item.id); | |
| 210 | - }, | |
| 211 | - checkboxChange: ({records,}: { records: ${simpleClassName}Api.${simpleClassName}[];}) => { | |
| 212 | - deleteIds.value = records.map((item) => item.id); | |
| 213 | - }, | |
| 215 | + checkboxAll: setDeleteIds, | |
| 216 | + checkboxChange: setDeleteIds, | |
| 214 | 217 | #end |
| 215 | 218 | } |
| 216 | 219 | #end | ... | ... |
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/modules/list_sub_erp.vue.vm
| ... | ... | @@ -76,6 +76,13 @@ async function onDelete(row: ${simpleClassName}Api.${subSimpleClassName}) { |
| 76 | 76 | #if ($table.deleteBatch) |
| 77 | 77 | const deleteIds = ref<number[]>([]) // 待删除${subTable.classComment} ID |
| 78 | 78 | const showDeleteBatchBtn = computed(() => isEmpty(deleteIds.value)); |
| 79 | +function setDeleteIds({ | |
| 80 | + records, | |
| 81 | +}: { | |
| 82 | + records: ${simpleClassName}Api.${subSimpleClassName}[]; | |
| 83 | +}) { | |
| 84 | + deleteIds.value = records.map((item) => item.id); | |
| 85 | +} | |
| 79 | 86 | /** 批量删除${subTable.classComment} */ |
| 80 | 87 | async function onDeleteBatch() { |
| 81 | 88 | const hideLoading = message.loading({ |
| ... | ... | @@ -159,12 +166,8 @@ function onActionClick({ |
| 159 | 166 | } as VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>, |
| 160 | 167 | #if (${table.templateType} == 11 && $table.deleteBatch) |
| 161 | 168 | gridEvents:{ |
| 162 | - checkboxAll: ({records,}: { records: ${simpleClassName}Api.${subSimpleClassName}[];}) => { | |
| 163 | - deleteIds.value = records.map((item) => item.id); | |
| 164 | - }, | |
| 165 | - checkboxChange: ({records,}: { records: ${simpleClassName}Api.${subSimpleClassName}[];}) => { | |
| 166 | - deleteIds.value = records.map((item) => item.id); | |
| 167 | - }, | |
| 169 | + checkboxAll: setDeleteIds, | |
| 170 | + checkboxChange: setDeleteIds, | |
| 168 | 171 | } |
| 169 | 172 | #end |
| 170 | 173 | }); | ... | ... |