diff --git a/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/web/page/DataPageResp.java b/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/web/page/DataPageResp.java index f05fe81..12dc288 100644 --- a/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/web/page/DataPageResp.java +++ b/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/web/page/DataPageResp.java @@ -34,4 +34,7 @@ public class DataPageResp implements Serializable { public static DataPageResp of(PageQueryModel pageQueryModel) { return new DataPageResp<>(pageQueryModel.getTotal(), pageQueryModel.getDataList()); } + public static DataPageResp of(Long total, List rows) { + return new DataPageResp<>(total,rows); + } } diff --git a/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/web/page/PageQueryModel.java b/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/web/page/PageQueryModel.java index 383cc75..e2b41c0 100644 --- a/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/web/page/PageQueryModel.java +++ b/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/web/page/PageQueryModel.java @@ -36,4 +36,13 @@ public class PageQueryModel { public static PageQueryModel of(Page page) { return new PageQueryModel<>(page.getTotal(), page.getRecords()); } + /** + * 构建分页查询模型对象 + * @param total,list 分页对象 + * @return 分页模型对象 + * @param 入参 + */ + public static PageQueryModel of(Long total,List list) { + return new PageQueryModel<>(total, list); + } } diff --git a/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/controller/SysPostController.java b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/controller/SysPostController.java index 9121c77..e230ee9 100644 --- a/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/controller/SysPostController.java +++ b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/controller/SysPostController.java @@ -10,9 +10,11 @@ import com.muyu.common.log.enums.BusinessType; import com.muyu.common.security.annotation.RequiresPermissions; import com.muyu.common.security.utils.SecurityUtils; import com.muyu.system.domain.SysPost; -import com.muyu.system.domain.model.SysPostPageQueryModel; +import com.muyu.system.domain.model.*; +import com.muyu.system.domain.rep.SysPostEditReq; import com.muyu.system.domain.rep.SysPostListReq; -import com.muyu.system.service.SysPostService; +import com.muyu.system.domain.rep.SysPostSaveReq; +import com.muyu.system.domain.resp.SysPostListResp;import com.muyu.system.service.SysPostService; import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; @@ -36,11 +38,9 @@ public class SysPostController extends BaseController { */ @RequiresPermissions("system:post:list") @PostMapping("/list") - public Result> list (@RequestBody SysPostListReq postListReq) { - PageQueryModel sysPostPageQueryModel = postService.pageQuery( - SysPostPageQueryModel.reqBuild(postListReq) - ); - return Result.success(DataPageResp.of(sysPostPageQueryModel)); + public Result> list (@RequestBody SysPostListReq postListReq) { + PageQueryModel sysPostPageQueryModel = postService.getList(SysPostPageQueryModel.reqBuild(postListReq)); + return Result.success(DataPageResp.of(sysPostPageQueryModel.getTotal(),sysPostPageQueryModel.getDataList().stream().map(SysPostListResp::listBuild).toList())); } @Log(title = "岗位管理", businessType = BusinessType.EXPORT) @@ -48,11 +48,9 @@ public class SysPostController extends BaseController { @PostMapping("/export") public void export (HttpServletResponse response, SysPostListReq postListReq) { // TODO 导出重写 - PageQueryModel sysPostPageQueryModel = postService.pageQuery( - SysPostPageQueryModel.reqBuild(postListReq) - ); - ExcelUtil util = new ExcelUtil(SysPost.class); - util.exportExcel(response, sysPostPageQueryModel.getDataList(), "岗位数据"); + PageQueryModel sysPostPageQueryModel = postService.getList(SysPostPageQueryModel.reqBuild(postListReq)); + ExcelUtil util = new ExcelUtil(SysPostListResp.class); + util.exportExcel(response, sysPostPageQueryModel.getDataList().stream().map(SysPostListResp::listBuild).toList(), "岗位数据"); } /** @@ -60,7 +58,7 @@ public class SysPostController extends BaseController { */ @RequiresPermissions("system:post:query") @GetMapping(value = "/{postId}") - public Result getInfo (@PathVariable("postId") Long postId) { + public Result getInfo (@PathVariable("postId") Long postId) { return success(postService.selectPostById(postId)); } @@ -70,14 +68,14 @@ public class SysPostController extends BaseController { @RequiresPermissions("system:post:add") @Log(title = "岗位管理", businessType = BusinessType.INSERT) @PostMapping - public Result add (@Validated @RequestBody SysPost post) { - if (!postService.checkPostNameUnique(post)) { - return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在"); - } else if (!postService.checkPostCodeUnique(post)) { - return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); + public Result add (@Validated @RequestBody SysPostSaveReq sysPostSaveReq) { + if (!postService.checkPostNameUnique(SysPostSaveModel.saveBuild(sysPostSaveReq))) { + return error("新增岗位'" + sysPostSaveReq.getPostName() + "'失败,岗位名称已存在"); + } else if (!postService.checkPostCodeUnique(SysPostSaveModel.saveBuild(sysPostSaveReq))) { + return error("新增岗位'" + sysPostSaveReq.getPostName() + "'失败,岗位编码已存在"); } - post.setCreateBy(SecurityUtils.getUsername()); - postService.insertPost(post); + sysPostSaveReq.setCreateBy(SecurityUtils.getUsername()); + postService.insertPost(SysPost.saveBuild(SysPostSaveModel.saveBuild(sysPostSaveReq))); return Result.success(); } @@ -87,14 +85,14 @@ public class SysPostController extends BaseController { @RequiresPermissions("system:post:edit") @Log(title = "岗位管理", businessType = BusinessType.UPDATE) @PutMapping - public Result edit (@Validated @RequestBody SysPost post) { - if (!postService.checkPostNameUnique(post)) { - return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); - } else if (!postService.checkPostCodeUnique(post)) { - return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); + public Result edit (@Validated @RequestBody SysPostEditReq sysPostEditReq) { + if (!postService.checkEditPostNameUnique(SysPostEditModel.editBuild(sysPostEditReq))) { + return error("修改岗位'" + sysPostEditReq.getPostName() + "'失败,岗位名称已存在"); + } else if (!postService.checkEditPostCodeUnique(SysPostEditModel.editBuild(sysPostEditReq))) { + return error("修改岗位'" + sysPostEditReq.getPostName() + "'失败,岗位编码已存在"); } - post.setUpdateBy(SecurityUtils.getUsername()); - postService.updatePost(post); + sysPostEditReq.setUpdateBy(SecurityUtils.getUsername()); + postService.updatePost(SysPost.editBuild(SysPostEditModel.editBuild(sysPostEditReq))); return Result.success(); } diff --git a/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/SysPost.java b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/SysPost.java index 8b6f665..f3e14e6 100644 --- a/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/SysPost.java +++ b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/SysPost.java @@ -6,6 +6,9 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.muyu.common.core.annotation.Excel; import com.muyu.common.core.annotation.Excel.ColumnType; import com.muyu.common.core.web.domain.BaseEntity; +import com.muyu.system.domain.model.SysPostEditModel; +import com.muyu.system.domain.model.SysPostSaveModel; +import com.muyu.system.domain.rep.SysPostSaveReq; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; @@ -79,4 +82,27 @@ public class SysPost extends BaseEntity { public Integer getPostSort () { return postSort; } + + public static SysPost saveBuild(SysPostSaveModel sysPostSaveModel) { + return SysPost.builder() + .postId(sysPostSaveModel.getPostId()) + .postCode(sysPostSaveModel.getPostCode()) + .postName(sysPostSaveModel.getPostName()) + .postSort(sysPostSaveModel.getPostSort()) + .status(sysPostSaveModel.getStatus()) + .flag(sysPostSaveModel.isFlag()) + .createBy(sysPostSaveModel.getCreateBy()) + .build(); + } + public static SysPost editBuild(SysPostEditModel sysPostEditModel) { + return SysPost.builder() + .postId(sysPostEditModel.getPostId()) + .postCode(sysPostEditModel.getPostCode()) + .postName(sysPostEditModel.getPostName()) + .postSort(sysPostEditModel.getPostSort()) + .status(sysPostEditModel.getStatus()) + .flag(sysPostEditModel.isFlag()) + .createBy(sysPostEditModel.getUpdateBy()) + .build(); + } } diff --git a/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/model/SysPostEditModel.java b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/model/SysPostEditModel.java new file mode 100644 index 0000000..671ebf0 --- /dev/null +++ b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/model/SysPostEditModel.java @@ -0,0 +1,73 @@ +package com.muyu.system.domain.model; + +import com.muyu.common.core.annotation.Excel; +import com.muyu.system.domain.rep.SysPostEditReq; +import com.muyu.system.domain.rep.SysPostSaveReq; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; /** + * 岗位信息列表模型 + * @author: AoCi Tian + * @create: 2025-02-23 19:31 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SysPostEditModel { + private static final long serialVersionUID = 1L; + + /** + * 岗位序号 + */ + @Excel(name = "岗位序号", cellType = Excel.ColumnType.NUMERIC) + private Long postId; + + /** + * 岗位编码 + */ + @Excel(name = "岗位编码") + private String postCode; + + /** + * 岗位名称 + */ + @Excel(name = "岗位名称") + private String postName; + + /** + * 岗位排序 + */ + @Excel(name = "岗位排序") + private Integer postSort; + + /** + * 状态(0正常 1停用) + */ + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") + private String status; + + /** + * 用户是否存在此岗位标识 默认不存在 + */ + @Builder.Default + private boolean flag = false; + + /** + * 创建者 + */ + private String updateBy; + + public static SysPostEditModel editBuild(SysPostEditReq sysPostEditReq) { + return SysPostEditModel.builder() + .postId(sysPostEditReq.getPostId()) + .postCode(sysPostEditReq.getPostCode()) + .postName(sysPostEditReq.getPostName()) + .postSort(sysPostEditReq.getPostSort()) + .status(sysPostEditReq.getStatus()) + .flag(sysPostEditReq.isFlag()) + .updateBy(sysPostEditReq.getUpdateBy()) + .build(); + } +} diff --git a/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/model/SysPostListModel.java b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/model/SysPostListModel.java new file mode 100644 index 0000000..9fa28f5 --- /dev/null +++ b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/model/SysPostListModel.java @@ -0,0 +1,64 @@ +package com.muyu.system.domain.model; + +import com.muyu.common.core.annotation.Excel; +import com.muyu.system.domain.SysPost; +import lombok.*; +import lombok.experimental.SuperBuilder; /** + * 岗位信息列表模型 + * @author: AoCi Tian + * @create: 2025-02-23 19:31 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SysPostListModel { + private static final long serialVersionUID = 1L; + + /** + * 岗位序号 + */ + @Excel(name = "岗位序号", cellType = Excel.ColumnType.NUMERIC) + private Long postId; + + /** + * 岗位编码 + */ + @Excel(name = "岗位编码") + private String postCode; + + /** + * 岗位名称 + */ + @Excel(name = "岗位名称") + private String postName; + + /** + * 岗位排序 + */ + @Excel(name = "岗位排序") + private Integer postSort; + + /** + * 状态(0正常 1停用) + */ + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") + private String status; + + /** + * 用户是否存在此岗位标识 默认不存在 + */ + @Builder.Default + private boolean flag = false; + + public static SysPostListModel listBuild(SysPost sysPost) { + return SysPostListModel.builder() + .postId(sysPost.getPostId()) + .postCode(sysPost.getPostCode()) + .postName(sysPost.getPostName()) + .postSort(sysPost.getPostSort()) + .status(sysPost.getStatus()) + .flag(sysPost.isFlag()) + .build(); + } +} diff --git a/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/model/SysPostMyInfoModel.java b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/model/SysPostMyInfoModel.java new file mode 100644 index 0000000..12c42f0 --- /dev/null +++ b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/model/SysPostMyInfoModel.java @@ -0,0 +1,66 @@ +package com.muyu.system.domain.model; + +import com.muyu.common.core.annotation.Excel; +import com.muyu.system.domain.SysPost; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; /** + * 个人岗位信息 + * @author: AoCi Tian + * @create: 2025-02-23 20:52 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SysPostMyInfoModel { + private static final long serialVersionUID = 1L; + + /** + * 岗位序号 + */ + @Excel(name = "岗位序号", cellType = Excel.ColumnType.NUMERIC) + private Long postId; + + /** + * 岗位编码 + */ + @Excel(name = "岗位编码") + private String postCode; + + /** + * 岗位名称 + */ + @Excel(name = "岗位名称") + private String postName; + + /** + * 岗位排序 + */ + @Excel(name = "岗位排序") + private Integer postSort; + + /** + * 状态(0正常 1停用) + */ + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") + private String status; + + /** + * 用户是否存在此岗位标识 默认不存在 + */ + @Builder.Default + private boolean flag = false; + + public static SysPostMyInfoModel build(SysPost sysPost) { + return SysPostMyInfoModel.builder() + .postId(sysPost.getPostId()) + .postCode(sysPost.getPostCode()) + .postName(sysPost.getPostName()) + .postSort(sysPost.getPostSort()) + .status(sysPost.getStatus()) + .flag(sysPost.isFlag()) + .build(); + } +} diff --git a/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/model/SysPostSaveModel.java b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/model/SysPostSaveModel.java new file mode 100644 index 0000000..c57938e --- /dev/null +++ b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/model/SysPostSaveModel.java @@ -0,0 +1,73 @@ +package com.muyu.system.domain.model; + +import com.muyu.common.core.annotation.Excel; +import com.muyu.system.domain.SysPost; +import com.muyu.system.domain.rep.SysPostSaveReq; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; /** + * 岗位信息列表模型 + * @author: AoCi Tian + * @create: 2025-02-23 19:31 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SysPostSaveModel { + private static final long serialVersionUID = 1L; + + /** + * 岗位序号 + */ + @Excel(name = "岗位序号", cellType = Excel.ColumnType.NUMERIC) + private Long postId; + + /** + * 岗位编码 + */ + @Excel(name = "岗位编码") + private String postCode; + + /** + * 岗位名称 + */ + @Excel(name = "岗位名称") + private String postName; + + /** + * 岗位排序 + */ + @Excel(name = "岗位排序") + private Integer postSort; + + /** + * 状态(0正常 1停用) + */ + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") + private String status; + + /** + * 用户是否存在此岗位标识 默认不存在 + */ + @Builder.Default + private boolean flag = false; + + /** + * 创建者 + */ + private String createBy; + + public static SysPostSaveModel saveBuild(SysPostSaveReq sysPostSaveReq) { + return SysPostSaveModel.builder() + .postId(sysPostSaveReq.getPostId()) + .postCode(sysPostSaveReq.getPostCode()) + .postName(sysPostSaveReq.getPostName()) + .postSort(sysPostSaveReq.getPostSort()) + .status(sysPostSaveReq.getStatus()) + .flag(sysPostSaveReq.isFlag()) + .createBy(sysPostSaveReq.getCreateBy()) + .build(); + } +} diff --git a/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/rep/SysPostEditReq.java b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/rep/SysPostEditReq.java new file mode 100644 index 0000000..05c9e04 --- /dev/null +++ b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/rep/SysPostEditReq.java @@ -0,0 +1,72 @@ +package com.muyu.system.domain.rep; + +import com.muyu.common.core.annotation.Excel; +import com.muyu.system.domain.SysPost; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; /** + * 岗位信息列表模型 + * @author: AoCi Tian + * @create: 2025-02-23 19:31 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SysPostEditReq { + private static final long serialVersionUID = 1L; + + /** + * 岗位序号 + */ + @Excel(name = "岗位序号", cellType = Excel.ColumnType.NUMERIC) + private Long postId; + + /** + * 岗位编码 + */ + @Excel(name = "岗位编码") + private String postCode; + + /** + * 岗位名称 + */ + @Excel(name = "岗位名称") + private String postName; + + /** + * 岗位排序 + */ + @Excel(name = "岗位排序") + private Integer postSort; + + /** + * 状态(0正常 1停用) + */ + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") + private String status; + + /** + * 用户是否存在此岗位标识 默认不存在 + */ + @Builder.Default + private boolean flag = false; + + /** + * 创建者 + */ + private String updateBy; + + public static SysPostEditReq editBuild(SysPost sysPost) { + return SysPostEditReq.builder() + .postId(sysPost.getPostId()) + .postCode(sysPost.getPostCode()) + .postName(sysPost.getPostName()) + .postSort(sysPost.getPostSort()) + .status(sysPost.getStatus()) + .flag(sysPost.isFlag()) + .updateBy(sysPost.getUpdateBy()) + .build(); + } +} diff --git a/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/rep/SysPostSaveReq.java b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/rep/SysPostSaveReq.java new file mode 100644 index 0000000..8116a6d --- /dev/null +++ b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/rep/SysPostSaveReq.java @@ -0,0 +1,75 @@ +package com.muyu.system.domain.rep; + +import com.muyu.common.core.annotation.Excel; +import com.muyu.system.domain.SysPost; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; /** + * 岗位信息列表模型 + * @author: AoCi Tian + * @create: 2025-02-23 19:31 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SysPostSaveReq { + private static final long serialVersionUID = 1L; + + /** + * 岗位序号 + */ + @Excel(name = "岗位序号", cellType = Excel.ColumnType.NUMERIC) + private Long postId; + + /** + * 岗位编码 + */ + @Excel(name = "岗位编码") + private String postCode; + + /** + * 岗位名称 + */ + @Excel(name = "岗位名称") + private String postName; + + /** + * 岗位排序 + */ + @Excel(name = "岗位排序") + private Integer postSort; + + /** + * 状态(0正常 1停用) + */ + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") + private String status; + + /** + * 用户是否存在此岗位标识 默认不存在 + */ + @Builder.Default + private boolean flag = false; + + /** + * 创建者 + */ + private String createBy; + + public static SysPostSaveReq saveBuild(SysPost sysPost) { + return SysPostSaveReq.builder() + .postId(sysPost.getPostId()) + .postCode(sysPost.getPostCode()) + .postName(sysPost.getPostName()) + .postSort(sysPost.getPostSort()) + .status(sysPost.getStatus()) + .flag(sysPost.isFlag()) + .createBy(sysPost.getCreateBy()) + .build(); + } +} diff --git a/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/resp/SysPostListResp.java b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/resp/SysPostListResp.java new file mode 100644 index 0000000..e92872b --- /dev/null +++ b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/domain/resp/SysPostListResp.java @@ -0,0 +1,71 @@ +package com.muyu.system.domain.resp; + +import com.muyu.common.core.annotation.Excel; +import com.muyu.common.core.web.page.PageQueryModel; +import com.muyu.system.domain.SysPost; +import com.muyu.system.domain.model.SysPostListModel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; /** + + * 岗位信息响应列表 + * @author: AoCi Tian + * @create: 2025-02-23 19:37 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SysPostListResp { + private static final long serialVersionUID = 1L; + + /** + * 岗位序号 + */ + @Excel(name = "岗位序号", cellType = Excel.ColumnType.NUMERIC) + private Long postId; + + /** + * 岗位编码 + */ + @Excel(name = "岗位编码") + private String postCode; + + /** + * 岗位名称 + */ + @Excel(name = "岗位名称") + private String postName; + + /** + * 岗位排序 + */ + @Excel(name = "岗位排序") + private Integer postSort; + + /** + * 状态(0正常 1停用) + */ + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") + private String status; + + /** + * 用户是否存在此岗位标识 默认不存在 + */ + @Builder.Default + private boolean flag = false; + + public static SysPostListResp listBuild(SysPostListModel sysPostListModel) { + return SysPostListResp.builder() + .postId(sysPostListModel.getPostId()) + .postCode(sysPostListModel.getPostCode()) + .postName(sysPostListModel.getPostName()) + .postSort(sysPostListModel.getPostSort()) + .status(sysPostListModel.getStatus()) + .flag(sysPostListModel.isFlag()) + .build(); + } +} diff --git a/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/service/SysPostService.java b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/service/SysPostService.java index 63194df..48fcbd3 100644 --- a/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/service/SysPostService.java +++ b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/service/SysPostService.java @@ -1,9 +1,11 @@ package com.muyu.system.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.muyu.common.core.web.page.DataPageResp; import com.muyu.common.core.web.page.PageQueryModel; import com.muyu.system.domain.SysPost; -import com.muyu.system.domain.model.SysPostPageQueryModel; +import com.muyu.system.domain.model.*; +import com.muyu.system.domain.resp.SysPostListResp; import java.util.List; @@ -27,7 +29,7 @@ public interface SysPostService extends IService { * * @return 角色对象信息 */ - public SysPost selectPostById (Long postId); + public SysPostMyInfoModel selectPostById (Long postId); /** * 根据用户ID获取岗位选择框列表 @@ -41,20 +43,40 @@ public interface SysPostService extends IService { /** * 校验岗位名称 * - * @param post 岗位信息 + * @param sysPostSaveModel 岗位信息 * * @return 结果 */ - public boolean checkPostNameUnique (SysPost post); + public boolean checkPostNameUnique (SysPostSaveModel sysPostSaveModel);/** + + + * 校验岗位名称 + * + * @param sysPostEditModel 岗位信息 + * + * @return 结果 + */ + public boolean checkEditPostNameUnique (SysPostEditModel sysPostEditModel); + /** * 校验岗位编码 * - * @param post 岗位信息 + * @param sysPostSaveModel 岗位信息 * * @return 结果 */ - public boolean checkPostCodeUnique (SysPost post); + public boolean checkPostCodeUnique (SysPostSaveModel sysPostSaveModel); + + + /** + * 校验岗位编码 + * + * @param sysPostEditModel 岗位信息 + * + * @return 结果 + */ + public boolean checkEditPostCodeUnique (SysPostEditModel sysPostEditModel); /** * 通过岗位ID查询岗位使用数量 @@ -103,4 +125,10 @@ public interface SysPostService extends IService { PageQueryModel pageQuery(SysPostPageQueryModel sysPostPageQueryModel); + /** + * 岗位信息列表 + * @param sysPostPageQueryModel 分页信息 + * @return 结果 + */ + PageQueryModel getList(SysPostPageQueryModel sysPostPageQueryModel); } diff --git a/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/service/impl/SysPostServiceImpl.java b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/service/impl/SysPostServiceImpl.java index 7588de5..10aa4a3 100644 --- a/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/service/impl/SysPostServiceImpl.java +++ b/cloud-modules/cloud-modules-system/src/main/java/com/muyu/system/service/impl/SysPostServiceImpl.java @@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.muyu.common.core.constant.UserConstants; import com.muyu.common.core.exception.ServiceException; import com.muyu.common.core.utils.StringUtils; +import com.muyu.common.core.web.page.DataPageResp; import com.muyu.common.core.web.page.PageQueryModel; import com.muyu.system.domain.SysPost; -import com.muyu.system.domain.model.SysPostPageQueryModel; +import com.muyu.system.domain.model.*; +import com.muyu.system.domain.resp.SysPostListResp; import com.muyu.system.mapper.SysPostMapper; import com.muyu.system.mapper.SysUserPostMapper; import com.muyu.system.service.SysPostService; @@ -52,8 +54,8 @@ public class SysPostServiceImpl extends ServiceImpl impl * @return 角色对象信息 */ @Override - public SysPost selectPostById (Long postId) { - return getById(postId); + public SysPostMyInfoModel selectPostById (Long postId) { + return SysPostMyInfoModel.build(getById(postId)); } /** @@ -71,15 +73,25 @@ public class SysPostServiceImpl extends ServiceImpl impl /** * 校验岗位名称是否唯一 * - * @param post 岗位信息 + * @param sysPostSaveModel 岗位信息 * * @return 结果 */ @Override - public boolean checkPostNameUnique (SysPost post) { + public boolean checkPostNameUnique (SysPostSaveModel sysPostSaveModel) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.eq(SysPost::getPostName, post.getPostName()); - lambdaQueryWrapper.eq(post.getPostId() != null, SysPost::getPostId, post.getPostId()); + lambdaQueryWrapper.eq(SysPost::getPostName, sysPostSaveModel.getPostName()); + lambdaQueryWrapper.eq(sysPostSaveModel.getPostId() != null, SysPost::getPostId, sysPostSaveModel.getPostId()); + if (this.count(lambdaQueryWrapper) != 0) { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + @Override + public boolean checkEditPostNameUnique (SysPostEditModel sysPostEditModel) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(SysPost::getPostName, sysPostEditModel.getPostName()); + lambdaQueryWrapper.eq(sysPostEditModel.getPostId() != null, SysPost::getPostId, sysPostEditModel.getPostId()); if (this.count(lambdaQueryWrapper) != 0) { return UserConstants.NOT_UNIQUE; } @@ -89,16 +101,25 @@ public class SysPostServiceImpl extends ServiceImpl impl /** * 校验岗位编码是否唯一 * - * @param post 岗位信息 + * @param sysPostSaveModel 岗位信息 * * @return 结果 */ @Override - public boolean checkPostCodeUnique (SysPost post) { - + public boolean checkPostCodeUnique(SysPostSaveModel sysPostSaveModel) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.eq(SysPost::getPostCode, post.getPostCode()); - lambdaQueryWrapper.eq(post.getPostId() != null, SysPost::getPostId, post.getPostId()); + lambdaQueryWrapper.eq(SysPost::getPostCode, sysPostSaveModel.getPostCode()); + lambdaQueryWrapper.eq(sysPostSaveModel.getPostId() != null, SysPost::getPostId, sysPostSaveModel.getPostId()); + if (this.count(lambdaQueryWrapper) != 0) { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + @Override + public boolean checkEditPostCodeUnique(SysPostEditModel sysPostEditModel) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(SysPost::getPostCode, sysPostEditModel.getPostCode()); + lambdaQueryWrapper.eq(sysPostEditModel.getPostId() != null, SysPost::getPostId, sysPostEditModel.getPostId()); if (this.count(lambdaQueryWrapper) != 0) { return UserConstants.NOT_UNIQUE; } @@ -178,6 +199,16 @@ public class SysPostServiceImpl extends ServiceImpl impl queryWrapper.like(StringUtils.isNotEmpty(sysPostPageQueryModel.getPostName()),SysPost::getPostName, sysPostPageQueryModel.getPostName()); queryWrapper.eq(StringUtils.isNotEmpty(sysPostPageQueryModel.getStatus()),SysPost::getStatus, sysPostPageQueryModel.getStatus()); Page page = this.page(sysPostPageQueryModel.buildPage(), queryWrapper); + return PageQueryModel.of(page); } + @Override + public PageQueryModel getList(SysPostPageQueryModel sysPostPageQueryModel) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.like(StringUtils.isNotEmpty(sysPostPageQueryModel.getPostCode()),SysPost::getPostCode, sysPostPageQueryModel.getPostCode()); + queryWrapper.like(StringUtils.isNotEmpty(sysPostPageQueryModel.getPostName()),SysPost::getPostName, sysPostPageQueryModel.getPostName()); + queryWrapper.eq(StringUtils.isNotEmpty(sysPostPageQueryModel.getStatus()),SysPost::getStatus, sysPostPageQueryModel.getStatus()); + Page page = this.page(sysPostPageQueryModel.buildPage(), queryWrapper); + return PageQueryModel.of(page.getTotal(),page.getRecords().stream().map(SysPostListModel::listBuild).toList()); + } }