Commit ddb5bce0a20cb94c9449c9b7db0b9589d15bac86

Authored by YunaiV
1 parent e8bc284d

vo 简化:post 重构

Showing 16 changed files with 82 additions and 188 deletions
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/PageParam.java
@@ -15,6 +15,13 @@ public class PageParam implements Serializable { @@ -15,6 +15,13 @@ public class PageParam implements Serializable {
15 private static final Integer PAGE_NO = 1; 15 private static final Integer PAGE_NO = 1;
16 private static final Integer PAGE_SIZE = 10; 16 private static final Integer PAGE_SIZE = 10;
17 17
  18 + /**
  19 + * 每页条数 - 不分页
  20 + *
  21 + * 例如说,导出接口,可以设置 {@link #pageSize} 为 -1 不分页,查询所有数据。
  22 + */
  23 + public static final Integer PAGE_SIZE_NONE = -1;
  24 +
18 @Schema(description = "页码,从 1 开始", requiredMode = Schema.RequiredMode.REQUIRED,example = "1") 25 @Schema(description = "页码,从 1 开始", requiredMode = Schema.RequiredMode.REQUIRED,example = "1")
19 @NotNull(message = "页码不能为空") 26 @NotNull(message = "页码不能为空")
20 @Min(value = 1, message = "页码最小值为 1") 27 @Min(value = 1, message = "页码最小值为 1")
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java
@@ -26,6 +26,12 @@ import java.util.List; @@ -26,6 +26,12 @@ import java.util.List;
26 public interface BaseMapperX<T> extends MPJBaseMapper<T> { 26 public interface BaseMapperX<T> extends MPJBaseMapper<T> {
27 27
28 default PageResult<T> selectPage(PageParam pageParam, @Param("ew") Wrapper<T> queryWrapper) { 28 default PageResult<T> selectPage(PageParam pageParam, @Param("ew") Wrapper<T> queryWrapper) {
  29 + // 特殊:不分页,直接查询全部
  30 + if (PageParam.PAGE_SIZE_NONE.equals(pageParam.getPageNo())) {
  31 + List<T> list = selectList(queryWrapper);
  32 + return new PageResult<>(list, (long) list.size());
  33 + }
  34 +
29 // MyBatis Plus 查询 35 // MyBatis Plus 查询
30 IPage<T> mpPage = MyBatisUtils.buildPage(pageParam); 36 IPage<T> mpPage = MyBatisUtils.buildPage(pageParam);
31 selectPage(mpPage, queryWrapper); 37 selectPage(mpPage, queryWrapper);
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/PostController.java
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.controller.admin.dept; @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.controller.admin.dept;
2 2
3 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; 3 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
4 import cn.iocoder.yudao.framework.common.pojo.CommonResult; 4 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  5 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
5 import cn.iocoder.yudao.framework.common.pojo.PageResult; 6 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; 7 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
7 import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; 8 import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
@@ -39,16 +40,16 @@ public class PostController { @@ -39,16 +40,16 @@ public class PostController {
39 @PostMapping("/create") 40 @PostMapping("/create")
40 @Operation(summary = "创建岗位") 41 @Operation(summary = "创建岗位")
41 @PreAuthorize("@ss.hasPermission('system:post:create')") 42 @PreAuthorize("@ss.hasPermission('system:post:create')")
42 - public CommonResult<Long> createPost(@Valid @RequestBody PostCreateReqVO reqVO) {  
43 - Long postId = postService.createPost(reqVO); 43 + public CommonResult<Long> createPost(@Valid @RequestBody PostReqVO createReqVO) {
  44 + Long postId = postService.createPost(createReqVO);
44 return success(postId); 45 return success(postId);
45 } 46 }
46 47
47 @PutMapping("/update") 48 @PutMapping("/update")
48 @Operation(summary = "修改岗位") 49 @Operation(summary = "修改岗位")
49 @PreAuthorize("@ss.hasPermission('system:post:update')") 50 @PreAuthorize("@ss.hasPermission('system:post:update')")
50 - public CommonResult<Boolean> updatePost(@Valid @RequestBody PostUpdateReqVO reqVO) {  
51 - postService.updatePost(reqVO); 51 + public CommonResult<Boolean> updatePost(@Valid @RequestBody PostReqVO updateReqVO) {
  52 + postService.updatePost(updateReqVO);
52 return success(true); 53 return success(true);
53 } 54 }
54 55
@@ -69,13 +70,13 @@ public class PostController { @@ -69,13 +70,13 @@ public class PostController {
69 } 70 }
70 71
71 @GetMapping("/list-all-simple") 72 @GetMapping("/list-all-simple")
72 - @Operation(summary = "获取岗位精简信息列表", description = "只包含被开启的岗位,主要用于前端的下拉选项")  
73 - public CommonResult<List<PostSimpleRespVO>> getSimplePostList() { 73 + @Operation(summary = "获取岗位全列表", description = "只包含被开启的岗位,主要用于前端的下拉选项")
  74 + public CommonResult<List<PostRespVO>> getSimplePostList() {
74 // 获得岗位列表,只要开启状态的 75 // 获得岗位列表,只要开启状态的
75 List<PostDO> list = postService.getPostList(null, Collections.singleton(CommonStatusEnum.ENABLE.getStatus())); 76 List<PostDO> list = postService.getPostList(null, Collections.singleton(CommonStatusEnum.ENABLE.getStatus()));
76 // 排序后,返回给前端 77 // 排序后,返回给前端
77 list.sort(Comparator.comparing(PostDO::getSort)); 78 list.sort(Comparator.comparing(PostDO::getSort));
78 - return success(PostConvert.INSTANCE.convertList02(list)); 79 + return success(PostConvert.INSTANCE.convertList(list));
79 } 80 }
80 81
81 @GetMapping("/page") 82 @GetMapping("/page")
@@ -89,11 +90,12 @@ public class PostController { @@ -89,11 +90,12 @@ public class PostController {
89 @Operation(summary = "岗位管理") 90 @Operation(summary = "岗位管理")
90 @PreAuthorize("@ss.hasPermission('system:post:export')") 91 @PreAuthorize("@ss.hasPermission('system:post:export')")
91 @OperateLog(type = EXPORT) 92 @OperateLog(type = EXPORT)
92 - public void export(HttpServletResponse response, @Validated PostExportReqVO reqVO) throws IOException {  
93 - List<PostDO> posts = postService.getPostList(reqVO);  
94 - List<PostExcelVO> data = PostConvert.INSTANCE.convertList03(posts); 93 + public void export(HttpServletResponse response, @Validated PostPageReqVO reqVO) throws IOException {
  94 + reqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
  95 + PageResult<PostDO> pageResult = postService.getPostPage(reqVO);
95 // 输出 96 // 输出
96 - ExcelUtils.write(response, "岗位数据.xls", "岗位列表", PostExcelVO.class, data); 97 + PageResult<PostRespVO> list = PostConvert.INSTANCE.convertPage(pageResult);
  98 + ExcelUtils.write(response, "岗位数据.xls", "岗位列表", PostRespVO.class, list.getList());
97 } 99 }
98 100
99 } 101 }
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/post/PostCreateReqVO.java deleted
1 -package cn.iocoder.yudao.module.system.controller.admin.dept.vo.post;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -import lombok.EqualsAndHashCode;  
6 -  
7 -@Schema(description = "管理后台 - 岗位创建 Request VO")  
8 -@Data  
9 -@EqualsAndHashCode(callSuper = true)  
10 -public class PostCreateReqVO extends PostBaseVO {  
11 -}  
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/post/PostExcelVO.java deleted
1 -package cn.iocoder.yudao.module.system.controller.admin.dept.vo.post;  
2 -  
3 -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;  
4 -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;  
5 -import cn.iocoder.yudao.module.system.enums.DictTypeConstants;  
6 -import com.alibaba.excel.annotation.ExcelProperty;  
7 -import lombok.Data;  
8 -  
9 -/**  
10 - * 岗位 Excel 导出响应 VO  
11 - */  
12 -@Data  
13 -public class PostExcelVO {  
14 -  
15 - @ExcelProperty("岗位序号")  
16 - private Long id;  
17 -  
18 - @ExcelProperty("岗位编码")  
19 - private String code;  
20 -  
21 - @ExcelProperty("岗位名称")  
22 - private String name;  
23 -  
24 - @ExcelProperty("岗位排序")  
25 - private Integer sort;  
26 -  
27 - @ExcelProperty(value = "状态", converter = DictConvert.class)  
28 - @DictFormat(DictTypeConstants.COMMON_STATUS)  
29 - private String status;  
30 -  
31 -}  
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/post/PostExportReqVO.java deleted
1 -package cn.iocoder.yudao.module.system.controller.admin.dept.vo.post;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -  
6 -@Schema(description = "管理后台 - 岗位导出 Request VO,参数和 PostExcelVO 是一致的")  
7 -@Data  
8 -public class PostExportReqVO {  
9 -  
10 - @Schema(description = "岗位编码,模糊匹配", example = "yudao")  
11 - private String code;  
12 -  
13 - @Schema(description = "岗位名称,模糊匹配", example = "芋道")  
14 - private String name;  
15 -  
16 - @Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")  
17 - private Integer status;  
18 -  
19 -}  
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/post/PostListReqVO.java deleted
1 -package cn.iocoder.yudao.module.system.controller.admin.dept.vo.post;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -import lombok.EqualsAndHashCode;  
6 -  
7 -@Schema(description = "管理后台 - 岗位列表 Request VO")  
8 -@Data  
9 -@EqualsAndHashCode(callSuper = true)  
10 -public class PostListReqVO extends PostBaseVO {  
11 -  
12 - @Schema(description = "岗位名称,模糊匹配", example = "芋道")  
13 - private String name;  
14 -  
15 - @Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")  
16 - private Integer status;  
17 -  
18 -}  
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/post/PostBaseVO.java renamed to yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/post/PostReqVO.java
1 package cn.iocoder.yudao.module.system.controller.admin.dept.vo.post; 1 package cn.iocoder.yudao.module.system.controller.admin.dept.vo.post;
  2 +
  3 +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
  4 +import cn.iocoder.yudao.framework.common.validation.InEnum;
2 import io.swagger.v3.oas.annotations.media.Schema; 5 import io.swagger.v3.oas.annotations.media.Schema;
3 import lombok.Data; 6 import lombok.Data;
4 7
@@ -6,16 +9,16 @@ import javax.validation.constraints.NotBlank; @@ -6,16 +9,16 @@ import javax.validation.constraints.NotBlank;
6 import javax.validation.constraints.NotNull; 9 import javax.validation.constraints.NotNull;
7 import javax.validation.constraints.Size; 10 import javax.validation.constraints.Size;
8 11
9 -/**  
10 - * 岗位 Base VO,提供给添加、修改、详细的子 VO 使用  
11 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成  
12 - */ 12 +@Schema(description = "管理后台 - 岗位创建/修改 Request VO")
13 @Data 13 @Data
14 -public class PostBaseVO { 14 +public class PostReqVO {
  15 +
  16 + @Schema(description = "岗位编号", example = "1024")
  17 + private Long id;
15 18
16 - @Schema(description = "岗位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小博主") 19 + @Schema(description = "岗位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小土豆")
17 @NotBlank(message = "岗位名称不能为空") 20 @NotBlank(message = "岗位名称不能为空")
18 - @Size(max = 50, message = "岗位名称长度不能超过50个字符") 21 + @Size(max = 50, message = "岗位名称长度不能超过 50 个字符")
19 private String name; 22 private String name;
20 23
21 @Schema(description = "岗位编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao") 24 @Schema(description = "岗位编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao")
@@ -27,10 +30,11 @@ public class PostBaseVO { @@ -27,10 +30,11 @@ public class PostBaseVO {
27 @NotNull(message = "显示顺序不能为空") 30 @NotNull(message = "显示顺序不能为空")
28 private Integer sort; 31 private Integer sort;
29 32
30 - @Schema(description = "状态,参见 CommonStatusEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") 33 + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  34 + @InEnum(CommonStatusEnum.class)
31 private Integer status; 35 private Integer status;
32 36
33 @Schema(description = "备注", example = "快乐的备注") 37 @Schema(description = "备注", example = "快乐的备注")
34 private String remark; 38 private String remark;
35 39
36 -} 40 -}
  41 +}
37 \ No newline at end of file 42 \ No newline at end of file
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/post/PostRespVO.java
1 package cn.iocoder.yudao.module.system.controller.admin.dept.vo.post; 1 package cn.iocoder.yudao.module.system.controller.admin.dept.vo.post;
2 2
  3 +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
  4 +import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
  5 +import com.alibaba.excel.annotation.ExcelProperty;
3 import io.swagger.v3.oas.annotations.media.Schema; 6 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 7 import lombok.Data;
5 -import lombok.EqualsAndHashCode;  
6 8
7 import java.time.LocalDateTime; 9 import java.time.LocalDateTime;
8 10
9 @Schema(description = "管理后台 - 岗位信息 Response VO") 11 @Schema(description = "管理后台 - 岗位信息 Response VO")
10 @Data 12 @Data
11 -@EqualsAndHashCode(callSuper = true)  
12 -public class PostRespVO extends PostBaseVO { 13 +public class PostRespVO {
13 14
14 @Schema(description = "岗位序号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") 15 @Schema(description = "岗位序号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
  16 + @ExcelProperty("岗位序号")
15 private Long id; 17 private Long id;
16 18
17 - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式") 19 + @Schema(description = "岗位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小土豆")
  20 + @ExcelProperty("岗位名称")
  21 + private String name;
  22 +
  23 + @Schema(description = "岗位编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao")
  24 + @ExcelProperty("岗位编码")
  25 + private String code;
  26 +
  27 + @Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
  28 + @ExcelProperty("岗位排序")
  29 + private Integer sort;
  30 +
  31 + @Schema(description = "状态,参见 CommonStatusEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  32 + @DictFormat(DictTypeConstants.COMMON_STATUS)
  33 + private Integer status;
  34 +
  35 + @Schema(description = "备注", example = "快乐的备注")
  36 + private String remark;
  37 +
  38 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
18 private LocalDateTime createTime; 39 private LocalDateTime createTime;
19 40
20 } 41 }
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/post/PostSimpleRespVO.java deleted
1 -package cn.iocoder.yudao.module.system.controller.admin.dept.vo.post;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.AllArgsConstructor;  
5 -import lombok.Data;  
6 -import lombok.NoArgsConstructor;  
7 -  
8 -@Schema(description = "管理后台 - 岗位精简信息 Response VO")  
9 -@Data  
10 -@NoArgsConstructor  
11 -@AllArgsConstructor  
12 -public class PostSimpleRespVO {  
13 -  
14 - @Schema(description = "岗位编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")  
15 - private Long id;  
16 -  
17 - @Schema(description = "岗位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")  
18 - private String name;  
19 -  
20 -}  
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/post/PostUpdateReqVO.java deleted
1 -package cn.iocoder.yudao.module.system.controller.admin.dept.vo.post;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -import lombok.EqualsAndHashCode;  
6 -  
7 -import javax.validation.constraints.NotNull;  
8 -  
9 -@Schema(description = "管理后台 - 岗位更新 Request VO")  
10 -@Data  
11 -@EqualsAndHashCode(callSuper = true)  
12 -public class PostUpdateReqVO extends PostBaseVO {  
13 -  
14 - @Schema(description = "岗位编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")  
15 - @NotNull(message = "岗位编号不能为空")  
16 - private Long id;  
17 -  
18 -}  
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/dept/PostConvert.java
@@ -13,16 +13,12 @@ public interface PostConvert { @@ -13,16 +13,12 @@ public interface PostConvert {
13 13
14 PostConvert INSTANCE = Mappers.getMapper(PostConvert.class); 14 PostConvert INSTANCE = Mappers.getMapper(PostConvert.class);
15 15
16 - List<PostSimpleRespVO> convertList02(List<PostDO> list); 16 + List<PostRespVO> convertList(List<PostDO> list);
17 17
18 PageResult<PostRespVO> convertPage(PageResult<PostDO> page); 18 PageResult<PostRespVO> convertPage(PageResult<PostDO> page);
19 19
20 - PostRespVO convert(PostDO id); 20 + PostRespVO convert(PostDO bean);
21 21
22 - PostDO convert(PostCreateReqVO bean);  
23 -  
24 - PostDO convert(PostUpdateReqVO reqVO);  
25 -  
26 - List<PostExcelVO> convertList03(List<PostDO> list); 22 + PostDO convert(PostReqVO bean);
27 23
28 } 24 }
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/PostMapper.java
@@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.system.dal.mysql.dept; @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.system.dal.mysql.dept;
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
6 -import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostExportReqVO;  
7 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostPageReqVO; 6 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostPageReqVO;
8 import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO; 7 import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO;
9 import org.apache.ibatis.annotations.Mapper; 8 import org.apache.ibatis.annotations.Mapper;
@@ -28,13 +27,6 @@ public interface PostMapper extends BaseMapperX&lt;PostDO&gt; { @@ -28,13 +27,6 @@ public interface PostMapper extends BaseMapperX&lt;PostDO&gt; {
28 .orderByDesc(PostDO::getId)); 27 .orderByDesc(PostDO::getId));
29 } 28 }
30 29
31 - default List<PostDO> selectList(PostExportReqVO reqVO) {  
32 - return selectList(new LambdaQueryWrapperX<PostDO>()  
33 - .likeIfPresent(PostDO::getCode, reqVO.getCode())  
34 - .likeIfPresent(PostDO::getName, reqVO.getName())  
35 - .eqIfPresent(PostDO::getStatus, reqVO.getStatus()));  
36 - }  
37 -  
38 default PostDO selectByName(String name) { 30 default PostDO selectByName(String name) {
39 return selectOne(PostDO::getName, name); 31 return selectOne(PostDO::getName, name);
40 } 32 }
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/PostService.java
@@ -2,10 +2,8 @@ package cn.iocoder.yudao.module.system.service.dept; @@ -2,10 +2,8 @@ package cn.iocoder.yudao.module.system.service.dept;
2 2
3 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; 3 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
4 import cn.iocoder.yudao.framework.common.pojo.PageResult; 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 -import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostCreateReqVO;  
6 -import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostExportReqVO;  
7 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostPageReqVO; 5 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostPageReqVO;
8 -import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostUpdateReqVO; 6 +import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostReqVO;
9 import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO; 7 import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO;
10 import org.springframework.lang.Nullable; 8 import org.springframework.lang.Nullable;
11 9
@@ -24,17 +22,17 @@ public interface PostService { @@ -24,17 +22,17 @@ public interface PostService {
24 /** 22 /**
25 * 创建岗位 23 * 创建岗位
26 * 24 *
27 - * @param reqVO 岗位信息 25 + * @param createReqVO 岗位信息
28 * @return 岗位编号 26 * @return 岗位编号
29 */ 27 */
30 - Long createPost(PostCreateReqVO reqVO); 28 + Long createPost(PostReqVO createReqVO);
31 29
32 /** 30 /**
33 * 更新岗位 31 * 更新岗位
34 * 32 *
35 - * @param reqVO 岗位信息 33 + * @param updateReqVO 岗位信息
36 */ 34 */
37 - void updatePost(PostUpdateReqVO reqVO); 35 + void updatePost(PostReqVO updateReqVO);
38 36
39 /** 37 /**
40 * 删除岗位信息 38 * 删除岗位信息
@@ -71,14 +69,6 @@ public interface PostService { @@ -71,14 +69,6 @@ public interface PostService {
71 PageResult<PostDO> getPostPage(PostPageReqVO reqVO); 69 PageResult<PostDO> getPostPage(PostPageReqVO reqVO);
72 70
73 /** 71 /**
74 - * 获得岗位列表  
75 - *  
76 - * @param reqVO 查询条件  
77 - * @return 部门列表  
78 - */  
79 - List<PostDO> getPostList(PostExportReqVO reqVO);  
80 -  
81 - /**  
82 * 获得岗位信息 72 * 获得岗位信息
83 * 73 *
84 * @param id 岗位编号 74 * @param id 岗位编号
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/PostServiceImpl.java
@@ -3,10 +3,8 @@ package cn.iocoder.yudao.module.system.service.dept; @@ -3,10 +3,8 @@ package cn.iocoder.yudao.module.system.service.dept;
3 import cn.hutool.core.collection.CollUtil; 3 import cn.hutool.core.collection.CollUtil;
4 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; 4 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
5 import cn.iocoder.yudao.framework.common.pojo.PageResult; 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 -import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostCreateReqVO;  
7 -import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostExportReqVO;  
8 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostPageReqVO; 6 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostPageReqVO;
9 -import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostUpdateReqVO; 7 +import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostReqVO;
10 import cn.iocoder.yudao.module.system.convert.dept.PostConvert; 8 import cn.iocoder.yudao.module.system.convert.dept.PostConvert;
11 import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO; 9 import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO;
12 import cn.iocoder.yudao.module.system.dal.mysql.dept.PostMapper; 10 import cn.iocoder.yudao.module.system.dal.mysql.dept.PostMapper;
@@ -35,23 +33,23 @@ public class PostServiceImpl implements PostService { @@ -35,23 +33,23 @@ public class PostServiceImpl implements PostService {
35 private PostMapper postMapper; 33 private PostMapper postMapper;
36 34
37 @Override 35 @Override
38 - public Long createPost(PostCreateReqVO reqVO) { 36 + public Long createPost(PostReqVO createReqVO) {
39 // 校验正确性 37 // 校验正确性
40 - validatePostForCreateOrUpdate(null, reqVO.getName(), reqVO.getCode()); 38 + validatePostForCreateOrUpdate(null, createReqVO.getName(), createReqVO.getCode());
41 39
42 // 插入岗位 40 // 插入岗位
43 - PostDO post = PostConvert.INSTANCE.convert(reqVO); 41 + PostDO post = PostConvert.INSTANCE.convert(createReqVO);
44 postMapper.insert(post); 42 postMapper.insert(post);
45 return post.getId(); 43 return post.getId();
46 } 44 }
47 45
48 @Override 46 @Override
49 - public void updatePost(PostUpdateReqVO reqVO) { 47 + public void updatePost(PostReqVO updateReqVO) {
50 // 校验正确性 48 // 校验正确性
51 - validatePostForCreateOrUpdate(reqVO.getId(), reqVO.getName(), reqVO.getCode()); 49 + validatePostForCreateOrUpdate(updateReqVO.getId(), updateReqVO.getName(), updateReqVO.getCode());
52 50
53 // 更新岗位 51 // 更新岗位
54 - PostDO updateObj = PostConvert.INSTANCE.convert(reqVO); 52 + PostDO updateObj = PostConvert.INSTANCE.convert(updateReqVO);
55 postMapper.updateById(updateObj); 53 postMapper.updateById(updateObj);
56 } 54 }
57 55
@@ -120,11 +118,6 @@ public class PostServiceImpl implements PostService { @@ -120,11 +118,6 @@ public class PostServiceImpl implements PostService {
120 } 118 }
121 119
122 @Override 120 @Override
123 - public List<PostDO> getPostList(PostExportReqVO reqVO) {  
124 - return postMapper.selectList(reqVO);  
125 - }  
126 -  
127 - @Override  
128 public PostDO getPost(Long id) { 121 public PostDO getPost(Long id) {
129 return postMapper.selectById(id); 122 return postMapper.selectById(id);
130 } 123 }
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dept/PostServiceImplTest.java
@@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; @@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
4 import cn.iocoder.yudao.framework.common.pojo.PageResult; 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; 5 import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils;
6 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; 6 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
7 -import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostCreateReqVO; 7 +import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostReqVO;
8 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostExportReqVO; 8 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostExportReqVO;
9 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostPageReqVO; 9 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostPageReqVO;
10 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostUpdateReqVO; 10 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostUpdateReqVO;
@@ -44,7 +44,7 @@ public class PostServiceImplTest extends BaseDbUnitTest { @@ -44,7 +44,7 @@ public class PostServiceImplTest extends BaseDbUnitTest {
44 @Test 44 @Test
45 public void testCreatePost_success() { 45 public void testCreatePost_success() {
46 // 准备参数 46 // 准备参数
47 - PostCreateReqVO reqVO = randomPojo(PostCreateReqVO.class, 47 + PostReqVO reqVO = randomPojo(PostReqVO.class,
48 o -> o.setStatus(randomEle(CommonStatusEnum.values()).getStatus())); 48 o -> o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()));
49 // 调用 49 // 调用
50 Long postId = postService.createPost(reqVO); 50 Long postId = postService.createPost(reqVO);
@@ -103,7 +103,7 @@ public class PostServiceImplTest extends BaseDbUnitTest { @@ -103,7 +103,7 @@ public class PostServiceImplTest extends BaseDbUnitTest {
103 PostDO postDO = randomPostDO(); 103 PostDO postDO = randomPostDO();
104 postMapper.insert(postDO);// @Sql: 先插入出一条存在的数据 104 postMapper.insert(postDO);// @Sql: 先插入出一条存在的数据
105 // 准备参数 105 // 准备参数
106 - PostCreateReqVO reqVO = randomPojo(PostCreateReqVO.class, 106 + PostReqVO reqVO = randomPojo(PostReqVO.class,
107 // 模拟 name 重复 107 // 模拟 name 重复
108 o -> o.setName(postDO.getName())); 108 o -> o.setName(postDO.getName()));
109 assertServiceException(() -> postService.createPost(reqVO), POST_NAME_DUPLICATE); 109 assertServiceException(() -> postService.createPost(reqVO), POST_NAME_DUPLICATE);