新增岗位管理, 将之前的岗位管理变更为职称管理
修改用户新增和修改时 添加岗位选择 修改 用户查询 增加岗位、编制、性质字段
This commit is contained in:
parent
81123dbbea
commit
ead4f755a7
@ -54,11 +54,12 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode DEPT_NOT_ENABLE = new ErrorCode(1_002_004_006, "部门({})不处于开启状态,不允许选择");
|
||||
ErrorCode DEPT_PARENT_IS_CHILD = new ErrorCode(1_002_004_007, "不能设置自己的子部门为父部门");
|
||||
|
||||
// ========== 岗位模块 1-002-005-000 ==========
|
||||
ErrorCode POST_NOT_FOUND = new ErrorCode(1_002_005_000, "当前岗位不存在");
|
||||
ErrorCode POST_NOT_ENABLE = new ErrorCode(1_002_005_001, "岗位({}) 不处于开启状态,不允许选择");
|
||||
ErrorCode POST_NAME_DUPLICATE = new ErrorCode(1_002_005_002, "已经存在该名字的岗位");
|
||||
ErrorCode POST_CODE_DUPLICATE = new ErrorCode(1_002_005_003, "已经存在该标识的岗位");
|
||||
// ========== 职称模块 1-002-005-000 ==========
|
||||
ErrorCode POST_NOT_FOUND = new ErrorCode(1_002_005_000, "当前职称不存在");
|
||||
ErrorCode POST_NOT_ENABLE = new ErrorCode(1_002_005_001, "职称({}) 不处于开启状态,不允许选择");
|
||||
ErrorCode POST_NAME_DUPLICATE = new ErrorCode(1_002_005_002, "已经存在该名字的职称");
|
||||
ErrorCode POST_CODE_DUPLICATE = new ErrorCode(1_002_005_003, "已经存在该标识的职称");
|
||||
ErrorCode POSITION_NOT_EXISTS = new ErrorCode(1_002_005_004, "岗位信息不存在");
|
||||
|
||||
// ========== 字典类型 1-002-006-000 ==========
|
||||
ErrorCode DICT_TYPE_NOT_EXISTS = new ErrorCode(1_002_006_001, "当前字典类型不存在");
|
||||
|
@ -0,0 +1,104 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.position;
|
||||
|
||||
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.datapermission.core.annotation.DataPermission;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.position.vo.PositionPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.position.vo.PositionRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.position.vo.PositionSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.position.PositionDO;
|
||||
import cn.iocoder.yudao.module.system.service.position.PositionService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@Tag(name = "管理后台 - 岗位信息")
|
||||
@RestController
|
||||
@RequestMapping("/system/position")
|
||||
@Validated
|
||||
public class PositionController {
|
||||
|
||||
@Resource
|
||||
private PositionService positionService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建岗位信息")
|
||||
@PreAuthorize("@ss.hasPermission('system:position:create')")
|
||||
public CommonResult<Long> createPosition(@Valid @RequestBody PositionSaveReqVO createReqVO) {
|
||||
return success(positionService.createPosition(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新岗位信息")
|
||||
@PreAuthorize("@ss.hasPermission('system:position:update')")
|
||||
public CommonResult<Boolean> updatePosition(@Valid @RequestBody PositionSaveReqVO updateReqVO) {
|
||||
positionService.updatePosition(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除岗位信息")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('system:position:delete')")
|
||||
public CommonResult<Boolean> deletePosition(@RequestParam("id") Long id) {
|
||||
positionService.deletePosition(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得岗位信息")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:position:query')")
|
||||
public CommonResult<PositionRespVO> getPosition(@RequestParam("id") Long id) {
|
||||
PositionDO position = positionService.getPosition(id);
|
||||
return success(BeanUtils.toBean(position, PositionRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get-list")
|
||||
@Operation(summary = "获得岗位信息")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:position:query')")
|
||||
@DataPermission(enable = false)
|
||||
public CommonResult<List<PositionRespVO>> getPositionList() {
|
||||
List<PositionDO> positions = positionService.getPositionList();
|
||||
return success(BeanUtils.toBean(positions, PositionRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得岗位信息分页")
|
||||
@PreAuthorize("@ss.hasPermission('system:position:query')")
|
||||
public CommonResult<PageResult<PositionRespVO>> getPositionPage(@Valid PositionPageReqVO pageReqVO) {
|
||||
PageResult<PositionDO> pageResult = positionService.getPositionPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, PositionRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出岗位信息 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('system:position:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportPositionExcel(@Valid PositionPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<PositionDO> list = positionService.getPositionPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "岗位信息.xls", "数据", PositionRespVO.class,
|
||||
BeanUtils.toBean(list, PositionRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.position.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
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 PositionPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "岗位名称", example = "JAVA开发")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "状态(0正常 1停用)", example = "0")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.position.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 岗位信息 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class PositionRespVO {
|
||||
|
||||
@Schema(description = "岗位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("岗位ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "岗位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "JAVA开发")
|
||||
@ExcelProperty("岗位名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "状态(0正常 1停用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
@ExcelProperty("状态(0正常 1停用)")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.position.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 岗位信息新增/修改 Request VO")
|
||||
@Data
|
||||
public class PositionSaveReqVO {
|
||||
|
||||
@Schema(description = "岗位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "岗位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "JAVA开发")
|
||||
@NotEmpty(message = "岗位名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "状态(0正常 1停用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
@NotNull(message = "状态(0正常 1停用)不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
private String remark;
|
||||
|
||||
}
|
@ -15,9 +15,11 @@ import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.*;
|
||||
import cn.iocoder.yudao.module.system.convert.user.UserConvert;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.position.PositionDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
||||
import cn.iocoder.yudao.module.system.service.dept.PostService;
|
||||
import cn.iocoder.yudao.module.system.service.position.PositionService;
|
||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -37,6 +39,7 @@ import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@Tag(name = "管理后台 - 用户")
|
||||
@ -53,6 +56,9 @@ public class UserController {
|
||||
@Resource
|
||||
private PostService postService;
|
||||
|
||||
@Resource
|
||||
private PositionService positionService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "新增用户")
|
||||
@PreAuthorize("@ss.hasPermission('system:user:create')")
|
||||
@ -114,8 +120,10 @@ public class UserController {
|
||||
// 拼接数据
|
||||
Map<Long, DeptDO> deptMap = deptService.getDeptMap(convertList(pageResult.getList(), AdminUserDO::getDeptId));
|
||||
Map<Long, PostDO> postMap = postService.getDeptMap(convertList(pageResult.getList(), AdminUserDO::getPostIds));
|
||||
List<PositionDO> positionDOs = positionService.getPositionList(convertList(pageResult.getList(), AdminUserDO::getPositionId));
|
||||
Map<Long, PositionDO> positionMap = convertMap(positionDOs, PositionDO::getId);
|
||||
|
||||
return success(new PageResult<>(UserConvert.INSTANCE.convertList(pageResult.getList(), deptMap, postMap),
|
||||
return success(new PageResult<>(UserConvert.INSTANCE.convertList(pageResult.getList(), deptMap, postMap, positionMap),
|
||||
pageResult.getTotal()));
|
||||
}
|
||||
|
||||
@ -132,8 +140,10 @@ public class UserController {
|
||||
// 拼接数据
|
||||
Map<Long, DeptDO> deptMap = deptService.getDeptMap(convertList(pageResult.getList(), AdminUserDO::getDeptId));
|
||||
Map<Long, PostDO> postMap = postService.getDeptMap(convertList(pageResult.getList(), AdminUserDO::getPostIds));
|
||||
List<PositionDO> positionDOs = positionService.getPositionList(convertList(pageResult.getList(), AdminUserDO::getPositionId));
|
||||
Map<Long, PositionDO> positionMap = convertMap(positionDOs, PositionDO::getId);
|
||||
|
||||
return success(new PageResult<>(UserConvert.INSTANCE.convertList(pageResult.getList(), deptMap, postMap),
|
||||
return success(new PageResult<>(UserConvert.INSTANCE.convertList(pageResult.getList(), deptMap, postMap, positionMap),
|
||||
pageResult.getTotal()));
|
||||
}
|
||||
|
||||
@ -189,7 +199,7 @@ public class UserController {
|
||||
post = postService.getPost(postId);
|
||||
}
|
||||
|
||||
return success(UserConvert.INSTANCE.convert(user, dept, post));
|
||||
return success(UserConvert.INSTANCE.convert(user, dept));
|
||||
}
|
||||
|
||||
@PostMapping("/getByDeptIds")
|
||||
@ -254,6 +264,8 @@ public class UserController {
|
||||
|
||||
Map<Long, DeptDO> deptMap = deptService.getDeptMap(convertList(list, AdminUserDO::getDeptId));
|
||||
Map<Long, PostDO> postMap = postService.getDeptMap(convertList(list, AdminUserDO::getPostIds));
|
||||
List<PositionDO> positionDOs = positionService.getPositionList(convertList(list, AdminUserDO::getPositionId));
|
||||
Map<Long, PositionDO> positionMap = convertMap(positionDOs, PositionDO::getId);
|
||||
|
||||
//获取部门名称
|
||||
List<DeptDO> deptDO = deptService.getDeptTree();
|
||||
@ -264,7 +276,7 @@ public class UserController {
|
||||
|
||||
// 输出 Excel
|
||||
ExcelUtils.write(response, "用户数据.xls", "数据", UserRespVO.class,
|
||||
UserConvert.INSTANCE.convertList(list, deptMap, postMap),
|
||||
UserConvert.INSTANCE.convertList(list, deptMap, postMap, positionMap),
|
||||
1, getDeptNameFun(deptDO),
|
||||
2, getPostNameFun(postDO));
|
||||
}
|
||||
|
@ -42,13 +42,20 @@ public class UserRespVO{
|
||||
@ExcelProperty("部门名称")
|
||||
private String deptName;
|
||||
|
||||
@Schema(description = "岗位编号数组", example = "1")
|
||||
@Schema(description = "职称编号数组", example = "1")
|
||||
private Set<Long> postIds;
|
||||
|
||||
@Schema(description = "岗位名称", example = "总裁")
|
||||
@ExcelProperty("岗位")
|
||||
@Schema(description = "职称名称", example = "总裁")
|
||||
@ExcelProperty("职称")
|
||||
private String postName;
|
||||
|
||||
@Schema(description = "岗位编号数", example = "1")
|
||||
private Long positionId;
|
||||
|
||||
@Schema(description = "岗位名称", example = "1")
|
||||
@ExcelProperty("岗位")
|
||||
private String positionName;
|
||||
|
||||
@Schema(description = "手机号码", example = "15601691300")
|
||||
@ExcelProperty("手机号码")
|
||||
private String mobile;
|
||||
@ -83,6 +90,12 @@ public class UserRespVO{
|
||||
@DictFormat(DictTypeConstants.COMMON_STATUS)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "用户性质 | 字典值system_user_type", example = "1")
|
||||
private Integer userNature;
|
||||
|
||||
@Schema(description = "用户编制 | 字典值system_user_type", example = "2")
|
||||
private Integer userStaffing;
|
||||
|
||||
@Schema(description = "最后登录 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "192.168.1.1")
|
||||
// @ExcelProperty("最后登录IP")
|
||||
private String loginIp;
|
||||
@ -93,5 +106,4 @@ public class UserRespVO{
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
|
@ -39,9 +39,12 @@ public class UserSaveReqVO {
|
||||
@Schema(description = "部门ID", example = "我是一个用户")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "岗位编号数组", example = "1")
|
||||
@Schema(description = "职称编号数组", example = "1")
|
||||
private Set<Long> postIds;
|
||||
|
||||
@Schema(description = "岗位编号数", example = "1")
|
||||
private Long positionId;
|
||||
|
||||
@Schema(description = "用户邮箱", example = "yudao@iocoder.cn")
|
||||
@Email(message = "邮箱格式不正确")
|
||||
@Size(max = 50, message = "邮箱长度不能超过 50 个字符")
|
||||
|
@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSimpleRe
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.position.PositionDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import org.mapstruct.Mapper;
|
||||
@ -25,9 +26,11 @@ public interface UserConvert {
|
||||
|
||||
UserConvert INSTANCE = Mappers.getMapper(UserConvert.class);
|
||||
|
||||
default List<UserRespVO> convertList(List<AdminUserDO> list, Map<Long, DeptDO> deptMap, Map<Long, PostDO> postMap) {
|
||||
default List<UserRespVO> convertList(List<AdminUserDO> list, Map<Long, DeptDO> deptMap,
|
||||
Map<Long, PostDO> postMap, Map<Long, PositionDO> positionMap) {
|
||||
|
||||
return CollectionUtils.convertList(list, user -> convert(user, deptMap.get(user.getDeptId()), postMap.get(user.getPostIds().stream().findFirst().orElse(null))));
|
||||
return CollectionUtils.convertList(list, user -> convert(user, deptMap.get(user.getDeptId()),
|
||||
postMap.get(user.getPostIds().stream().findFirst().orElse(null)), positionMap.get(user.getPositionId())));
|
||||
}
|
||||
|
||||
default UserRespVO convert(AdminUserDO user, DeptDO dept) {
|
||||
@ -39,7 +42,7 @@ public interface UserConvert {
|
||||
return userVO;
|
||||
}
|
||||
|
||||
default UserRespVO convert(AdminUserDO user, DeptDO dept, PostDO postDO) {
|
||||
default UserRespVO convert(AdminUserDO user, DeptDO dept, PostDO postDO, PositionDO position) {
|
||||
UserRespVO userVO = BeanUtils.toBean(user, UserRespVO.class);
|
||||
if (dept != null) {
|
||||
userVO.setDeptName(dept.getName());
|
||||
@ -47,6 +50,9 @@ public interface UserConvert {
|
||||
if (postDO != null) {
|
||||
userVO.setPostName(postDO.getName());
|
||||
}
|
||||
if (position != null) {
|
||||
userVO.setPositionName(position.getName());
|
||||
}
|
||||
return userVO;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,42 @@
|
||||
package cn.iocoder.yudao.module.system.dal.dataobject.position;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 岗位信息 DO
|
||||
*
|
||||
* @author 符溶馨
|
||||
*/
|
||||
@TableName("system_position")
|
||||
@KeySequence("system_position_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PositionDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 岗位ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 岗位名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
@ -55,10 +55,14 @@ public class AdminUserDO extends TenantBaseDO {
|
||||
*/
|
||||
private Long deptId;
|
||||
/**
|
||||
* 岗位编号数组
|
||||
* 职称编号数组
|
||||
*/
|
||||
@TableField(typeHandler = JsonLongSetTypeHandler.class)
|
||||
private Set<Long> postIds;
|
||||
/**
|
||||
* 岗位编号
|
||||
*/
|
||||
private Long positionId;
|
||||
/**
|
||||
* 用户邮箱
|
||||
*/
|
||||
|
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.position;
|
||||
|
||||
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.system.controller.admin.position.vo.PositionPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.position.PositionDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 岗位信息 Mapper
|
||||
*
|
||||
* @author 符溶馨
|
||||
*/
|
||||
@Mapper
|
||||
public interface PositionMapper extends BaseMapperX<PositionDO> {
|
||||
|
||||
default PageResult<PositionDO> selectPage(PositionPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<PositionDO>()
|
||||
.likeIfPresent(PositionDO::getName, reqVO.getName())
|
||||
.eqIfPresent(PositionDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(PositionDO::getRemark, reqVO.getRemark())
|
||||
.betweenIfPresent(PositionDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(PositionDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package cn.iocoder.yudao.module.system.service.position;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.position.vo.PositionPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.position.vo.PositionSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.position.PositionDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 岗位信息 Service 接口
|
||||
*
|
||||
* @author 符溶馨
|
||||
*/
|
||||
public interface PositionService {
|
||||
|
||||
/**
|
||||
* 创建岗位信息
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createPosition(@Valid PositionSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新岗位信息
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updatePosition(@Valid PositionSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除岗位信息
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deletePosition(Long id);
|
||||
|
||||
/**
|
||||
* 获得岗位信息
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 岗位信息
|
||||
*/
|
||||
PositionDO getPosition(Long id);
|
||||
|
||||
/**
|
||||
* 获得岗位信息分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 岗位信息分页
|
||||
*/
|
||||
PageResult<PositionDO> getPositionPage(PositionPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得开启得 岗位列表
|
||||
* @return 岗位列表
|
||||
*/
|
||||
List<PositionDO> getPositionList();
|
||||
|
||||
/**
|
||||
* 获得指定得岗位列表
|
||||
*
|
||||
* @param ids 岗位编号数组
|
||||
* @return 岗位列表
|
||||
*/
|
||||
List<PositionDO> getPositionList(List<Long> ids);
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package cn.iocoder.yudao.module.system.service.position;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.position.vo.PositionPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.position.vo.PositionSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.position.PositionDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.position.PositionMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.POSITION_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 岗位信息 Service 实现类
|
||||
*
|
||||
* @author 符溶馨
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class PositionServiceImpl implements PositionService {
|
||||
|
||||
@Resource
|
||||
private PositionMapper positionMapper;
|
||||
|
||||
@Override
|
||||
public Long createPosition(PositionSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
PositionDO position = BeanUtils.toBean(createReqVO, PositionDO.class);
|
||||
positionMapper.insert(position);
|
||||
// 返回
|
||||
return position.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePosition(PositionSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validatePositionExists(updateReqVO.getId());
|
||||
// 更新
|
||||
PositionDO updateObj = BeanUtils.toBean(updateReqVO, PositionDO.class);
|
||||
positionMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePosition(Long id) {
|
||||
// 校验存在
|
||||
validatePositionExists(id);
|
||||
// 删除
|
||||
positionMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validatePositionExists(Long id) {
|
||||
if (positionMapper.selectById(id) == null) {
|
||||
throw exception(POSITION_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionDO getPosition(Long id) {
|
||||
return positionMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<PositionDO> getPositionPage(PositionPageReqVO pageReqVO) {
|
||||
return positionMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionDO> getPositionList() {
|
||||
return positionMapper.selectList(PositionDO::getStatus, CommonStatusEnum.ENABLE.getStatus());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionDO> getPositionList(List<Long> ids) {
|
||||
return positionMapper.selectList(new LambdaQueryWrapperX<PositionDO>()
|
||||
.eq(PositionDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
|
||||
.inIfPresent(PositionDO::getId, ids));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user