From e10425e049daac247b77b4fc4b193d14298c9e11 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 19 May 2025 17:58:57 +0800 Subject: [PATCH] perf:【INFRA 基础设施】vben5-antd-schema 主主子表normal代码生成时,可生成批量删除 --- yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/Demo01ContactController.java | 3 +-- yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/Demo03StudentController.java | 208 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/Demo03StudentErpController.java | 208 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentErpPageReqVO.java | 30 ++++++++++++++++++++++++++++++ yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentErpRespVO.java | 41 +++++++++++++++++++++++++++++++++++++++++ yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentErpSaveReqVO.java | 32 ++++++++++++++++++++++++++++++++ yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentPageReqVO.java | 30 ------------------------------ yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentRespVO.java | 41 ----------------------------------------- yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentSaveReqVO.java | 32 -------------------------------- yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/Demo03StudentNormalController.java | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/vo/Demo03StudentNormalPageReqVO.java | 30 ++++++++++++++++++++++++++++++ yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/vo/Demo03StudentNormalRespVO.java | 41 +++++++++++++++++++++++++++++++++++++++++ yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/vo/Demo03StudentNormalSaveReqVO.java | 41 +++++++++++++++++++++++++++++++++++++++++ yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03CourseErpMapper.java | 34 ++++++++++++++++++++++++++++++++++ yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03CourseMapper.java | 34 ---------------------------------- yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03GradeErpMapper.java | 37 +++++++++++++++++++++++++++++++++++++ yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03GradeMapper.java | 37 ------------------------------------- yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03StudentErpMapper.java | 27 +++++++++++++++++++++++++++ yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03StudentMapper.java | 27 --------------------------- yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/normal/Demo03CourseNormalMapper.java | 29 +++++++++++++++++++++++++++++ yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/normal/Demo03GradeNormalMapper.java | 29 +++++++++++++++++++++++++++++ yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/normal/Demo03StudentNormalMapper.java | 27 +++++++++++++++++++++++++++ yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentErpService.java | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentErpServiceImpl.java | 241 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentService.java | 160 ---------------------------------------------------------------------------------------------------------------------------------------------------------------- yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentServiceImpl.java | 241 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/normal/Demo03StudentNormalService.java | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/normal/Demo03StudentNormalServiceImpl.java | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/index.vue.vm | 15 +++++++++------ yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/modules/list_sub_erp.vue.vm | 15 +++++++++------ 30 files changed, 1409 insertions(+), 824 deletions(-) delete mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/Demo03StudentController.java create mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/Demo03StudentErpController.java create mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentErpPageReqVO.java create mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentErpRespVO.java create mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentErpSaveReqVO.java delete mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentPageReqVO.java delete mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentRespVO.java delete mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentSaveReqVO.java create mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/Demo03StudentNormalController.java create mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/vo/Demo03StudentNormalPageReqVO.java create mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/vo/Demo03StudentNormalRespVO.java create mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/vo/Demo03StudentNormalSaveReqVO.java create mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03CourseErpMapper.java delete mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03CourseMapper.java create mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03GradeErpMapper.java delete mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03GradeMapper.java create mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03StudentErpMapper.java delete mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03StudentMapper.java create mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/normal/Demo03CourseNormalMapper.java create mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/normal/Demo03GradeNormalMapper.java create mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/normal/Demo03StudentNormalMapper.java create mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentErpService.java create mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentErpServiceImpl.java delete mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentService.java delete mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentServiceImpl.java create mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/normal/Demo03StudentNormalService.java create mode 100644 yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/normal/Demo03StudentNormalServiceImpl.java diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/Demo01ContactController.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/Demo01ContactController.java index c3c518d..8574aef 100644 --- a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/Demo01ContactController.java +++ b/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; import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; -import jakarta.validation.constraints.Size; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -65,7 +64,7 @@ public class Demo01ContactController { @Parameter(name = "ids", description = "编号", required = true) @Operation(summary = "批量删除示例联系人") @PreAuthorize("@ss.hasPermission('infra:demo01-contact:delete')") - public CommonResult deleteDemo01Contact(@RequestParam("ids") @Size(max = 100, message = "最多允许100个") List ids) { + public CommonResult deleteDemo01Contact(@RequestParam("ids") List ids) { demo01ContactService.deleteDemo01ContactByIds(ids); return success(true); } diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/Demo03StudentController.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/Demo03StudentController.java deleted file mode 100644 index 09c0c20..0000000 --- a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/Demo03StudentController.java +++ /dev/null @@ -1,208 +0,0 @@ -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; -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.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.erp.Demo03StudentService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 学生") -@RestController -@RequestMapping("/infra/demo03-student-erp") -@Validated -public class Demo03StudentController { - - @Resource - private Demo03StudentService demo03StudentService; - - @PostMapping("/create") - @Operation(summary = "创建学生") - @PreAuthorize("@ss.hasPermission('infra:demo03-student:create')") - public CommonResult createDemo03Student(@Valid @RequestBody Demo03StudentSaveReqVO createReqVO) { - return success(demo03StudentService.createDemo03Student(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新学生") - @PreAuthorize("@ss.hasPermission('infra:demo03-student:update')") - public CommonResult updateDemo03Student(@Valid @RequestBody Demo03StudentSaveReqVO updateReqVO) { - demo03StudentService.updateDemo03Student(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除学生") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')") - public CommonResult deleteDemo03Student(@RequestParam("id") Long id) { - demo03StudentService.deleteDemo03Student(id); - return success(true); - } - - @DeleteMapping("/delete-batch") - @Parameter(name = "ids", description = "编号", required = true) - @Operation(summary = "批量删除学生") - @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')") - public CommonResult deleteDemo03Student(@RequestParam("ids") List ids) { - demo03StudentService.deleteDemo03StudentByIds(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得学生") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") - public CommonResult getDemo03Student(@RequestParam("id") Long id) { - Demo03StudentDO demo03Student = demo03StudentService.getDemo03Student(id); - return success(BeanUtils.toBean(demo03Student, Demo03StudentRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得学生分页") - @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") - public CommonResult> getDemo03StudentPage(@Valid Demo03StudentPageReqVO pageReqVO) { - PageResult pageResult = demo03StudentService.getDemo03StudentPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, Demo03StudentRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出学生 Excel") - @PreAuthorize("@ss.hasPermission('infra:demo03-student:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportDemo03StudentExcel(@Valid Demo03StudentPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = demo03StudentService.getDemo03StudentPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "学生.xls", "数据", Demo03StudentRespVO.class, - BeanUtils.toBean(list, Demo03StudentRespVO.class)); - } - - // ==================== 子表(学生课程) ==================== - - @GetMapping("/demo03-course/page") - @Operation(summary = "获得学生课程分页") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") - public CommonResult> getDemo03CoursePage(PageParam pageReqVO, - @RequestParam("studentId") Long studentId) { - return success(demo03StudentService.getDemo03CoursePage(pageReqVO, studentId)); - } - - @PostMapping("/demo03-course/create") - @Operation(summary = "创建学生课程") - @PreAuthorize("@ss.hasPermission('infra:demo03-student:create')") - public CommonResult createDemo03Course(@Valid @RequestBody Demo03CourseDO demo03Course) { - return success(demo03StudentService.createDemo03Course(demo03Course)); - } - - @PutMapping("/demo03-course/update") - @Operation(summary = "更新学生课程") - @PreAuthorize("@ss.hasPermission('infra:demo03-student:update')") - public CommonResult updateDemo03Course(@Valid @RequestBody Demo03CourseDO demo03Course) { - demo03StudentService.updateDemo03Course(demo03Course); - return success(true); - } - - @DeleteMapping("/demo03-course/delete") - @Parameter(name = "id", description = "编号", required = true) - @Operation(summary = "删除学生课程") - @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')") - public CommonResult deleteDemo03Course(@RequestParam("id") Long id) { - demo03StudentService.deleteDemo03Course(id); - 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 deleteDemo03Course(@RequestParam("ids") List ids) { - demo03StudentService.deleteDemo03CourseByIds(ids); - return success(true); - } - - @GetMapping("/demo03-course/get") - @Operation(summary = "获得学生课程") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") - public CommonResult getDemo03Course(@RequestParam("id") Long id) { - return success(demo03StudentService.getDemo03Course(id)); - } - - // ==================== 子表(学生班级) ==================== - - @GetMapping("/demo03-grade/page") - @Operation(summary = "获得学生班级分页") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") - public CommonResult> getDemo03GradePage(PageParam pageReqVO, - @RequestParam("studentId") Long studentId) { - return success(demo03StudentService.getDemo03GradePage(pageReqVO, studentId)); - } - - @PostMapping("/demo03-grade/create") - @Operation(summary = "创建学生班级") - @PreAuthorize("@ss.hasPermission('infra:demo03-student:create')") - public CommonResult createDemo03Grade(@Valid @RequestBody Demo03GradeDO demo03Grade) { - return success(demo03StudentService.createDemo03Grade(demo03Grade)); - } - - @PutMapping("/demo03-grade/update") - @Operation(summary = "更新学生班级") - @PreAuthorize("@ss.hasPermission('infra:demo03-student:update')") - public CommonResult updateDemo03Grade(@Valid @RequestBody Demo03GradeDO demo03Grade) { - demo03StudentService.updateDemo03Grade(demo03Grade); - return success(true); - } - - @DeleteMapping("/demo03-grade/delete") - @Parameter(name = "id", description = "编号", required = true) - @Operation(summary = "删除学生班级") - @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')") - public CommonResult deleteDemo03Grade(@RequestParam("id") Long id) { - demo03StudentService.deleteDemo03Grade(id); - 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 deleteDemo03Grade(@RequestParam("ids") List ids) { - demo03StudentService.deleteDemo03GradeByIds(ids); - return success(true); - } - - @GetMapping("/demo03-grade/get") - @Operation(summary = "获得学生班级") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") - public CommonResult getDemo03Grade(@RequestParam("id") Long id) { - return success(demo03StudentService.getDemo03Grade(id)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/Demo03StudentErpController.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/Demo03StudentErpController.java new file mode 100644 index 0000000..361e7f5 --- /dev/null +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/Demo03StudentErpController.java @@ -0,0 +1,208 @@ +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; +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.erp.vo.Demo03StudentErpPageReqVO; +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpRespVO; +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpSaveReqVO; +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.erp.Demo03StudentErpService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.io.IOException; +import java.util.List; + +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - 学生") +@RestController +@RequestMapping("/infra/demo03-student-erp") +@Validated +public class Demo03StudentErpController { + + @Resource + private Demo03StudentErpService demo03StudentErpService; + + @PostMapping("/create") + @Operation(summary = "创建学生") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:create')") + public CommonResult createDemo03Student(@Valid @RequestBody Demo03StudentErpSaveReqVO createReqVO) { + return success(demo03StudentErpService.createDemo03Student(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新学生") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:update')") + public CommonResult updateDemo03Student(@Valid @RequestBody Demo03StudentErpSaveReqVO updateReqVO) { + demo03StudentErpService.updateDemo03Student(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除学生") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')") + public CommonResult deleteDemo03Student(@RequestParam("id") Long id) { + demo03StudentErpService.deleteDemo03Student(id); + return success(true); + } + + @DeleteMapping("/delete-batch") + @Parameter(name = "ids", description = "编号", required = true) + @Operation(summary = "批量删除学生") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')") + public CommonResult deleteDemo03Student(@RequestParam("ids") List ids) { + demo03StudentErpService.deleteDemo03StudentByIds(ids); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得学生") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") + public CommonResult getDemo03Student(@RequestParam("id") Long id) { + Demo03StudentDO demo03Student = demo03StudentErpService.getDemo03Student(id); + return success(BeanUtils.toBean(demo03Student, Demo03StudentErpRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得学生分页") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") + public CommonResult> getDemo03StudentPage(@Valid Demo03StudentErpPageReqVO pageReqVO) { + PageResult pageResult = demo03StudentErpService.getDemo03StudentPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, Demo03StudentErpRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出学生 Excel") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportDemo03StudentExcel(@Valid Demo03StudentErpPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = demo03StudentErpService.getDemo03StudentPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "学生.xls", "数据", Demo03StudentErpRespVO.class, + BeanUtils.toBean(list, Demo03StudentErpRespVO.class)); + } + + // ==================== 子表(学生课程) ==================== + + @GetMapping("/demo03-course/page") + @Operation(summary = "获得学生课程分页") + @Parameter(name = "studentId", description = "学生编号") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") + public CommonResult> getDemo03CoursePage(PageParam pageReqVO, + @RequestParam("studentId") Long studentId) { + return success(demo03StudentErpService.getDemo03CoursePage(pageReqVO, studentId)); + } + + @PostMapping("/demo03-course/create") + @Operation(summary = "创建学生课程") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:create')") + public CommonResult createDemo03Course(@Valid @RequestBody Demo03CourseDO demo03Course) { + return success(demo03StudentErpService.createDemo03Course(demo03Course)); + } + + @PutMapping("/demo03-course/update") + @Operation(summary = "更新学生课程") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:update')") + public CommonResult updateDemo03Course(@Valid @RequestBody Demo03CourseDO demo03Course) { + demo03StudentErpService.updateDemo03Course(demo03Course); + return success(true); + } + + @DeleteMapping("/demo03-course/delete") + @Parameter(name = "id", description = "编号", required = true) + @Operation(summary = "删除学生课程") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')") + public CommonResult deleteDemo03Course(@RequestParam("id") Long id) { + demo03StudentErpService.deleteDemo03Course(id); + 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 deleteDemo03Course(@RequestParam("ids") List ids) { + demo03StudentErpService.deleteDemo03CourseByIds(ids); + return success(true); + } + + @GetMapping("/demo03-course/get") + @Operation(summary = "获得学生课程") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") + public CommonResult getDemo03Course(@RequestParam("id") Long id) { + return success(demo03StudentErpService.getDemo03Course(id)); + } + + // ==================== 子表(学生班级) ==================== + + @GetMapping("/demo03-grade/page") + @Operation(summary = "获得学生班级分页") + @Parameter(name = "studentId", description = "学生编号") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") + public CommonResult> getDemo03GradePage(PageParam pageReqVO, + @RequestParam("studentId") Long studentId) { + return success(demo03StudentErpService.getDemo03GradePage(pageReqVO, studentId)); + } + + @PostMapping("/demo03-grade/create") + @Operation(summary = "创建学生班级") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:create')") + public CommonResult createDemo03Grade(@Valid @RequestBody Demo03GradeDO demo03Grade) { + return success(demo03StudentErpService.createDemo03Grade(demo03Grade)); + } + + @PutMapping("/demo03-grade/update") + @Operation(summary = "更新学生班级") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:update')") + public CommonResult updateDemo03Grade(@Valid @RequestBody Demo03GradeDO demo03Grade) { + demo03StudentErpService.updateDemo03Grade(demo03Grade); + return success(true); + } + + @DeleteMapping("/demo03-grade/delete") + @Parameter(name = "id", description = "编号", required = true) + @Operation(summary = "删除学生班级") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')") + public CommonResult deleteDemo03Grade(@RequestParam("id") Long id) { + demo03StudentErpService.deleteDemo03Grade(id); + 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 deleteDemo03Grade(@RequestParam("ids") List ids) { + demo03StudentErpService.deleteDemo03GradeByIds(ids); + return success(true); + } + + @GetMapping("/demo03-grade/get") + @Operation(summary = "获得学生班级") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") + public CommonResult getDemo03Grade(@RequestParam("id") Long id) { + return success(demo03StudentErpService.getDemo03Grade(id)); + } + +} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentErpPageReqVO.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentErpPageReqVO.java new file mode 100644 index 0000000..3fb8dea --- /dev/null +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentErpPageReqVO.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo; + +import lombok.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 学生分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class Demo03StudentErpPageReqVO extends PageParam { + + @Schema(description = "名字", example = "芋艿") + private String name; + + @Schema(description = "性别") + private Integer sex; + + @Schema(description = "简介", example = "随便") + private String description; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentErpRespVO.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentErpRespVO.java new file mode 100644 index 0000000..ed7cfca --- /dev/null +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentErpRespVO.java @@ -0,0 +1,41 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + +@Schema(description = "管理后台 - 学生 Response VO") +@Data +@ExcelIgnoreUnannotated +public class Demo03StudentErpRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525") + @ExcelProperty("编号") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") + @ExcelProperty("名字") + private String name; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty(value = "性别", converter = DictConvert.class) + @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer sex; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("出生日期") + private LocalDateTime birthday; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便") + @ExcelProperty("简介") + private String description; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentErpSaveReqVO.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentErpSaveReqVO.java new file mode 100644 index 0000000..46c2504 --- /dev/null +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentErpSaveReqVO.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import jakarta.validation.constraints.*; + +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 学生新增/修改 Request VO") +@Data +public class Demo03StudentErpSaveReqVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") + @NotEmpty(message = "名字不能为空") + private String name; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "性别不能为空") + private Integer sex; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "出生日期不能为空") + private LocalDateTime birthday; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便") + @NotEmpty(message = "简介不能为空") + private String description; + +} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentPageReqVO.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentPageReqVO.java deleted file mode 100644 index 2845b32..0000000 --- a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 学生分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class Demo03StudentPageReqVO extends PageParam { - - @Schema(description = "名字", example = "芋艿") - private String name; - - @Schema(description = "性别") - private Integer sex; - - @Schema(description = "简介", example = "随便") - private String description; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentRespVO.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentRespVO.java deleted file mode 100644 index 8f60e3c..0000000 --- a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentRespVO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; -import com.alibaba.excel.annotation.*; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; - -@Schema(description = "管理后台 - 学生 Response VO") -@Data -@ExcelIgnoreUnannotated -public class Demo03StudentRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - @ExcelProperty("名字") - private String name; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty(value = "性别", converter = DictConvert.class) - @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Integer sex; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出生日期") - private LocalDateTime birthday; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便") - @ExcelProperty("简介") - private String description; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentSaveReqVO.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentSaveReqVO.java deleted file mode 100644 index 5bd8125..0000000 --- a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/erp/vo/Demo03StudentSaveReqVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import jakarta.validation.constraints.*; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 学生新增/修改 Request VO") -@Data -public class Demo03StudentSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "性别不能为空") - private Integer sex; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出生日期不能为空") - private LocalDateTime birthday; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便") - @NotEmpty(message = "简介不能为空") - private String description; - -} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/Demo03StudentNormalController.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/Demo03StudentNormalController.java new file mode 100644 index 0000000..58d11cf --- /dev/null +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/Demo03StudentNormalController.java @@ -0,0 +1,125 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal; + +import org.springframework.web.bind.annotation.*; +import jakarta.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import jakarta.validation.*; +import jakarta.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.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.service.demo.demo03.normal.Demo03StudentNormalService; + +@Tag(name = "管理后台 - 学生") +@RestController +@RequestMapping("/infra/demo03-student-normal") +@Validated +public class Demo03StudentNormalController { + + @Resource + private Demo03StudentNormalService demo03StudentNormalService; + + @PostMapping("/create") + @Operation(summary = "创建学生") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:create')") + public CommonResult createDemo03Student(@Valid @RequestBody Demo03StudentNormalSaveReqVO createReqVO) { + return success(demo03StudentNormalService.createDemo03Student(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新学生") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:update')") + public CommonResult updateDemo03Student(@Valid @RequestBody Demo03StudentNormalSaveReqVO updateReqVO) { + demo03StudentNormalService.updateDemo03Student(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除学生") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')") + public CommonResult deleteDemo03Student(@RequestParam("id") Long id) { + demo03StudentNormalService.deleteDemo03Student(id); + return success(true); + } + + @DeleteMapping("/delete-batch") + @Parameter(name = "ids", description = "编号", required = true) + @Operation(summary = "批量删除学生") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')") + public CommonResult deleteDemo03Student(@RequestParam("ids") List ids) { + demo03StudentNormalService.deleteDemo03StudentByIds(ids); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得学生") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") + public CommonResult getDemo03Student(@RequestParam("id") Long id) { + Demo03StudentDO demo03Student = demo03StudentNormalService.getDemo03Student(id); + return success(BeanUtils.toBean(demo03Student, Demo03StudentNormalRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得学生分页") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") + public CommonResult> getDemo03StudentPage(@Valid Demo03StudentNormalPageReqVO pageReqVO) { + PageResult pageResult = demo03StudentNormalService.getDemo03StudentPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, Demo03StudentNormalRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出学生 Excel") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportDemo03StudentExcel(@Valid Demo03StudentNormalPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = demo03StudentNormalService.getDemo03StudentPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "学生.xls", "数据", Demo03StudentNormalRespVO.class, + BeanUtils.toBean(list, Demo03StudentNormalRespVO.class)); + } + + // ==================== 子表(学生课程) ==================== + + @GetMapping("/demo03-course/list-by-student-id") + @Operation(summary = "获得学生课程列表") + @Parameter(name = "studentId", description = "学生编号") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") + public CommonResult> getDemo03CourseListByStudentId(@RequestParam("studentId") Long studentId) { + return success(demo03StudentNormalService.getDemo03CourseListByStudentId(studentId)); + } + + // ==================== 子表(学生班级) ==================== + + @GetMapping("/demo03-grade/get-by-student-id") + @Operation(summary = "获得学生班级") + @Parameter(name = "studentId", description = "学生编号") + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')") + public CommonResult getDemo03GradeByStudentId(@RequestParam("studentId") Long studentId) { + return success(demo03StudentNormalService.getDemo03GradeByStudentId(studentId)); + } + +} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/vo/Demo03StudentNormalPageReqVO.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/vo/Demo03StudentNormalPageReqVO.java new file mode 100644 index 0000000..5511cb1 --- /dev/null +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/vo/Demo03StudentNormalPageReqVO.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo; + +import lombok.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 学生分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class Demo03StudentNormalPageReqVO extends PageParam { + + @Schema(description = "名字", example = "芋艿") + private String name; + + @Schema(description = "性别") + private Integer sex; + + @Schema(description = "简介", example = "随便") + private String description; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/vo/Demo03StudentNormalRespVO.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/vo/Demo03StudentNormalRespVO.java new file mode 100644 index 0000000..84aa800 --- /dev/null +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/vo/Demo03StudentNormalRespVO.java @@ -0,0 +1,41 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + +@Schema(description = "管理后台 - 学生 Response VO") +@Data +@ExcelIgnoreUnannotated +public class Demo03StudentNormalRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525") + @ExcelProperty("编号") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") + @ExcelProperty("名字") + private String name; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty(value = "性别", converter = DictConvert.class) + @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer sex; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("出生日期") + private LocalDateTime birthday; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便") + @ExcelProperty("简介") + private String description; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/vo/Demo03StudentNormalSaveReqVO.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/vo/Demo03StudentNormalSaveReqVO.java new file mode 100644 index 0000000..627e4db --- /dev/null +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/normal/vo/Demo03StudentNormalSaveReqVO.java @@ -0,0 +1,41 @@ +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.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 +public class Demo03StudentNormalSaveReqVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") + @NotEmpty(message = "名字不能为空") + private String name; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "性别不能为空") + private Integer sex; + + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "出生日期不能为空") + private LocalDateTime birthday; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便") + @NotEmpty(message = "简介不能为空") + private String description; + + @Schema(description = "学生课程列表") + private List demo03Courses; + + @Schema(description = "学生班级") + private Demo03GradeDO demo03Grade; + +} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03CourseErpMapper.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03CourseErpMapper.java new file mode 100644 index 0000000..b438a2f --- /dev/null +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03CourseErpMapper.java @@ -0,0 +1,34 @@ +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; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 学生课程 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface Demo03CourseErpMapper extends BaseMapperX { + + default PageResult selectPage(PageParam reqVO, Long studentId) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eq(Demo03CourseDO::getStudentId, studentId) + .orderByDesc(Demo03CourseDO::getId)); + } + + default int deleteByStudentId(Long studentId) { + return delete(Demo03CourseDO::getStudentId, studentId); + } + + default int deleteByStudentIds(List studentIds) { + return delete(Demo03CourseDO::getStudentId, studentIds); + } + +} diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03CourseMapper.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03CourseMapper.java deleted file mode 100644 index 891586a..0000000 --- a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03CourseMapper.java +++ /dev/null @@ -1,34 +0,0 @@ -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; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 学生课程 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface Demo03CourseMapper extends BaseMapperX { - - default PageResult selectPage(PageParam reqVO, Long studentId) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(Demo03CourseDO::getStudentId, studentId) - .orderByDesc(Demo03CourseDO::getId)); - } - - default int deleteByStudentId(Long studentId) { - return delete(Demo03CourseDO::getStudentId, studentId); - } - - default int deleteByStudentIds(List studentIds) { - return delete(Demo03CourseDO::getStudentId, studentIds); - } - -} diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03GradeErpMapper.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03GradeErpMapper.java new file mode 100644 index 0000000..6bdfcd1 --- /dev/null +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03GradeErpMapper.java @@ -0,0 +1,37 @@ +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; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +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 + * + * @author 芋道源码 + */ +@Mapper +public interface Demo03GradeErpMapper extends BaseMapperX { + + default PageResult selectPage(PageParam reqVO, Long studentId) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eq(Demo03GradeDO::getStudentId, studentId) + .orderByDesc(Demo03GradeDO::getId)); + } + default Demo03GradeDO selectByStudentId(Long studentId) { + return selectOne(Demo03GradeDO::getStudentId, studentId); + } + + default int deleteByStudentId(Long studentId) { + return delete(Demo03GradeDO::getStudentId, studentId); + } + + default int deleteByStudentIds(List studentIds) { + return delete(Demo03GradeDO::getStudentId, studentIds); + } + +} diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03GradeMapper.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03GradeMapper.java deleted file mode 100644 index aec5474..0000000 --- a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03GradeMapper.java +++ /dev/null @@ -1,37 +0,0 @@ -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; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -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 - * - * @author 芋道源码 - */ -@Mapper -public interface Demo03GradeMapper extends BaseMapperX { - - default PageResult selectPage(PageParam reqVO, Long studentId) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(Demo03GradeDO::getStudentId, studentId) - .orderByDesc(Demo03GradeDO::getId)); - } - default Demo03GradeDO selectByStudentId(Long studentId) { - return selectOne(Demo03GradeDO::getStudentId, studentId); - } - - default int deleteByStudentId(Long studentId) { - return delete(Demo03GradeDO::getStudentId, studentId); - } - - default int deleteByStudentIds(List studentIds) { - return delete(Demo03GradeDO::getStudentId, studentIds); - } - -} diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03StudentErpMapper.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03StudentErpMapper.java new file mode 100644 index 0000000..ee600bd --- /dev/null +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03StudentErpMapper.java @@ -0,0 +1,27 @@ +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.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; + +/** + * 学生 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface Demo03StudentErpMapper extends BaseMapperX { + + default PageResult selectPage(Demo03StudentErpPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(Demo03StudentDO::getName, reqVO.getName()) + .eqIfPresent(Demo03StudentDO::getSex, reqVO.getSex()) + .eqIfPresent(Demo03StudentDO::getDescription, reqVO.getDescription()) + .betweenIfPresent(Demo03StudentDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(Demo03StudentDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03StudentMapper.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03StudentMapper.java deleted file mode 100644 index 7d7628b..0000000 --- a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/erp/Demo03StudentMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -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.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; - -/** - * 学生 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface Demo03StudentMapper extends BaseMapperX { - - default PageResult selectPage(Demo03StudentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(Demo03StudentDO::getName, reqVO.getName()) - .eqIfPresent(Demo03StudentDO::getSex, reqVO.getSex()) - .eqIfPresent(Demo03StudentDO::getDescription, reqVO.getDescription()) - .betweenIfPresent(Demo03StudentDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(Demo03StudentDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/normal/Demo03CourseNormalMapper.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/normal/Demo03CourseNormalMapper.java new file mode 100644 index 0000000..7617bb9 --- /dev/null +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/normal/Demo03CourseNormalMapper.java @@ -0,0 +1,29 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.normal; + +import java.util.*; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 学生课程 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface Demo03CourseNormalMapper extends BaseMapperX { + + default List selectListByStudentId(Long studentId) { + return selectList(Demo03CourseDO::getStudentId, studentId); + } + + default int deleteByStudentId(Long studentId) { + return delete(Demo03CourseDO::getStudentId, studentId); + } + + default int deleteByStudentIds(List studentIds) { + return delete(Demo03CourseDO::getStudentId, studentIds); + } + +} diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/normal/Demo03GradeNormalMapper.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/normal/Demo03GradeNormalMapper.java new file mode 100644 index 0000000..c296c86 --- /dev/null +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/normal/Demo03GradeNormalMapper.java @@ -0,0 +1,29 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.normal; + +import java.util.*; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 学生班级 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface Demo03GradeNormalMapper extends BaseMapperX { + + default Demo03GradeDO selectByStudentId(Long studentId) { + return selectOne(Demo03GradeDO::getStudentId, studentId); + } + + default int deleteByStudentId(Long studentId) { + return delete(Demo03GradeDO::getStudentId, studentId); + } + + default int deleteByStudentIds(List studentIds) { + return delete(Demo03GradeDO::getStudentId, studentIds); + } + +} diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/normal/Demo03StudentNormalMapper.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/normal/Demo03StudentNormalMapper.java new file mode 100644 index 0000000..105812c --- /dev/null +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/normal/Demo03StudentNormalMapper.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.normal; + +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.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo.*; + +/** + * 学生 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface Demo03StudentNormalMapper extends BaseMapperX { + + default PageResult selectPage(Demo03StudentNormalPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(Demo03StudentDO::getName, reqVO.getName()) + .eqIfPresent(Demo03StudentDO::getSex, reqVO.getSex()) + .eqIfPresent(Demo03StudentDO::getDescription, reqVO.getDescription()) + .betweenIfPresent(Demo03StudentDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(Demo03StudentDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentErpService.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentErpService.java new file mode 100644 index 0000000..a346116 --- /dev/null +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentErpService.java @@ -0,0 +1,160 @@ +package cn.iocoder.yudao.module.infra.service.demo.demo03.erp; + +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.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 学生 Service 接口 + * + * @author 芋道源码 + */ +public interface Demo03StudentErpService { + + /** + * 创建学生 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createDemo03Student(@Valid Demo03StudentErpSaveReqVO createReqVO); + + /** + * 更新学生 + * + * @param updateReqVO 更新信息 + */ + void updateDemo03Student(@Valid Demo03StudentErpSaveReqVO updateReqVO); + + /** + * 删除学生 + * + * @param id 编号 + */ + void deleteDemo03Student(Long id); + + /** + * 批量删除学生 + * + * @param ids 编号 + */ + void deleteDemo03StudentByIds(List ids); + + /** + * 获得学生 + * + * @param id 编号 + * @return 学生 + */ + Demo03StudentDO getDemo03Student(Long id); + + /** + * 获得学生分页 + * + * @param pageReqVO 分页查询 + * @return 学生分页 + */ + PageResult getDemo03StudentPage(Demo03StudentErpPageReqVO pageReqVO); + + // ==================== 子表(学生课程) ==================== + + /** + * 获得学生课程分页 + * + * @param pageReqVO 分页查询 + * @param studentId 学生编号 + * @return 学生课程分页 + */ + PageResult getDemo03CoursePage(PageParam pageReqVO, Long studentId); + + /** + * 创建学生课程 + * + * @param demo03Course 创建信息 + * @return 编号 + */ + Long createDemo03Course(@Valid Demo03CourseDO demo03Course); + + /** + * 更新学生课程 + * + * @param demo03Course 更新信息 + */ + void updateDemo03Course(@Valid Demo03CourseDO demo03Course); + + /** + * 删除学生课程 + * + * @param id 编号 + */ + void deleteDemo03Course(Long id); + + /** + * 批量删除学生课程 + * + * @param ids 编号 + */ + void deleteDemo03CourseByIds(List ids); + + /** + * 获得学生课程 + * + * @param id 编号 + * @return 学生课程 + */ + Demo03CourseDO getDemo03Course(Long id); + + // ==================== 子表(学生班级) ==================== + + /** + * 获得学生班级分页 + * + * @param pageReqVO 分页查询 + * @param studentId 学生编号 + * @return 学生班级分页 + */ + PageResult getDemo03GradePage(PageParam pageReqVO, Long studentId); + + /** + * 创建学生班级 + * + * @param demo03Grade 创建信息 + * @return 编号 + */ + Long createDemo03Grade(@Valid Demo03GradeDO demo03Grade); + + /** + * 更新学生班级 + * + * @param demo03Grade 更新信息 + */ + void updateDemo03Grade(@Valid Demo03GradeDO demo03Grade); + + /** + * 删除学生班级 + * + * @param id 编号 + */ + void deleteDemo03Grade(Long id); + + /** + * 批量删除学生班级 + * + * @param ids 编号 + */ + void deleteDemo03GradeByIds(List ids); + + /** + * 获得学生班级 + * + * @param id 编号 + * @return 学生班级 + */ + Demo03GradeDO getDemo03Grade(Long id); + +} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentErpServiceImpl.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentErpServiceImpl.java new file mode 100644 index 0000000..2329f27 --- /dev/null +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentErpServiceImpl.java @@ -0,0 +1,241 @@ +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.erp.vo.Demo03StudentErpPageReqVO; +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpSaveReqVO; +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.erp.Demo03CourseErpMapper; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp.Demo03GradeErpMapper; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp.Demo03StudentErpMapper; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; + +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; + +/** + * 学生 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class Demo03StudentErpServiceImpl implements Demo03StudentErpService { + + @Resource + private Demo03StudentErpMapper demo03StudentErpMapper; + @Resource + private Demo03CourseErpMapper demo03CourseErpMapper; + @Resource + private Demo03GradeErpMapper demo03GradeErpMapper; + + @Override + public Long createDemo03Student(Demo03StudentErpSaveReqVO createReqVO) { + // 插入 + Demo03StudentDO demo03Student = BeanUtils.toBean(createReqVO, Demo03StudentDO.class); + demo03StudentErpMapper.insert(demo03Student); + // 返回 + return demo03Student.getId(); + } + + @Override + public void updateDemo03Student(Demo03StudentErpSaveReqVO updateReqVO) { + // 校验存在 + validateDemo03StudentExists(updateReqVO.getId()); + // 更新 + Demo03StudentDO updateObj = BeanUtils.toBean(updateReqVO, Demo03StudentDO.class); + demo03StudentErpMapper.updateById(updateObj); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteDemo03Student(Long id) { + // 校验存在 + validateDemo03StudentExists(id); + // 删除 + demo03StudentErpMapper.deleteById(id); + + // 删除子表 + deleteDemo03CourseByStudentId(id); + deleteDemo03GradeByStudentId(id); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteDemo03StudentByIds(List ids) { + // 校验存在 + validateDemo03StudentExists(ids); + // 删除 + demo03StudentErpMapper.deleteByIds(ids); + + // 删除子表 + deleteDemo03CourseByStudentIds(ids); + deleteDemo03GradeByStudentIds(ids); + } + + private void validateDemo03StudentExists(List ids) { + List list = demo03StudentErpMapper.selectByIds(ids); + if (CollUtil.isEmpty(list) || list.size() != ids.size()) { + throw exception(DEMO03_STUDENT_NOT_EXISTS); + } + } + + private void validateDemo03StudentExists(Long id) { + if (demo03StudentErpMapper.selectById(id) == null) { + throw exception(DEMO03_STUDENT_NOT_EXISTS); + } + } + + @Override + public Demo03StudentDO getDemo03Student(Long id) { + return demo03StudentErpMapper.selectById(id); + } + + @Override + public PageResult getDemo03StudentPage(Demo03StudentErpPageReqVO pageReqVO) { + return demo03StudentErpMapper.selectPage(pageReqVO); + } + + // ==================== 子表(学生课程) ==================== + + @Override + public PageResult getDemo03CoursePage(PageParam pageReqVO, Long studentId) { + return demo03CourseErpMapper.selectPage(pageReqVO, studentId); + } + + @Override + public Long createDemo03Course(Demo03CourseDO demo03Course) { + demo03CourseErpMapper.insert(demo03Course); + return demo03Course.getId(); + } + + @Override + public void updateDemo03Course(Demo03CourseDO demo03Course) { + // 校验存在 + validateDemo03CourseExists(demo03Course.getId()); + // 更新 + demo03Course.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 + demo03CourseErpMapper.updateById(demo03Course); + } + + @Override + public void deleteDemo03Course(Long id) { + // 校验存在 + validateDemo03CourseExists(id); + // 删除 + demo03CourseErpMapper.deleteById(id); + } + + @Override + public void deleteDemo03CourseByIds(List ids) { + // 校验存在 + validateDemo03CourseExists(ids); + // 删除 + demo03CourseErpMapper.deleteByIds(ids); + } + + @Override + public Demo03CourseDO getDemo03Course(Long id) { + return demo03CourseErpMapper.selectById(id); + } + + private void validateDemo03CourseExists(Long id) { + if (demo03CourseErpMapper.selectById(id) == null) { + throw exception(DEMO03_COURSE_NOT_EXISTS); + } + } + + private void validateDemo03CourseExists(List ids) { + List list = demo03CourseErpMapper.selectByIds(ids); + if (CollUtil.isEmpty(list) || list.size() != ids.size()) { + throw exception(DEMO03_COURSE_NOT_EXISTS); + } + } + + private void deleteDemo03CourseByStudentId(Long studentId) { + demo03CourseErpMapper.deleteByStudentId(studentId); + } + + private void deleteDemo03CourseByStudentIds(List studentIds) { + demo03CourseErpMapper.deleteByStudentIds(studentIds); + } + + // ==================== 子表(学生班级) ==================== + + @Override + public PageResult getDemo03GradePage(PageParam pageReqVO, Long studentId) { + return demo03GradeErpMapper.selectPage(pageReqVO, studentId); + } + + @Override + public Long createDemo03Grade(Demo03GradeDO demo03Grade) { + // 校验是否已经存在 + if (demo03GradeErpMapper.selectByStudentId(demo03Grade.getStudentId()) != null) { + throw exception(DEMO03_GRADE_EXISTS); + } + // 插入 + demo03GradeErpMapper.insert(demo03Grade); + return demo03Grade.getId(); + } + + @Override + public void updateDemo03Grade(Demo03GradeDO demo03Grade) { + // 校验存在 + validateDemo03GradeExists(demo03Grade.getId()); + // 更新 + demo03Grade.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 + demo03GradeErpMapper.updateById(demo03Grade); + } + + @Override + public void deleteDemo03Grade(Long id) { + // 校验存在 + validateDemo03GradeExists(id); + // 删除 + demo03GradeErpMapper.deleteById(id); + } + + @Override + public void deleteDemo03GradeByIds(List ids) { + // 校验存在 + validateDemo03GradeExists(ids); + // 删除 + demo03GradeErpMapper.deleteByIds(ids); + } + + @Override + public Demo03GradeDO getDemo03Grade(Long id) { + return demo03GradeErpMapper.selectById(id); + } + + private void validateDemo03GradeExists(Long id) { + if (demo03GradeErpMapper.selectById(id) == null) { + throw exception(DEMO03_GRADE_NOT_EXISTS); + } + } + + private void validateDemo03GradeExists(List ids) { + List list = demo03GradeErpMapper.selectByIds(ids); + if (CollUtil.isEmpty(list) || list.size() != ids.size()) { + throw exception(DEMO03_GRADE_NOT_EXISTS); + } + } + + private void deleteDemo03GradeByStudentId(Long studentId) { + demo03GradeErpMapper.deleteByStudentId(studentId); + } + + private void deleteDemo03GradeByStudentIds(List studentIds) { + demo03GradeErpMapper.deleteByStudentIds(studentIds); + } + +} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentService.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentService.java deleted file mode 100644 index e4c97c6..0000000 --- a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentService.java +++ /dev/null @@ -1,160 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo.demo03.erp; - -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.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 学生 Service 接口 - * - * @author 芋道源码 - */ -public interface Demo03StudentService { - - /** - * 创建学生 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDemo03Student(@Valid Demo03StudentSaveReqVO createReqVO); - - /** - * 更新学生 - * - * @param updateReqVO 更新信息 - */ - void updateDemo03Student(@Valid Demo03StudentSaveReqVO updateReqVO); - - /** - * 删除学生 - * - * @param id 编号 - */ - void deleteDemo03Student(Long id); - - /** - * 批量删除学生 - * - * @param ids 编号 - */ - void deleteDemo03StudentByIds(List ids); - - /** - * 获得学生 - * - * @param id 编号 - * @return 学生 - */ - Demo03StudentDO getDemo03Student(Long id); - - /** - * 获得学生分页 - * - * @param pageReqVO 分页查询 - * @return 学生分页 - */ - PageResult getDemo03StudentPage(Demo03StudentPageReqVO pageReqVO); - - // ==================== 子表(学生课程) ==================== - - /** - * 获得学生课程分页 - * - * @param pageReqVO 分页查询 - * @param studentId 学生编号 - * @return 学生课程分页 - */ - PageResult getDemo03CoursePage(PageParam pageReqVO, Long studentId); - - /** - * 创建学生课程 - * - * @param demo03Course 创建信息 - * @return 编号 - */ - Long createDemo03Course(@Valid Demo03CourseDO demo03Course); - - /** - * 更新学生课程 - * - * @param demo03Course 更新信息 - */ - void updateDemo03Course(@Valid Demo03CourseDO demo03Course); - - /** - * 删除学生课程 - * - * @param id 编号 - */ - void deleteDemo03Course(Long id); - - /** - * 批量删除学生课程 - * - * @param ids 编号 - */ - void deleteDemo03CourseByIds(List ids); - - /** - * 获得学生课程 - * - * @param id 编号 - * @return 学生课程 - */ - Demo03CourseDO getDemo03Course(Long id); - - // ==================== 子表(学生班级) ==================== - - /** - * 获得学生班级分页 - * - * @param pageReqVO 分页查询 - * @param studentId 学生编号 - * @return 学生班级分页 - */ - PageResult getDemo03GradePage(PageParam pageReqVO, Long studentId); - - /** - * 创建学生班级 - * - * @param demo03Grade 创建信息 - * @return 编号 - */ - Long createDemo03Grade(@Valid Demo03GradeDO demo03Grade); - - /** - * 更新学生班级 - * - * @param demo03Grade 更新信息 - */ - void updateDemo03Grade(@Valid Demo03GradeDO demo03Grade); - - /** - * 删除学生班级 - * - * @param id 编号 - */ - void deleteDemo03Grade(Long id); - - /** - * 批量删除学生班级 - * - * @param ids 编号 - */ - void deleteDemo03GradeByIds(List ids); - - /** - * 获得学生班级 - * - * @param id 编号 - * @return 学生班级 - */ - Demo03GradeDO getDemo03Grade(Long id); - -} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentServiceImpl.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentServiceImpl.java deleted file mode 100644 index a5f5eeb..0000000 --- a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentServiceImpl.java +++ /dev/null @@ -1,241 +0,0 @@ -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.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.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 java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 学生 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class Demo03StudentServiceImpl implements Demo03StudentService { - - @Resource - private Demo03StudentMapper demo03StudentMapper; - @Resource - private Demo03CourseMapper demo03CourseMapper; - @Resource - private Demo03GradeMapper demo03GradeMapper; - - @Override - public Long createDemo03Student(Demo03StudentSaveReqVO createReqVO) { - // 插入 - Demo03StudentDO demo03Student = BeanUtils.toBean(createReqVO, Demo03StudentDO.class); - demo03StudentMapper.insert(demo03Student); - // 返回 - return demo03Student.getId(); - } - - @Override - public void updateDemo03Student(Demo03StudentSaveReqVO updateReqVO) { - // 校验存在 - validateDemo03StudentExists(updateReqVO.getId()); - // 更新 - Demo03StudentDO updateObj = BeanUtils.toBean(updateReqVO, Demo03StudentDO.class); - demo03StudentMapper.updateById(updateObj); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteDemo03Student(Long id) { - // 校验存在 - validateDemo03StudentExists(id); - // 删除 - demo03StudentMapper.deleteById(id); - - // 删除子表 - deleteDemo03CourseByStudentId(id); - deleteDemo03GradeByStudentId(id); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteDemo03StudentByIds(List ids) { - // 校验存在 - validateDemo03StudentExists(ids); - // 删除 - demo03StudentMapper.deleteByIds(ids); - - // 删除子表 - deleteDemo03CourseByStudentIds(ids); - deleteDemo03GradeByStudentIds(ids); - } - - private void validateDemo03StudentExists(List ids) { - List 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); - } - } - - @Override - public Demo03StudentDO getDemo03Student(Long id) { - return demo03StudentMapper.selectById(id); - } - - @Override - public PageResult getDemo03StudentPage(Demo03StudentPageReqVO pageReqVO) { - return demo03StudentMapper.selectPage(pageReqVO); - } - - // ==================== 子表(学生课程) ==================== - - @Override - public PageResult getDemo03CoursePage(PageParam pageReqVO, Long studentId) { - return demo03CourseMapper.selectPage(pageReqVO, studentId); - } - - @Override - public Long createDemo03Course(Demo03CourseDO demo03Course) { - demo03CourseMapper.insert(demo03Course); - return demo03Course.getId(); - } - - @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 void deleteDemo03CourseByIds(List ids) { - // 校验存在 - validateDemo03CourseExists(ids); - // 删除 - demo03CourseMapper.deleteByIds(ids); - } - - @Override - public Demo03CourseDO getDemo03Course(Long id) { - return demo03CourseMapper.selectById(id); - } - - private void validateDemo03CourseExists(Long id) { - if (demo03CourseMapper.selectById(id) == null) { - throw exception(DEMO03_COURSE_NOT_EXISTS); - } - } - - private void validateDemo03CourseExists(List ids) { - List list = demo03CourseMapper.selectByIds(ids); - if (CollUtil.isEmpty(list) || list.size() != ids.size()) { - throw exception(DEMO03_COURSE_NOT_EXISTS); - } - } - - private void deleteDemo03CourseByStudentId(Long studentId) { - demo03CourseMapper.deleteByStudentId(studentId); - } - - private void deleteDemo03CourseByStudentIds(List studentIds) { - demo03CourseMapper.deleteByStudentIds(studentIds); - } - - // ==================== 子表(学生班级) ==================== - - @Override - public PageResult getDemo03GradePage(PageParam pageReqVO, Long studentId) { - return demo03GradeMapper.selectPage(pageReqVO, studentId); - } - - @Override - public Long createDemo03Grade(Demo03GradeDO demo03Grade) { - // 校验是否已经存在 - if (demo03GradeMapper.selectByStudentId(demo03Grade.getStudentId()) != null) { - throw exception(DEMO03_GRADE_EXISTS); - } - // 插入 - demo03GradeMapper.insert(demo03Grade); - return demo03Grade.getId(); - } - - @Override - public void updateDemo03Grade(Demo03GradeDO demo03Grade) { - // 校验存在 - validateDemo03GradeExists(demo03Grade.getId()); - // 更新 - demo03Grade.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 - demo03GradeMapper.updateById(demo03Grade); - } - - @Override - public void deleteDemo03Grade(Long id) { - // 校验存在 - validateDemo03GradeExists(id); - // 删除 - demo03GradeMapper.deleteById(id); - } - - @Override - public void deleteDemo03GradeByIds(List ids) { - // 校验存在 - validateDemo03GradeExists(ids); - // 删除 - demo03GradeMapper.deleteByIds(ids); - } - - @Override - public Demo03GradeDO getDemo03Grade(Long id) { - return demo03GradeMapper.selectById(id); - } - - private void validateDemo03GradeExists(Long id) { - if (demo03GradeMapper.selectById(id) == null) { - throw exception(DEMO03_GRADE_NOT_EXISTS); - } - } - - private void validateDemo03GradeExists(List ids) { - List 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 studentIds) { - demo03GradeMapper.deleteByStudentIds(studentIds); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/normal/Demo03StudentNormalService.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/normal/Demo03StudentNormalService.java new file mode 100644 index 0000000..c38b9ed --- /dev/null +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/normal/Demo03StudentNormalService.java @@ -0,0 +1,83 @@ +package cn.iocoder.yudao.module.infra.service.demo.demo03.normal; + +import java.util.*; +import jakarta.validation.*; +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.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.framework.common.pojo.PageResult; + +/** + * 学生 Service 接口 + * + * @author 芋道源码 + */ +public interface Demo03StudentNormalService { + + /** + * 创建学生 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createDemo03Student(@Valid Demo03StudentNormalSaveReqVO createReqVO); + + /** + * 更新学生 + * + * @param updateReqVO 更新信息 + */ + void updateDemo03Student(@Valid Demo03StudentNormalSaveReqVO updateReqVO); + + /** + * 删除学生 + * + * @param id 编号 + */ + void deleteDemo03Student(Long id); + + /** + * 批量删除学生 + * + * @param ids 编号 + */ + void deleteDemo03StudentByIds(List ids); + + /** + * 获得学生 + * + * @param id 编号 + * @return 学生 + */ + Demo03StudentDO getDemo03Student(Long id); + + /** + * 获得学生分页 + * + * @param pageReqVO 分页查询 + * @return 学生分页 + */ + PageResult getDemo03StudentPage(Demo03StudentNormalPageReqVO pageReqVO); + + // ==================== 子表(学生课程) ==================== + + /** + * 获得学生课程列表 + * + * @param studentId 学生编号 + * @return 学生课程列表 + */ + List getDemo03CourseListByStudentId(Long studentId); + + // ==================== 子表(学生班级) ==================== + + /** + * 获得学生班级 + * + * @param studentId 学生编号 + * @return 学生班级 + */ + Demo03GradeDO getDemo03GradeByStudentId(Long studentId); + +} \ No newline at end of file diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/normal/Demo03StudentNormalServiceImpl.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/normal/Demo03StudentNormalServiceImpl.java new file mode 100644 index 0000000..cac883d --- /dev/null +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/normal/Demo03StudentNormalServiceImpl.java @@ -0,0 +1,175 @@ +package cn.iocoder.yudao.module.infra.service.demo.demo03.normal; + +import cn.hutool.core.collection.CollUtil; +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.normal.vo.Demo03StudentNormalPageReqVO; +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo.Demo03StudentNormalSaveReqVO; +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.normal.Demo03CourseNormalMapper; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.normal.Demo03GradeNormalMapper; +import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.normal.Demo03StudentNormalMapper; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; + +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.DEMO03_STUDENT_NOT_EXISTS; + +/** + * 学生 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class Demo03StudentNormalServiceImpl implements Demo03StudentNormalService { + + @Resource + private Demo03StudentNormalMapper demo03StudentNormalMapper; + @Resource + private Demo03CourseNormalMapper demo03CourseNormalMapper; + @Resource + private Demo03GradeNormalMapper demo03GradeNormalMapper; + + @Override + @Transactional(rollbackFor = Exception.class) + public Long createDemo03Student(Demo03StudentNormalSaveReqVO createReqVO) { + // 插入 + Demo03StudentDO demo03Student = BeanUtils.toBean(createReqVO, Demo03StudentDO.class); + demo03StudentNormalMapper.insert(demo03Student); + + // 插入子表 + createDemo03CourseList(demo03Student.getId(), createReqVO.getDemo03Courses()); + createDemo03Grade(demo03Student.getId(), createReqVO.getDemo03Grade()); + // 返回 + return demo03Student.getId(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateDemo03Student(Demo03StudentNormalSaveReqVO updateReqVO) { + // 校验存在 + validateDemo03StudentExists(updateReqVO.getId()); + // 更新 + Demo03StudentDO updateObj = BeanUtils.toBean(updateReqVO, Demo03StudentDO.class); + demo03StudentNormalMapper.updateById(updateObj); + + // 更新子表 + updateDemo03CourseList(updateReqVO.getId(), updateReqVO.getDemo03Courses()); + updateDemo03Grade(updateReqVO.getId(), updateReqVO.getDemo03Grade()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteDemo03Student(Long id) { + // 校验存在 + validateDemo03StudentExists(id); + // 删除 + demo03StudentNormalMapper.deleteById(id); + + // 删除子表 + deleteDemo03CourseByStudentId(id); + deleteDemo03GradeByStudentId(id); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteDemo03StudentByIds(List ids) { + // 校验存在 + validateDemo03StudentExists(ids); + // 删除 + demo03StudentNormalMapper.deleteByIds(ids); + + // 删除子表 + deleteDemo03CourseByStudentIds(ids); + deleteDemo03GradeByStudentIds(ids); + } + + private void validateDemo03StudentExists(List ids) { + List list = demo03StudentNormalMapper.selectByIds(ids); + if (CollUtil.isEmpty(list) || list.size() != ids.size()) { + throw exception(DEMO03_STUDENT_NOT_EXISTS); + } + } + + private void validateDemo03StudentExists(Long id) { + if (demo03StudentNormalMapper.selectById(id) == null) { + throw exception(DEMO03_STUDENT_NOT_EXISTS); + } + } + + @Override + public Demo03StudentDO getDemo03Student(Long id) { + return demo03StudentNormalMapper.selectById(id); + } + + @Override + public PageResult getDemo03StudentPage(Demo03StudentNormalPageReqVO pageReqVO) { + return demo03StudentNormalMapper.selectPage(pageReqVO); + } + + // ==================== 子表(学生课程) ==================== + + @Override + public List getDemo03CourseListByStudentId(Long studentId) { + return demo03CourseNormalMapper.selectListByStudentId(studentId); + } + + private void createDemo03CourseList(Long studentId, List list) { + list.forEach(o -> o.setStudentId(studentId)); + demo03CourseNormalMapper.insertBatch(list); + } + + private void updateDemo03CourseList(Long studentId, List 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) { + demo03CourseNormalMapper.deleteByStudentId(studentId); + } + + private void deleteDemo03CourseByStudentIds(List studentIds) { + demo03CourseNormalMapper.deleteByStudentIds(studentIds); + } + + // ==================== 子表(学生班级) ==================== + + @Override + public Demo03GradeDO getDemo03GradeByStudentId(Long studentId) { + return demo03GradeNormalMapper.selectByStudentId(studentId); + } + + private void createDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) { + if (demo03Grade == null) { + return; + } + demo03Grade.setStudentId(studentId); + demo03GradeNormalMapper.insert(demo03Grade); + } + + private void updateDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) { + if (demo03Grade == null) { + return; + } + demo03Grade.setStudentId(studentId); + demo03Grade.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 + demo03GradeNormalMapper.insertOrUpdate(demo03Grade); + } + + private void deleteDemo03GradeByStudentId(Long studentId) { + demo03GradeNormalMapper.deleteByStudentId(studentId); + } + + private void deleteDemo03GradeByStudentIds(List studentIds) { + demo03GradeNormalMapper.deleteByStudentIds(studentIds); + } + +} \ No newline at end of file diff --git a/yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/index.vue.vm b/yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/index.vue.vm index c9746e4..4a4be13 100644 --- a/yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/index.vue.vm +++ b/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}) { #if ($table.templateType != 2 && $table.deleteBatch) const deleteIds = ref([]) // 待删除${table.classComment} ID const showDeleteBatchBtn = computed(() => isEmpty(deleteIds.value)); +function setDeleteIds({ + records, +}: { + records: ${simpleClassName}Api.${simpleClassName}[]; +}) { + deleteIds.value = records.map((item) => item.id); +} /** 批量删除${table.classComment} */ async function onDeleteBatch() { const hideLoading = message.loading({ @@ -205,12 +212,8 @@ const [Grid, gridApi] = useVbenVxeGrid({ }, #end #if($table.deleteBatch) - checkboxAll: ({records,}: { records: ${simpleClassName}Api.${simpleClassName}[];}) => { - deleteIds.value = records.map((item) => item.id); - }, - checkboxChange: ({records,}: { records: ${simpleClassName}Api.${simpleClassName}[];}) => { - deleteIds.value = records.map((item) => item.id); - }, + checkboxAll: setDeleteIds, + checkboxChange: setDeleteIds, #end } #end diff --git a/yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/modules/list_sub_erp.vue.vm b/yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/modules/list_sub_erp.vue.vm index d04f1ae..24c0605 100644 --- a/yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/modules/list_sub_erp.vue.vm +++ b/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}) { #if ($table.deleteBatch) const deleteIds = ref([]) // 待删除${subTable.classComment} ID const showDeleteBatchBtn = computed(() => isEmpty(deleteIds.value)); +function setDeleteIds({ + records, +}: { + records: ${simpleClassName}Api.${subSimpleClassName}[]; +}) { + deleteIds.value = records.map((item) => item.id); +} /** 批量删除${subTable.classComment} */ async function onDeleteBatch() { const hideLoading = message.loading({ @@ -159,12 +166,8 @@ function onActionClick({ } 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); - }, + checkboxAll: setDeleteIds, + checkboxChange: setDeleteIds, } #end }); -- libgit2 0.21.4