Commit a51e9645ef168f291216efa57c740b27df99cd42
1 parent
7c48aaba
代码生成:进一步完成 erp 模版
Showing
12 changed files
with
239 additions
and
80 deletions
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo12/InfraDemo12StudentController.java
| 1 | package cn.iocoder.yudao.module.infra.controller.admin.demo12; | 1 | package cn.iocoder.yudao.module.infra.controller.admin.demo12; |
| 2 | 2 | ||
| 3 | -import org.springframework.web.bind.annotation.*; | ||
| 4 | -import javax.annotation.Resource; | ||
| 5 | -import org.springframework.validation.annotation.Validated; | ||
| 6 | -import org.springframework.security.access.prepost.PreAuthorize; | ||
| 7 | -import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 8 | -import io.swagger.v3.oas.annotations.Parameter; | ||
| 9 | -import io.swagger.v3.oas.annotations.Operation; | ||
| 10 | - | ||
| 11 | -import javax.validation.constraints.*; | ||
| 12 | -import javax.validation.*; | ||
| 13 | -import javax.servlet.http.*; | ||
| 14 | -import java.util.*; | ||
| 15 | -import java.io.IOException; | ||
| 16 | - | ||
| 17 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 18 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 19 | -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 20 | - | 4 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 21 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | 6 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 22 | - | ||
| 23 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | 7 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 24 | -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | ||
| 25 | - | ||
| 26 | import cn.iocoder.yudao.module.infra.controller.admin.demo12.vo.*; | 8 | import cn.iocoder.yudao.module.infra.controller.admin.demo12.vo.*; |
| 27 | -import cn.iocoder.yudao.module.infra.dal.dataobject.demo12.InfraDemo12StudentDO; | 9 | +import cn.iocoder.yudao.module.infra.convert.demo12.InfraDemo12StudentConvert; |
| 28 | import cn.iocoder.yudao.module.infra.dal.dataobject.demo12.InfraDemo12StudentContactDO; | 10 | import cn.iocoder.yudao.module.infra.dal.dataobject.demo12.InfraDemo12StudentContactDO; |
| 11 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo12.InfraDemo12StudentDO; | ||
| 29 | import cn.iocoder.yudao.module.infra.dal.dataobject.demo12.InfraDemo12StudentTeacherDO; | 12 | import cn.iocoder.yudao.module.infra.dal.dataobject.demo12.InfraDemo12StudentTeacherDO; |
| 30 | -import cn.iocoder.yudao.module.infra.convert.demo12.InfraDemo12StudentConvert; | ||
| 31 | import cn.iocoder.yudao.module.infra.service.demo12.InfraDemo12StudentService; | 13 | import cn.iocoder.yudao.module.infra.service.demo12.InfraDemo12StudentService; |
| 14 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 15 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 16 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 17 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 18 | +import org.springframework.validation.annotation.Validated; | ||
| 19 | +import org.springframework.web.bind.annotation.*; | ||
| 20 | + | ||
| 21 | +import javax.annotation.Resource; | ||
| 22 | +import javax.servlet.http.HttpServletResponse; | ||
| 23 | +import javax.validation.Valid; | ||
| 24 | +import java.io.IOException; | ||
| 25 | +import java.util.List; | ||
| 26 | + | ||
| 27 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 28 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | ||
| 32 | 29 | ||
| 33 | @Tag(name = "管理后台 - 学生") | 30 | @Tag(name = "管理后台 - 学生") |
| 34 | @RestController | 31 | @RestController |
| @@ -94,22 +91,88 @@ public class InfraDemo12StudentController { | @@ -94,22 +91,88 @@ public class InfraDemo12StudentController { | ||
| 94 | 91 | ||
| 95 | // ==================== 子表(学生联系人) ==================== | 92 | // ==================== 子表(学生联系人) ==================== |
| 96 | 93 | ||
| 97 | - @GetMapping("/demo12-student/list-by-student-id") | ||
| 98 | - @Operation(summary = "获得学生联系人列表") | 94 | + @GetMapping("/demo12-student-contact/page") |
| 95 | + @Operation(summary = "获得学生联系人分页") | ||
| 99 | @Parameter(name = "studentId", description = "学生编号") | 96 | @Parameter(name = "studentId", description = "学生编号") |
| 100 | @PreAuthorize("@ss.hasPermission('infra:demo12-student:query')") | 97 | @PreAuthorize("@ss.hasPermission('infra:demo12-student:query')") |
| 101 | - public CommonResult<List<InfraDemo12StudentContactDO>> getDemo12StudentContactListByStudentId(@RequestParam("studentId") Long studentId) { | ||
| 102 | - return success(demo12StudentService.getDemo12StudentContactListByStudentId(studentId)); | 98 | + public CommonResult<PageResult<InfraDemo12StudentContactDO>> getDemo12StudentContactPage(PageParam pageReqVO, |
| 99 | + @RequestParam("studentId") Long studentId) { | ||
| 100 | + return success(demo12StudentService.getDemo12StudentContactPage(pageReqVO, studentId)); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + @PostMapping("/demo12-student-contact/create") | ||
| 104 | + @Operation(summary = "创建学生联系人") | ||
| 105 | + @PreAuthorize("@ss.hasPermission('infra:demo12-student:create')") | ||
| 106 | + public CommonResult<Long> createDemo12StudentContact(@Valid @RequestBody InfraDemo12StudentContactDO demo12StudentContact) { | ||
| 107 | + return success(demo12StudentService.createDemo12StudentContact(demo12StudentContact)); | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + @PutMapping("/demo12-student-contact/update") | ||
| 111 | + @Operation(summary = "更新学生联系人") | ||
| 112 | + @PreAuthorize("@ss.hasPermission('infra:demo12-student:update')") | ||
| 113 | + public CommonResult<Boolean> updateDemo12StudentContact(@Valid @RequestBody InfraDemo12StudentContactDO demo12StudentContact) { | ||
| 114 | + demo12StudentService.updateDemo12StudentContact(demo12StudentContact); | ||
| 115 | + return success(true); | ||
| 103 | } | 116 | } |
| 104 | 117 | ||
| 118 | + @DeleteMapping("/demo12-student-contact/delete") | ||
| 119 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 120 | + @Operation(summary = "删除学生联系人") | ||
| 121 | + @PreAuthorize("@ss.hasPermission('infra:demo12-student:delete')") | ||
| 122 | + public CommonResult<Boolean> deleteDemo12StudentContact(@RequestParam("id") Long id) { | ||
| 123 | + demo12StudentService.deleteDemo12StudentContact(id); | ||
| 124 | + return success(true); | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + @GetMapping("/demo12-student-contact/get") | ||
| 128 | + @Operation(summary = "获得学生联系人") | ||
| 129 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 130 | + @PreAuthorize("@ss.hasPermission('infra:demo12-student:query')") | ||
| 131 | + public CommonResult<InfraDemo12StudentContactDO> getDemo12StudentContact(@RequestParam("id") Long id) { | ||
| 132 | + return success(demo12StudentService.getDemo12StudentContact(id)); | ||
| 133 | + } | ||
| 134 | + | ||
| 105 | // ==================== 子表(学生班主任) ==================== | 135 | // ==================== 子表(学生班主任) ==================== |
| 106 | 136 | ||
| 107 | - @GetMapping("/demo12-student/get-by-student-id") | ||
| 108 | - @Operation(summary = "获得学生班主任") | 137 | + @GetMapping("/demo12-student-teacher/page") |
| 138 | + @Operation(summary = "获得学生班主任分页") | ||
| 109 | @Parameter(name = "studentId", description = "学生编号") | 139 | @Parameter(name = "studentId", description = "学生编号") |
| 110 | @PreAuthorize("@ss.hasPermission('infra:demo12-student:query')") | 140 | @PreAuthorize("@ss.hasPermission('infra:demo12-student:query')") |
| 111 | - public CommonResult<InfraDemo12StudentTeacherDO> getDemo12StudentTeacherByStudentId(@RequestParam("studentId") Long studentId) { | ||
| 112 | - return success(demo12StudentService.getDemo12StudentTeacherByStudentId(studentId)); | 141 | + public CommonResult<PageResult<InfraDemo12StudentTeacherDO>> getDemo12StudentTeacherPage(PageParam pageReqVO, |
| 142 | + @RequestParam("studentId") Long studentId) { | ||
| 143 | + return success(demo12StudentService.getDemo12StudentTeacherPage(pageReqVO, studentId)); | ||
| 113 | } | 144 | } |
| 114 | 145 | ||
| 146 | + @PostMapping("/demo12-student-teacher/create") | ||
| 147 | + @Operation(summary = "创建学生班主任") | ||
| 148 | + @PreAuthorize("@ss.hasPermission('infra:demo12-student:create')") | ||
| 149 | + public CommonResult<Long> createDemo12StudentTeacher(@Valid @RequestBody InfraDemo12StudentTeacherDO demo12StudentTeacher) { | ||
| 150 | + return success(demo12StudentService.createDemo12StudentTeacher(demo12StudentTeacher)); | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + @PutMapping("/demo12-student-teacher/update") | ||
| 154 | + @Operation(summary = "更新学生班主任") | ||
| 155 | + @PreAuthorize("@ss.hasPermission('infra:demo12-student:update')") | ||
| 156 | + public CommonResult<Boolean> updateDemo12StudentTeacher(@Valid @RequestBody InfraDemo12StudentTeacherDO demo12StudentTeacher) { | ||
| 157 | + demo12StudentService.updateDemo12StudentTeacher(demo12StudentTeacher); | ||
| 158 | + return success(true); | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + @DeleteMapping("/demo12-student-teacher/delete") | ||
| 162 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 163 | + @Operation(summary = "删除学生班主任") | ||
| 164 | + @PreAuthorize("@ss.hasPermission('infra:demo12-student:delete')") | ||
| 165 | + public CommonResult<Boolean> deleteDemo12StudentTeacher(@RequestParam("id") Long id) { | ||
| 166 | + demo12StudentService.deleteDemo12StudentTeacher(id); | ||
| 167 | + return success(true); | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + @GetMapping("/demo12-student-teacher/get") | ||
| 171 | + @Operation(summary = "获得学生班主任") | ||
| 172 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 173 | + @PreAuthorize("@ss.hasPermission('infra:demo12-student:query')") | ||
| 174 | + public CommonResult<InfraDemo12StudentTeacherDO> getDemo12StudentTeacher(@RequestParam("id") Long id) { | ||
| 175 | + return success(demo12StudentService.getDemo12StudentTeacher(id)); | ||
| 176 | + } | ||
| 177 | + | ||
| 115 | } | 178 | } |
| 116 | \ No newline at end of file | 179 | \ No newline at end of file |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo12/vo/InfraDemo12StudentBaseVO.java
| @@ -50,8 +50,4 @@ public class InfraDemo12StudentBaseVO { | @@ -50,8 +50,4 @@ public class InfraDemo12StudentBaseVO { | ||
| 50 | @NotEmpty(message = "备注不能为空") | 50 | @NotEmpty(message = "备注不能为空") |
| 51 | private String memo; | 51 | private String memo; |
| 52 | 52 | ||
| 53 | - private List<InfraDemo12StudentContactDO> demo12StudentContacts; | ||
| 54 | - | ||
| 55 | - private InfraDemo12StudentTeacherDO demo12StudentTeacher; | ||
| 56 | - | ||
| 57 | } | 53 | } |
| 58 | \ No newline at end of file | 54 | \ No newline at end of file |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo12/InfraDemo12StudentContactMapper.java
| @@ -17,8 +17,10 @@ import org.apache.ibatis.annotations.Mapper; | @@ -17,8 +17,10 @@ import org.apache.ibatis.annotations.Mapper; | ||
| 17 | @Mapper | 17 | @Mapper |
| 18 | public interface InfraDemo12StudentContactMapper extends BaseMapperX<InfraDemo12StudentContactDO> { | 18 | public interface InfraDemo12StudentContactMapper extends BaseMapperX<InfraDemo12StudentContactDO> { |
| 19 | 19 | ||
| 20 | - default List<InfraDemo12StudentContactDO> selectListByStudentId(Long studentId) { | ||
| 21 | - return selectList(InfraDemo12StudentContactDO::getStudentId, studentId); | 20 | + default PageResult<InfraDemo12StudentContactDO> selectPage(PageParam reqVO, Long studentId) { |
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<InfraDemo12StudentContactDO>() | ||
| 22 | + .eq(InfraDemo12StudentContactDO::getStudentId, studentId) | ||
| 23 | + .orderByDesc(InfraDemo12StudentContactDO::getId)); | ||
| 22 | } | 24 | } |
| 23 | 25 | ||
| 24 | default int deleteByStudentId(Long studentId) { | 26 | default int deleteByStudentId(Long studentId) { |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo12/InfraDemo12StudentTeacherMapper.java
| @@ -17,8 +17,10 @@ import org.apache.ibatis.annotations.Mapper; | @@ -17,8 +17,10 @@ import org.apache.ibatis.annotations.Mapper; | ||
| 17 | @Mapper | 17 | @Mapper |
| 18 | public interface InfraDemo12StudentTeacherMapper extends BaseMapperX<InfraDemo12StudentTeacherDO> { | 18 | public interface InfraDemo12StudentTeacherMapper extends BaseMapperX<InfraDemo12StudentTeacherDO> { |
| 19 | 19 | ||
| 20 | - default InfraDemo12StudentTeacherDO selectByStudentId(Long studentId) { | ||
| 21 | - return selectOne(InfraDemo12StudentTeacherDO::getStudentId, studentId); | 20 | + default PageResult<InfraDemo12StudentTeacherDO> selectPage(PageParam reqVO, Long studentId) { |
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<InfraDemo12StudentTeacherDO>() | ||
| 22 | + .eq(InfraDemo12StudentTeacherDO::getStudentId, studentId) | ||
| 23 | + .orderByDesc(InfraDemo12StudentTeacherDO::getId)); | ||
| 22 | } | 24 | } |
| 23 | 25 | ||
| 24 | default int deleteByStudentId(Long studentId) { | 26 | default int deleteByStudentId(Long studentId) { |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo12/InfraDemo12StudentService.java
| @@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.demo12.InfraDemo12StudentDO; | @@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.demo12.InfraDemo12StudentDO; | ||
| 7 | import cn.iocoder.yudao.module.infra.dal.dataobject.demo12.InfraDemo12StudentContactDO; | 7 | import cn.iocoder.yudao.module.infra.dal.dataobject.demo12.InfraDemo12StudentContactDO; |
| 8 | import cn.iocoder.yudao.module.infra.dal.dataobject.demo12.InfraDemo12StudentTeacherDO; | 8 | import cn.iocoder.yudao.module.infra.dal.dataobject.demo12.InfraDemo12StudentTeacherDO; |
| 9 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 9 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 10 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 10 | 11 | ||
| 11 | /** | 12 | /** |
| 12 | * 学生 Service 接口 | 13 | * 学生 Service 接口 |
| @@ -65,22 +66,84 @@ public interface InfraDemo12StudentService { | @@ -65,22 +66,84 @@ public interface InfraDemo12StudentService { | ||
| 65 | // ==================== 子表(学生联系人) ==================== | 66 | // ==================== 子表(学生联系人) ==================== |
| 66 | 67 | ||
| 67 | /** | 68 | /** |
| 68 | - * 获得学生联系人列表 | 69 | + * 获得学生联系人分页 |
| 69 | * | 70 | * |
| 71 | + * @param pageReqVO 分页查询 | ||
| 70 | * @param studentId 学生编号 | 72 | * @param studentId 学生编号 |
| 71 | - * @return 学生联系人列表 | 73 | + * @return 学生联系人分页 |
| 72 | */ | 74 | */ |
| 73 | - List<InfraDemo12StudentContactDO> getDemo12StudentContactListByStudentId(Long studentId); | 75 | + PageResult<InfraDemo12StudentContactDO> getDemo12StudentContactPage(PageParam pageReqVO, Long studentId); |
| 76 | + | ||
| 77 | + /** | ||
| 78 | + * 创建学生联系人 | ||
| 79 | + * | ||
| 80 | + * @param demo12StudentContact 创建信息 | ||
| 81 | + * @return 编号 | ||
| 82 | + */ | ||
| 83 | + Long createDemo12StudentContact(@Valid InfraDemo12StudentContactDO demo12StudentContact); | ||
| 84 | + | ||
| 85 | + /** | ||
| 86 | + * 更新学生联系人 | ||
| 87 | + * | ||
| 88 | + * @param demo12StudentContact 更新信息 | ||
| 89 | + */ | ||
| 90 | + void updateDemo12StudentContact(@Valid InfraDemo12StudentContactDO demo12StudentContact); | ||
| 91 | + | ||
| 92 | + /** | ||
| 93 | + * 删除学生联系人 | ||
| 94 | + * | ||
| 95 | + * @param id 编号 | ||
| 96 | + */ | ||
| 97 | + void deleteDemo12StudentContact(Long id); | ||
| 98 | + | ||
| 99 | + /** | ||
| 100 | + * 获得学生联系人 | ||
| 101 | + * | ||
| 102 | + * @param id 编号 | ||
| 103 | + * @return 学生联系人 | ||
| 104 | + */ | ||
| 105 | + InfraDemo12StudentContactDO getDemo12StudentContact(Long id); | ||
| 74 | 106 | ||
| 75 | 107 | ||
| 76 | // ==================== 子表(学生班主任) ==================== | 108 | // ==================== 子表(学生班主任) ==================== |
| 77 | 109 | ||
| 78 | /** | 110 | /** |
| 79 | - * 获得学生班主任 | 111 | + * 获得学生班主任分页 |
| 80 | * | 112 | * |
| 113 | + * @param pageReqVO 分页查询 | ||
| 81 | * @param studentId 学生编号 | 114 | * @param studentId 学生编号 |
| 82 | - * @return 学生班主任 | 115 | + * @return 学生班主任分页 |
| 83 | */ | 116 | */ |
| 84 | - InfraDemo12StudentTeacherDO getDemo12StudentTeacherByStudentId(Long studentId); | 117 | + PageResult<InfraDemo12StudentTeacherDO> getDemo12StudentTeacherPage(PageParam pageReqVO, Long studentId); |
| 118 | + | ||
| 119 | + /** | ||
| 120 | + * 创建学生班主任 | ||
| 121 | + * | ||
| 122 | + * @param demo12StudentTeacher 创建信息 | ||
| 123 | + * @return 编号 | ||
| 124 | + */ | ||
| 125 | + Long createDemo12StudentTeacher(@Valid InfraDemo12StudentTeacherDO demo12StudentTeacher); | ||
| 126 | + | ||
| 127 | + /** | ||
| 128 | + * 更新学生班主任 | ||
| 129 | + * | ||
| 130 | + * @param demo12StudentTeacher 更新信息 | ||
| 131 | + */ | ||
| 132 | + void updateDemo12StudentTeacher(@Valid InfraDemo12StudentTeacherDO demo12StudentTeacher); | ||
| 133 | + | ||
| 134 | + /** | ||
| 135 | + * 删除学生班主任 | ||
| 136 | + * | ||
| 137 | + * @param id 编号 | ||
| 138 | + */ | ||
| 139 | + void deleteDemo12StudentTeacher(Long id); | ||
| 140 | + | ||
| 141 | + /** | ||
| 142 | + * 获得学生班主任 | ||
| 143 | + * | ||
| 144 | + * @param id 编号 | ||
| 145 | + * @return 学生班主任 | ||
| 146 | + */ | ||
| 147 | + InfraDemo12StudentTeacherDO getDemo12StudentTeacher(Long id); | ||
| 85 | 148 | ||
| 86 | } | 149 | } |
| 87 | \ No newline at end of file | 150 | \ No newline at end of file |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo12/InfraDemo12StudentServiceImpl.java
| @@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.demo12.InfraDemo12StudentDO; | @@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.demo12.InfraDemo12StudentDO; | ||
| 11 | import cn.iocoder.yudao.module.infra.dal.dataobject.demo12.InfraDemo12StudentContactDO; | 11 | import cn.iocoder.yudao.module.infra.dal.dataobject.demo12.InfraDemo12StudentContactDO; |
| 12 | import cn.iocoder.yudao.module.infra.dal.dataobject.demo12.InfraDemo12StudentTeacherDO; | 12 | import cn.iocoder.yudao.module.infra.dal.dataobject.demo12.InfraDemo12StudentTeacherDO; |
| 13 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 13 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 14 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 14 | 15 | ||
| 15 | import cn.iocoder.yudao.module.infra.convert.demo12.InfraDemo12StudentConvert; | 16 | import cn.iocoder.yudao.module.infra.convert.demo12.InfraDemo12StudentConvert; |
| 16 | import cn.iocoder.yudao.module.infra.dal.mysql.demo12.InfraDemo12StudentMapper; | 17 | import cn.iocoder.yudao.module.infra.dal.mysql.demo12.InfraDemo12StudentMapper; |
| @@ -37,31 +38,21 @@ public class InfraDemo12StudentServiceImpl implements InfraDemo12StudentService | @@ -37,31 +38,21 @@ public class InfraDemo12StudentServiceImpl implements InfraDemo12StudentService | ||
| 37 | private InfraDemo12StudentTeacherMapper demo12StudentTeacherMapper; | 38 | private InfraDemo12StudentTeacherMapper demo12StudentTeacherMapper; |
| 38 | 39 | ||
| 39 | @Override | 40 | @Override |
| 40 | - @Transactional(rollbackFor = Exception.class) | ||
| 41 | public Long createDemo12Student(InfraDemo12StudentCreateReqVO createReqVO) { | 41 | public Long createDemo12Student(InfraDemo12StudentCreateReqVO createReqVO) { |
| 42 | // 插入 | 42 | // 插入 |
| 43 | InfraDemo12StudentDO demo12Student = InfraDemo12StudentConvert.INSTANCE.convert(createReqVO); | 43 | InfraDemo12StudentDO demo12Student = InfraDemo12StudentConvert.INSTANCE.convert(createReqVO); |
| 44 | demo12StudentMapper.insert(demo12Student); | 44 | demo12StudentMapper.insert(demo12Student); |
| 45 | - | ||
| 46 | - // 插入子表 | ||
| 47 | - createDemo12StudentContactList(demo12Student.getId(), createReqVO.getDemo12StudentContacts()); | ||
| 48 | - createDemo12StudentTeacher(demo12Student.getId(), createReqVO.getDemo12StudentTeacher()); | ||
| 49 | // 返回 | 45 | // 返回 |
| 50 | return demo12Student.getId(); | 46 | return demo12Student.getId(); |
| 51 | } | 47 | } |
| 52 | 48 | ||
| 53 | @Override | 49 | @Override |
| 54 | - @Transactional(rollbackFor = Exception.class) | ||
| 55 | public void updateDemo12Student(InfraDemo12StudentUpdateReqVO updateReqVO) { | 50 | public void updateDemo12Student(InfraDemo12StudentUpdateReqVO updateReqVO) { |
| 56 | // 校验存在 | 51 | // 校验存在 |
| 57 | validateDemo12StudentExists(updateReqVO.getId()); | 52 | validateDemo12StudentExists(updateReqVO.getId()); |
| 58 | // 更新 | 53 | // 更新 |
| 59 | InfraDemo12StudentDO updateObj = InfraDemo12StudentConvert.INSTANCE.convert(updateReqVO); | 54 | InfraDemo12StudentDO updateObj = InfraDemo12StudentConvert.INSTANCE.convert(updateReqVO); |
| 60 | demo12StudentMapper.updateById(updateObj); | 55 | demo12StudentMapper.updateById(updateObj); |
| 61 | - | ||
| 62 | - // 更新子表 | ||
| 63 | - updateDemo12StudentContactList(updateReqVO.getId(), updateReqVO.getDemo12StudentContacts()); | ||
| 64 | - updateDemo12StudentTeacher(updateReqVO.getId(), updateReqVO.getDemo12StudentTeacher()); | ||
| 65 | } | 56 | } |
| 66 | 57 | ||
| 67 | @Override | 58 | @Override |
| @@ -101,21 +92,31 @@ public class InfraDemo12StudentServiceImpl implements InfraDemo12StudentService | @@ -101,21 +92,31 @@ public class InfraDemo12StudentServiceImpl implements InfraDemo12StudentService | ||
| 101 | // ==================== 子表(学生联系人) ==================== | 92 | // ==================== 子表(学生联系人) ==================== |
| 102 | 93 | ||
| 103 | @Override | 94 | @Override |
| 104 | - public List<InfraDemo12StudentContactDO> getDemo12StudentContactListByStudentId(Long studentId) { | ||
| 105 | - return demo12StudentContactMapper.selectListByStudentId(studentId); | 95 | + public PageResult<InfraDemo12StudentContactDO> getDemo12StudentContactPage(PageParam pageReqVO, Long studentId) { |
| 96 | + return demo12StudentContactMapper.selectPage(pageReqVO, studentId); | ||
| 106 | } | 97 | } |
| 107 | 98 | ||
| 108 | - private void createDemo12StudentContactList(Long studentId, List<InfraDemo12StudentContactDO> list) { | ||
| 109 | - list.forEach(o -> o.setStudentId(studentId)); | ||
| 110 | - demo12StudentContactMapper.insertBatch(list); | 99 | + @Override |
| 100 | + public Long createDemo12StudentContact(InfraDemo12StudentContactDO demo12StudentContact) { | ||
| 101 | + demo12StudentContactMapper.insert(demo12StudentContact); | ||
| 102 | + return demo12StudentContact.getId(); | ||
| 111 | } | 103 | } |
| 112 | 104 | ||
| 113 | - private void updateDemo12StudentContactList(Long studentId, List<InfraDemo12StudentContactDO> list) { | ||
| 114 | - deleteDemo12StudentContactByStudentId(studentId); | ||
| 115 | - list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 | ||
| 116 | - createDemo12StudentContactList(studentId, list); | 105 | + @Override |
| 106 | + public void updateDemo12StudentContact(InfraDemo12StudentContactDO demo12StudentContact) { | ||
| 107 | + demo12StudentContactMapper.updateById(demo12StudentContact); | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + @Override | ||
| 111 | + public void deleteDemo12StudentContact(Long id) { | ||
| 112 | + demo12StudentContactMapper.deleteById(id); | ||
| 117 | } | 113 | } |
| 118 | 114 | ||
| 115 | + @Override | ||
| 116 | + public InfraDemo12StudentContactDO getDemo12StudentContact(Long id) { | ||
| 117 | + return demo12StudentContactMapper.selectById(id); | ||
| 118 | + } | ||
| 119 | + | ||
| 119 | private void deleteDemo12StudentContactByStudentId(Long studentId) { | 120 | private void deleteDemo12StudentContactByStudentId(Long studentId) { |
| 120 | demo12StudentContactMapper.deleteByStudentId(studentId); | 121 | demo12StudentContactMapper.deleteByStudentId(studentId); |
| 121 | } | 122 | } |
| @@ -123,27 +124,31 @@ public class InfraDemo12StudentServiceImpl implements InfraDemo12StudentService | @@ -123,27 +124,31 @@ public class InfraDemo12StudentServiceImpl implements InfraDemo12StudentService | ||
| 123 | // ==================== 子表(学生班主任) ==================== | 124 | // ==================== 子表(学生班主任) ==================== |
| 124 | 125 | ||
| 125 | @Override | 126 | @Override |
| 126 | - public InfraDemo12StudentTeacherDO getDemo12StudentTeacherByStudentId(Long studentId) { | ||
| 127 | - return demo12StudentTeacherMapper.selectByStudentId(studentId); | 127 | + public PageResult<InfraDemo12StudentTeacherDO> getDemo12StudentTeacherPage(PageParam pageReqVO, Long studentId) { |
| 128 | + return demo12StudentTeacherMapper.selectPage(pageReqVO, studentId); | ||
| 128 | } | 129 | } |
| 129 | 130 | ||
| 130 | - private void createDemo12StudentTeacher(Long studentId, InfraDemo12StudentTeacherDO demo12StudentTeacher) { | ||
| 131 | - if (demo12StudentTeacher == null) { | ||
| 132 | - return; | ||
| 133 | - } | ||
| 134 | - demo12StudentTeacher.setStudentId(studentId); | 131 | + @Override |
| 132 | + public Long createDemo12StudentTeacher(InfraDemo12StudentTeacherDO demo12StudentTeacher) { | ||
| 135 | demo12StudentTeacherMapper.insert(demo12StudentTeacher); | 133 | demo12StudentTeacherMapper.insert(demo12StudentTeacher); |
| 134 | + return demo12StudentTeacher.getId(); | ||
| 136 | } | 135 | } |
| 137 | 136 | ||
| 138 | - private void updateDemo12StudentTeacher(Long studentId, InfraDemo12StudentTeacherDO demo12StudentTeacher) { | ||
| 139 | - if (demo12StudentTeacher == null) { | ||
| 140 | - return; | ||
| 141 | - } | ||
| 142 | - demo12StudentTeacher.setStudentId(studentId); | ||
| 143 | - demo12StudentTeacher.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 | ||
| 144 | - demo12StudentTeacherMapper.insertOrUpdate(demo12StudentTeacher); | 137 | + @Override |
| 138 | + public void updateDemo12StudentTeacher(InfraDemo12StudentTeacherDO demo12StudentTeacher) { | ||
| 139 | + demo12StudentTeacherMapper.updateById(demo12StudentTeacher); | ||
| 145 | } | 140 | } |
| 146 | 141 | ||
| 142 | + @Override | ||
| 143 | + public void deleteDemo12StudentTeacher(Long id) { | ||
| 144 | + demo12StudentTeacherMapper.deleteById(id); | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + @Override | ||
| 148 | + public InfraDemo12StudentTeacherDO getDemo12StudentTeacher(Long id) { | ||
| 149 | + return demo12StudentTeacherMapper.selectById(id); | ||
| 150 | + } | ||
| 151 | + | ||
| 147 | private void deleteDemo12StudentTeacherByStudentId(Long studentId) { | 152 | private void deleteDemo12StudentTeacherByStudentId(Long studentId) { |
| 148 | demo12StudentTeacherMapper.deleteByStudentId(studentId); | 153 | demo12StudentTeacherMapper.deleteByStudentId(studentId); |
| 149 | } | 154 | } |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/controller.vm
| @@ -192,6 +192,16 @@ public class ${sceneEnum.prefixClass}${table.className}Controller { | @@ -192,6 +192,16 @@ public class ${sceneEnum.prefixClass}${table.className}Controller { | ||
| 192 | return success(true); | 192 | return success(true); |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | + @GetMapping("/${subSimpleClassName_strikeCase}/get") | ||
| 196 | + @Operation(summary = "获得${subTable.classComment}") | ||
| 197 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 198 | +#if ($sceneEnum.scene == 1) | ||
| 199 | + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')") | ||
| 200 | +#end | ||
| 201 | + public CommonResult<${subTable.className}DO> get${subSimpleClassName}(@RequestParam("id") ${subPrimaryColumn.javaType} id) { | ||
| 202 | + return success(${classNameVar}Service.get${subSimpleClassName}(id)); | ||
| 203 | + } | ||
| 204 | + | ||
| 195 | #end | 205 | #end |
| 196 | #end | 206 | #end |
| 197 | } | 207 | } |
| 198 | \ No newline at end of file | 208 | \ No newline at end of file |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/service/service.vm
| @@ -132,6 +132,14 @@ public interface ${table.className}Service { | @@ -132,6 +132,14 @@ public interface ${table.className}Service { | ||
| 132 | */ | 132 | */ |
| 133 | void delete${subSimpleClassName}(${subPrimaryColumn.javaType} id); | 133 | void delete${subSimpleClassName}(${subPrimaryColumn.javaType} id); |
| 134 | 134 | ||
| 135 | + /** | ||
| 136 | + * 获得${subTable.classComment} | ||
| 137 | + * | ||
| 138 | + * @param id 编号 | ||
| 139 | + * @return ${subTable.classComment} | ||
| 140 | + */ | ||
| 141 | + ${subTable.className}DO get${subSimpleClassName}(${subPrimaryColumn.javaType} id); | ||
| 142 | + | ||
| 135 | #end | 143 | #end |
| 136 | #end | 144 | #end |
| 137 | } | 145 | } |
| 138 | \ No newline at end of file | 146 | \ No newline at end of file |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/service/serviceImpl.vm
| @@ -198,6 +198,11 @@ public class ${table.className}ServiceImpl implements ${table.className}Service | @@ -198,6 +198,11 @@ public class ${table.className}ServiceImpl implements ${table.className}Service | ||
| 198 | ${subClassNameVars.get($index)}Mapper.deleteById(id); | 198 | ${subClassNameVars.get($index)}Mapper.deleteById(id); |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | + @Override | ||
| 202 | + public ${subTable.className}DO get${subSimpleClassName}(${subPrimaryColumn.javaType} id) { | ||
| 203 | + return ${subClassNameVars.get($index)}Mapper.selectById(id); | ||
| 204 | + } | ||
| 205 | + | ||
| 201 | ## 情况二:非 MASTER_ERP 时,支持批量的新增、修改操作 | 206 | ## 情况二:非 MASTER_ERP 时,支持批量的新增、修改操作 |
| 202 | #else | 207 | #else |
| 203 | #if ( $subTable.subJoinMany) | 208 | #if ( $subTable.subJoinMany) |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/api/api.ts.vm
| @@ -95,5 +95,10 @@ export const update${subSimpleClassName} = async (data) => { | @@ -95,5 +95,10 @@ export const update${subSimpleClassName} = async (data) => { | ||
| 95 | export const delete${subSimpleClassName} = async (id: number) => { | 95 | export const delete${subSimpleClassName} = async (id: number) => { |
| 96 | return await request.delete({ url: `${baseURL}/${subSimpleClassName_strikeCase}/delete?id=` + id }) | 96 | return await request.delete({ url: `${baseURL}/${subSimpleClassName_strikeCase}/delete?id=` + id }) |
| 97 | } | 97 | } |
| 98 | + | ||
| 99 | +// 获得${subTable.classComment} | ||
| 100 | +export const get${subSimpleClassName} = async (id: number) => { | ||
| 101 | + return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/get?id=` + id }) | ||
| 102 | +} | ||
| 98 | #end | 103 | #end |
| 99 | #end | 104 | #end |
| 100 | \ No newline at end of file | 105 | \ No newline at end of file |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/components/form_sub_erp.vue.vm
| @@ -30,7 +30,7 @@ | @@ -30,7 +30,7 @@ | ||
| 30 | <el-input v-model="formData.${javaField}" placeholder="请输入${comment}" /> | 30 | <el-input v-model="formData.${javaField}" placeholder="请输入${comment}" /> |
| 31 | </el-form-item> | 31 | </el-form-item> |
| 32 | #elseif($column.htmlType == "imageUpload")## 图片上传 | 32 | #elseif($column.htmlType == "imageUpload")## 图片上传 |
| 33 | - <el-form-item label="${comment}"> | 33 | + <el-form-item label="${comment}" prop="${javaField}"> |
| 34 | <UploadImg v-model="formData.${javaField}" /> | 34 | <UploadImg v-model="formData.${javaField}" /> |
| 35 | </el-form-item> | 35 | </el-form-item> |
| 36 | #elseif($column.htmlType == "fileUpload")## 文件上传 | 36 | #elseif($column.htmlType == "fileUpload")## 文件上传 |
| @@ -149,7 +149,7 @@ const open = async (type: string, id?: number, ${subJoinColumn.javaField}: numbe | @@ -149,7 +149,7 @@ const open = async (type: string, id?: number, ${subJoinColumn.javaField}: numbe | ||
| 149 | dialogTitle.value = t('action.' + type) | 149 | dialogTitle.value = t('action.' + type) |
| 150 | formType.value = type | 150 | formType.value = type |
| 151 | resetForm() | 151 | resetForm() |
| 152 | - formData.${subJoinColumn.javaField} = ${subJoinColumn.javaField} | 152 | + formData.value.${subJoinColumn.javaField} = ${subJoinColumn.javaField} |
| 153 | // 修改时,设置数据 | 153 | // 修改时,设置数据 |
| 154 | if (id) { | 154 | if (id) { |
| 155 | formLoading.value = true | 155 | formLoading.value = true |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/form.vue.vm
| @@ -27,7 +27,7 @@ | @@ -27,7 +27,7 @@ | ||
| 27 | <el-input v-model="formData.${javaField}" placeholder="请输入${comment}" /> | 27 | <el-input v-model="formData.${javaField}" placeholder="请输入${comment}" /> |
| 28 | </el-form-item> | 28 | </el-form-item> |
| 29 | #elseif($column.htmlType == "imageUpload")## 图片上传 | 29 | #elseif($column.htmlType == "imageUpload")## 图片上传 |
| 30 | - <el-form-item label="${comment}"> | 30 | + <el-form-item label="${comment}" prop="${javaField}"> |
| 31 | <UploadImg v-model="formData.${javaField}" /> | 31 | <UploadImg v-model="formData.${javaField}" /> |
| 32 | </el-form-item> | 32 | </el-form-item> |
| 33 | #elseif($column.htmlType == "fileUpload")## 文件上传 | 33 | #elseif($column.htmlType == "fileUpload")## 文件上传 |