人员管理根据原型调整以及优化
This commit is contained in:
parent
58032da00a
commit
af9fc57463
|
@ -43,8 +43,8 @@ public class RoleEntity extends AuditableEntity implements Serializable {
|
||||||
@TableField("role_key")
|
@TableField("role_key")
|
||||||
private String roleKey;
|
private String roleKey;
|
||||||
|
|
||||||
@ExcelProperty("1正常0禁用")
|
@ExcelProperty("0正常1禁用")
|
||||||
@ApiModelProperty("1正常0禁用")
|
@ApiModelProperty("0正常1禁用")
|
||||||
@TableField("status")
|
@TableField("status")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
|
|
@ -55,8 +55,8 @@ public class UserEntity extends AuditableEntity implements Serializable {
|
||||||
@TableField("salt")
|
@TableField("salt")
|
||||||
private String salt;
|
private String salt;
|
||||||
|
|
||||||
@ExcelProperty("1正常0禁用")
|
@ExcelProperty("0正常1禁用")
|
||||||
@ApiModelProperty("1正常0禁用")
|
@ApiModelProperty("0正常1禁用")
|
||||||
@TableField("status")
|
@TableField("status")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
@ -65,6 +65,21 @@ public class UserEntity extends AuditableEntity implements Serializable {
|
||||||
@TableField("name")
|
@TableField("name")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@ExcelProperty("用户编码")
|
||||||
|
@ApiModelProperty("用户编码")
|
||||||
|
@TableField("user_code")
|
||||||
|
private String userCode;
|
||||||
|
|
||||||
|
@ExcelProperty("用户类型")
|
||||||
|
@ApiModelProperty("用户类型")
|
||||||
|
@TableField("user_type")
|
||||||
|
private String userType;
|
||||||
|
|
||||||
|
@ExcelProperty("用户状态")
|
||||||
|
@ApiModelProperty("用户状态")
|
||||||
|
@TableField("user_status")
|
||||||
|
private String userStatus;
|
||||||
|
|
||||||
@ApiModelProperty("所属部门")
|
@ApiModelProperty("所属部门")
|
||||||
@TableField("dept_id")
|
@TableField("dept_id")
|
||||||
private String deptId;
|
private String deptId;
|
||||||
|
|
|
@ -17,6 +17,9 @@ public class UserListReq implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -10363935468256543L;
|
private static final long serialVersionUID = -10363935468256543L;
|
||||||
|
|
||||||
|
@ApiModelProperty("员工编码")
|
||||||
|
private String userCode;
|
||||||
|
|
||||||
@ApiModelProperty("账号")
|
@ApiModelProperty("账号")
|
||||||
private String account;
|
private String account;
|
||||||
|
|
||||||
|
@ -26,17 +29,14 @@ public class UserListReq implements Serializable {
|
||||||
@ApiModelProperty("所属部门id")
|
@ApiModelProperty("所属部门id")
|
||||||
private String deptId;
|
private String deptId;
|
||||||
|
|
||||||
@ApiModelProperty("岗位id")
|
|
||||||
private String postId;
|
|
||||||
|
|
||||||
@ApiModelProperty("手机号码")
|
@ApiModelProperty("手机号码")
|
||||||
private String mobile;
|
private String mobile;
|
||||||
|
|
||||||
@ApiModelProperty("邮箱")
|
@ApiModelProperty("在职状态,枚举UserStatusEnum")
|
||||||
private String email;
|
private String userStatus;
|
||||||
|
|
||||||
@ApiModelProperty("1正常0禁用")
|
@ApiModelProperty("员工性质,枚举UserTypeEnum")
|
||||||
private Integer status;
|
private String userType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import lombok.Data;
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author huise23
|
* @author huise23
|
||||||
|
@ -27,34 +28,42 @@ public class UserListResp implements Serializable {
|
||||||
@ApiModelProperty("账号")
|
@ApiModelProperty("账号")
|
||||||
private String account;
|
private String account;
|
||||||
|
|
||||||
@ApiModelProperty("1正常0禁用")
|
@ApiModelProperty("0正常1禁用")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@ApiModelProperty("姓名")
|
@ApiModelProperty("姓名")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty("员工编码")
|
||||||
|
private String userCode;
|
||||||
|
|
||||||
|
@ApiModelProperty("员工性质")
|
||||||
|
private String userType;
|
||||||
|
|
||||||
|
@ApiModelProperty("员工性质描述")
|
||||||
|
private String userTypeLabel;
|
||||||
|
|
||||||
|
@ApiModelProperty("在职状态")
|
||||||
|
private String userStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty("在职状态描述")
|
||||||
|
private String userStatusLabel;
|
||||||
|
|
||||||
@ApiModelProperty("所属部门名称")
|
@ApiModelProperty("所属部门名称")
|
||||||
private String deptName;
|
private String deptName;
|
||||||
|
|
||||||
|
@ApiModelProperty("角色名称")
|
||||||
|
private String roleName;
|
||||||
|
|
||||||
@ApiModelProperty("岗位名称")
|
@ApiModelProperty("岗位名称")
|
||||||
private String postName;
|
private String postName;
|
||||||
|
|
||||||
@ApiModelProperty("身份证")
|
|
||||||
private String identityCard;
|
|
||||||
|
|
||||||
@ApiModelProperty("手机号码")
|
@ApiModelProperty("手机号码")
|
||||||
private String mobile;
|
private String mobile;
|
||||||
|
|
||||||
@ApiModelProperty("邮箱")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private String email;
|
@ApiModelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
|
||||||
@ApiModelProperty("入职日期")
|
|
||||||
private LocalDate hiredate;
|
|
||||||
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
|
||||||
@ApiModelProperty("出生日期")
|
|
||||||
private LocalDate birthdate;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,19 +32,30 @@ public class UserReq implements Serializable {
|
||||||
@ApiModelProperty("头像地址")
|
@ApiModelProperty("头像地址")
|
||||||
private String avatar;
|
private String avatar;
|
||||||
|
|
||||||
@ApiModelProperty("1正常0禁用")
|
@ApiModelProperty("0正常1禁用")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@Size(groups = {ValidationGroup.Insert.class, ValidationGroup.Update.class}, max = 20, message = "姓名长度不能超过20字符")
|
@Size(groups = {ValidationGroup.Insert.class, ValidationGroup.Update.class}, max = 20, message = "姓名长度不能超过20字符")
|
||||||
@ApiModelProperty("姓名")
|
@ApiModelProperty("姓名")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@NotBlank(message = "员工性质不能为空")
|
||||||
|
@ApiModelProperty("员工性质")
|
||||||
|
private String userType;
|
||||||
|
|
||||||
|
@NotBlank(message = "在职状态不能为空")
|
||||||
|
@ApiModelProperty("在职状态")
|
||||||
|
private String userStatus;
|
||||||
|
|
||||||
@ApiModelProperty("所属部门")
|
@ApiModelProperty("所属部门")
|
||||||
private String deptId;
|
private String deptId;
|
||||||
|
|
||||||
@ApiModelProperty("岗位")
|
@ApiModelProperty("岗位")
|
||||||
private List<String> postIds;
|
private List<String> postIds;
|
||||||
|
|
||||||
|
@ApiModelProperty("角色")
|
||||||
|
private List<String> roleIds;
|
||||||
|
|
||||||
@Pattern(groups = {ValidationGroup.Insert.class, ValidationGroup.Update.class}, regexp = "^$|\\d(?:\\d{15}|\\d{17})$", message = "身份证号码格式不正确")
|
@Pattern(groups = {ValidationGroup.Insert.class, ValidationGroup.Update.class}, regexp = "^$|\\d(?:\\d{15}|\\d{17})$", message = "身份证号码格式不正确")
|
||||||
@ApiModelProperty("身份证")
|
@ApiModelProperty("身份证")
|
||||||
private String identityCard;
|
private String identityCard;
|
||||||
|
|
|
@ -22,18 +22,24 @@ public class UserResp extends UserReq implements Serializable{
|
||||||
@ApiModelProperty("用户名")
|
@ApiModelProperty("用户名")
|
||||||
private String userId;
|
private String userId;
|
||||||
|
|
||||||
@ApiModelProperty("账号")
|
|
||||||
private String account;
|
|
||||||
|
|
||||||
@ApiModelProperty("所属部门")
|
@ApiModelProperty("所属部门")
|
||||||
private String deptName;
|
private String deptName;
|
||||||
|
|
||||||
@ApiModelProperty("岗位,多个岗位英文逗号隔开")
|
@ApiModelProperty("岗位,多个岗位英文逗号隔开")
|
||||||
private String postName;
|
private String postName;
|
||||||
|
|
||||||
|
@ApiModelProperty("角色,多个角色英文逗号隔开")
|
||||||
|
private String roleName;
|
||||||
|
|
||||||
@ApiModelProperty("学历描述")
|
@ApiModelProperty("学历描述")
|
||||||
private String educationLabel;
|
private String educationLabel;
|
||||||
|
|
||||||
|
@ApiModelProperty("员工性质描述")
|
||||||
|
private String userTypeLabel;
|
||||||
|
|
||||||
|
@ApiModelProperty("在职状态描述")
|
||||||
|
private String userStatusLabel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.dite.znpt.util.ValidationGroup;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
@ -17,6 +18,7 @@ import java.util.List;
|
||||||
* @description
|
* @description
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
@ApiModel("用户角色绑定请求实体")
|
@ApiModel("用户角色绑定请求实体")
|
||||||
public class UserRoleReq implements Serializable {
|
public class UserRoleReq implements Serializable {
|
||||||
@Serial
|
@Serial
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.dite.znpt.enums;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: gaoxiong
|
||||||
|
* @Date: 2025/6/23 22:38
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum UserStatusEnum {
|
||||||
|
|
||||||
|
EMPLOYED("EMPLOYED", "在职"),
|
||||||
|
DIMISSION("DIMISSION", "正常离职"),
|
||||||
|
ABNORMAL_DIMISSION("ABNORMAL_DIMISSION", "非正常离职");
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final String desc;
|
||||||
|
|
||||||
|
UserStatusEnum(String code, String desc){
|
||||||
|
this.code = code;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UserStatusEnum getByCode(String code){
|
||||||
|
for (UserStatusEnum e : UserStatusEnum.values() ) {
|
||||||
|
if(e.code.equals(code)){
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDescByCode(String code){
|
||||||
|
UserStatusEnum e = getByCode(code);
|
||||||
|
return null == e ? null : e.desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<JSONObject> listAll(){
|
||||||
|
List<JSONObject> list = new ArrayList<>(UserStatusEnum.values().length);
|
||||||
|
for (UserStatusEnum e : UserStatusEnum.values() ) {
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.set(e.code, e.desc);
|
||||||
|
list.add(jsonObject);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.dite.znpt.enums;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: gaoxiong
|
||||||
|
* @Date: 2025/6/23 22:38
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum UserTypeEnum {
|
||||||
|
|
||||||
|
PERMANENT("PERMANENT", "正式工"),
|
||||||
|
TEMPORARY("TEMPORARY", "临时工");
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final String desc;
|
||||||
|
|
||||||
|
UserTypeEnum(String code, String desc){
|
||||||
|
this.code = code;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UserTypeEnum getByCode(String code){
|
||||||
|
for (UserTypeEnum e : UserTypeEnum.values() ) {
|
||||||
|
if(e.code.equals(code)){
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDescByCode(String code){
|
||||||
|
UserTypeEnum e = getByCode(code);
|
||||||
|
return null == e ? null : e.desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<JSONObject> listAll(){
|
||||||
|
List<JSONObject> list = new ArrayList<>(UserTypeEnum.values().length);
|
||||||
|
for (UserTypeEnum e : UserTypeEnum.values() ) {
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.set(e.code, e.desc);
|
||||||
|
list.add(jsonObject);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
|
@ -61,7 +61,7 @@ public class AuthServiceImpl implements AuthService {
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
return Result.error(Constants.PASSWORD_EXCEPTION, Constants.PASSWORD_EXCEPTION_MESSAGE);
|
return Result.error(Constants.PASSWORD_EXCEPTION, Constants.PASSWORD_EXCEPTION_MESSAGE);
|
||||||
}
|
}
|
||||||
if(!user.getStatus().equals(Constants.STATUS_0)){
|
if(!user.getStatus().equals(Constants.STATUS_1)){
|
||||||
return Result.error(Constants.USER_DISABLE_EXCEPTION, Constants.USER_DISABLE_EXCEPTION_MESSAGE);
|
return Result.error(Constants.USER_DISABLE_EXCEPTION, Constants.USER_DISABLE_EXCEPTION_MESSAGE);
|
||||||
}
|
}
|
||||||
if(user.getIsDefaultPassword()){
|
if(user.getIsDefaultPassword()){
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class CertificationServiceImpl extends ServiceImpl<CertificationMapper, C
|
||||||
|
|
||||||
private CertificationEntity validation(String certificationId, CertificationReq req) {
|
private CertificationEntity validation(String certificationId, CertificationReq req) {
|
||||||
UserEntity user = userService.getById(req.getUserId());
|
UserEntity user = userService.getById(req.getUserId());
|
||||||
if(null == user || !Constants.DEL_FLAG_0.equals(user.getDelFlag()) || !Constants.STATUS_0.equals(user.getStatus())){
|
if(null == user || !Constants.DEL_FLAG_0.equals(user.getDelFlag()) || !Constants.STATUS_1.equals(user.getStatus())){
|
||||||
throw new ServiceException(Message.USER_ID_NOT_EXIST_OR_ILLEGAL);
|
throw new ServiceException(Message.USER_ID_NOT_EXIST_OR_ILLEGAL);
|
||||||
}
|
}
|
||||||
if(null == CertificationEnum.getByCode(req.getCertificationType())){
|
if(null == CertificationEnum.getByCode(req.getCertificationType())){
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class UserPostServiceImpl extends ServiceImpl<UserPostMapper, UserPostEnt
|
||||||
if (CollUtil.isEmpty(postIds)) {
|
if (CollUtil.isEmpty(postIds)) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
List<PostEntity> posts= postService.listByIds(postIds).stream().filter(post -> Constants.STATUS_0.equals(post.getStatus())).toList();
|
List<PostEntity> posts= postService.listByIds(postIds).stream().filter(post -> Constants.STATUS_1.equals(post.getStatus())).toList();
|
||||||
return Converts.INSTANCE.toPostResp(posts);
|
return Converts.INSTANCE.toPostResp(posts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public class UserPostServiceImpl extends ServiceImpl<UserPostMapper, UserPostEnt
|
||||||
@Override
|
@Override
|
||||||
public void bindPostUser(String postId, List<String> userIds) {
|
public void bindPostUser(String postId, List<String> userIds) {
|
||||||
PostEntity post = postService.getById(postId);
|
PostEntity post = postService.getById(postId);
|
||||||
if(null == post || !Constants.STATUS_0.equals(post.getStatus())){
|
if(null == post || !Constants.STATUS_1.equals(post.getStatus())){
|
||||||
throw new ServiceException(Message.POST_ID_NOT_EXIST_OR_ILLEGAL);
|
throw new ServiceException(Message.POST_ID_NOT_EXIST_OR_ILLEGAL);
|
||||||
}
|
}
|
||||||
List<UserEntity> userList = userService.listByIds(userIds).stream().filter(userEntity -> !Constants.DEL_FLAG_1.equals(userEntity.getDelFlag())).toList();
|
List<UserEntity> userList = userService.listByIds(userIds).stream().filter(userEntity -> !Constants.DEL_FLAG_1.equals(userEntity.getDelFlag())).toList();
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRoleEnt
|
||||||
if (CollUtil.isEmpty(roleIds)) {
|
if (CollUtil.isEmpty(roleIds)) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
List<RoleEntity> roles = roleService.listByIds(roleIds).stream().filter(role -> Constants.DEL_FLAG_0.equals(role.getDelFlag()) && Constants.STATUS_0.equals(role.getStatus())).toList();
|
List<RoleEntity> roles = roleService.listByIds(roleIds).stream().filter(role -> Constants.DEL_FLAG_0.equals(role.getDelFlag()) && Constants.STATUS_1.equals(role.getStatus())).toList();
|
||||||
return Converts.INSTANCE.toRoleResp(roles);
|
return Converts.INSTANCE.toRoleResp(roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,24 +6,19 @@ import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.dite.znpt.constant.Constants;
|
import com.dite.znpt.constant.Constants;
|
||||||
import com.dite.znpt.constant.Message;
|
import com.dite.znpt.constant.Message;
|
||||||
import com.dite.znpt.converts.Converts;
|
import com.dite.znpt.converts.Converts;
|
||||||
import com.dite.znpt.domain.entity.PostEntity;
|
import com.dite.znpt.domain.entity.*;
|
||||||
import com.dite.znpt.domain.entity.UserEntity;
|
import com.dite.znpt.domain.vo.*;
|
||||||
import com.dite.znpt.domain.entity.UserPostEntity;
|
import com.dite.znpt.enums.UserStatusEnum;
|
||||||
import com.dite.znpt.domain.vo.UserListReq;
|
import com.dite.znpt.enums.UserTypeEnum;
|
||||||
import com.dite.znpt.domain.vo.UserListResp;
|
|
||||||
import com.dite.znpt.domain.vo.UserReq;
|
|
||||||
import com.dite.znpt.domain.vo.UserResp;
|
|
||||||
import com.dite.znpt.exception.ServiceException;
|
import com.dite.znpt.exception.ServiceException;
|
||||||
import com.dite.znpt.mapper.UserMapper;
|
import com.dite.znpt.mapper.UserMapper;
|
||||||
import com.dite.znpt.service.DeptService;
|
import com.dite.znpt.service.*;
|
||||||
import com.dite.znpt.service.PostService;
|
|
||||||
import com.dite.znpt.service.UserPostService;
|
|
||||||
import com.dite.znpt.service.UserService;
|
|
||||||
import com.dite.znpt.util.PageUtil;
|
import com.dite.znpt.util.PageUtil;
|
||||||
import com.dite.znpt.util.PasswordUtil;
|
import com.dite.znpt.util.PasswordUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
@ -33,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,14 +46,22 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
|
||||||
@Value("${password.enable-default:true}")
|
@Value("${password.enable-default:true}")
|
||||||
private Boolean enableDefaultPassword;
|
private Boolean enableDefaultPassword;
|
||||||
|
|
||||||
|
private static final String USER_CODE_PREFIX = "YG";
|
||||||
|
private static final Integer USER_CODE_LENGTH = 4;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DeptService deptService;
|
private DeptService deptService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private PostService postService;
|
private PostService postService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RoleService roleService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private UserPostService userPostService;
|
private UserPostService userPostService;
|
||||||
|
@Resource
|
||||||
|
private UserRoleService userRoleService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 功能描述:分页查询用户信息列表
|
* 功能描述:分页查询用户信息列表
|
||||||
|
@ -83,7 +87,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public List<UserListResp> list(UserListReq req) {
|
public List<UserListResp> list(UserListReq req) {
|
||||||
return this.baseMapper.queryBySelective(req);
|
return this.baseMapper.queryBySelective(req).stream().map(resp -> {
|
||||||
|
resp.setUserTypeLabel(UserTypeEnum.getDescByCode(resp.getUserType()));
|
||||||
|
resp.setUserStatusLabel(UserStatusEnum.getDescByCode(resp.getUserStatus()));
|
||||||
|
return resp;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,13 +109,18 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
|
||||||
if(StrUtil.isNotBlank(userResp.getDeptId())){
|
if(StrUtil.isNotBlank(userResp.getDeptId())){
|
||||||
userResp.setUserId(deptService.getById(userResp.getDeptId()).getDeptName());
|
userResp.setUserId(deptService.getById(userResp.getDeptId()).getDeptName());
|
||||||
}
|
}
|
||||||
|
userResp.setUserTypeLabel(UserTypeEnum.getDescByCode(userResp.getUserType()));
|
||||||
|
userResp.setUserStatusLabel(UserStatusEnum.getDescByCode(userResp.getUserStatus()));
|
||||||
List<UserPostEntity> userPostList = userPostService.list(Wrappers.lambdaQuery(UserPostEntity.class).eq(UserPostEntity::getUserId, userId));
|
List<UserPostEntity> userPostList = userPostService.list(Wrappers.lambdaQuery(UserPostEntity.class).eq(UserPostEntity::getUserId, userId));
|
||||||
if(CollUtil.isNotEmpty(userPostList)){
|
if(CollUtil.isNotEmpty(userPostList)){
|
||||||
String postName = postService.listByIds(
|
String postName = postService.listByIds(userPostList.stream().map(UserPostEntity::getPostId).toList()).stream().map(PostEntity::getPostName).collect(Collectors.joining(StrUtil.COMMA));
|
||||||
userPostList.stream().map(UserPostEntity::getPostId).toList()
|
|
||||||
).stream().map(PostEntity::getPostName).collect(Collectors.joining(StrUtil.COMMA));
|
|
||||||
userResp.setPostName(postName);
|
userResp.setPostName(postName);
|
||||||
}
|
}
|
||||||
|
List<UserRoleEntity> userRoleList = userRoleService.list(Wrappers.lambdaQuery(UserRoleEntity.class).eq(UserRoleEntity::getUserId, userId));
|
||||||
|
if(CollUtil.isNotEmpty(userRoleList)){
|
||||||
|
String roleName = roleService.listByIds(userRoleList.stream().map(UserRoleEntity::getRoleId).toList()).stream().map(RoleEntity::getRoleName).collect(Collectors.joining(StrUtil.COMMA));
|
||||||
|
userResp.setRoleName(roleName);
|
||||||
|
}
|
||||||
return userResp;
|
return userResp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,13 +140,48 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
|
||||||
entity.setSalt(salt);
|
entity.setSalt(salt);
|
||||||
String password = enableDefaultPassword ? defaultPassword : PasswordUtil.generatePassword();
|
String password = enableDefaultPassword ? defaultPassword : PasswordUtil.generatePassword();
|
||||||
entity.setPassword(SaSecureUtil.md5(req.getAccount().concat(password).concat(salt)));
|
entity.setPassword(SaSecureUtil.md5(req.getAccount().concat(password).concat(salt)));
|
||||||
|
entity.setUserCode(userCodeGenerator());
|
||||||
this.save(entity);
|
this.save(entity);
|
||||||
if(CollUtil.isNotEmpty(req.getPostIds())){
|
if(CollUtil.isNotEmpty(req.getPostIds())){
|
||||||
userPostService.bindUserPost(entity.getUserId(), req.getPostIds());
|
List<String> postIds = postService.listByIds(req.getPostIds()).stream().filter(post -> Constants.STATUS_0.equals(post.getPostId())).map(PostEntity::getPostId).toList();
|
||||||
|
if(CollUtil.isNotEmpty(postIds)){
|
||||||
|
userPostService.bindUserPost(entity.getUserId(),postIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(CollUtil.isNotEmpty(req.getRoleIds())){
|
||||||
|
List<String> roleIds = roleService.listByIds(req.getRoleIds()).stream().filter(role -> Constants.STATUS_0.equals(role.getStatus())).map(RoleEntity::getRoleId).toList();
|
||||||
|
if(CollUtil.isNotEmpty(roleIds)){
|
||||||
|
userRoleService.bindUserRole(new UserRoleReq().setUserId(entity.getUserId()).setRoleIds(req.getRoleIds()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return SaBase64Util.encode(password);
|
return SaBase64Util.encode(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String userCodeGenerator(){
|
||||||
|
QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<UserEntity>();
|
||||||
|
queryWrapper.select("max(user_code) as userCode");
|
||||||
|
List<Map<String, Object>> list = this.baseMapper.selectMaps(queryWrapper);
|
||||||
|
if(CollUtil.isEmpty(list)){
|
||||||
|
return USER_CODE_PREFIX.concat("0001");
|
||||||
|
}else {
|
||||||
|
String maxUserCode = list.get(0).get("userCode").toString();
|
||||||
|
String num = maxUserCode.replace(USER_CODE_PREFIX, StrUtil.EMPTY);
|
||||||
|
Integer nextNum = Integer.parseInt(num) + 1;
|
||||||
|
if(nextNum.toString().length() < USER_CODE_LENGTH){
|
||||||
|
return USER_CODE_PREFIX.concat(StrUtil.fillBefore(nextNum.toString(), '0', USER_CODE_LENGTH));
|
||||||
|
}else {
|
||||||
|
return USER_CODE_PREFIX.concat(nextNum.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println(Integer.parseInt("00001") + 1);
|
||||||
|
System.out.println(StrUtil.fillBefore("2",'0', 5));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 功能描述:更新用户信息
|
* 功能描述:更新用户信息
|
||||||
*
|
*
|
||||||
|
|
|
@ -8,13 +8,18 @@
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="queryBySelective" resultType="com.dite.znpt.domain.vo.UserListResp">
|
<select id="queryBySelective" resultType="com.dite.znpt.domain.vo.UserListResp">
|
||||||
SELECT
|
SELECT u.user_id, u.account, u.status, u.name, u.user_code, u.user_type, u.user_status, d.dept_name, u.mobile, u.create_time,
|
||||||
u.user_id, u.account, u.status, u.name, d.dept_name, u.identity_card, u.mobile, u.email, u.hiredate, u.birthdate, GROUP_CONCAT(p.post_name) AS post_name
|
GROUP_CONCAT(r.role_name) AS role_name,GROUP_CONCAT(p.post_name) AS post_name
|
||||||
FROM user u
|
FROM user u
|
||||||
LEFT JOIN dept d ON u.dept_id = d.dept_id
|
LEFT JOIN dept d ON u.dept_id = d.dept_id
|
||||||
LEFT JOIN user_post up ON u.user_id = up.user_id
|
LEFT JOIN user_role ur ON u.user_id = ur.user_id
|
||||||
LEFT JOIN post p ON up.post_id = p.post_id
|
LEFT JOIN role r ON ur.role_id = r.role_id
|
||||||
|
LEFT JOIN user_post up ON up.user_id = u.user_id
|
||||||
|
LEFT JOIN post p ON p.post_id = up.post_id
|
||||||
<where>
|
<where>
|
||||||
|
<if test="userCode != null and userCode != ''">
|
||||||
|
AND u.user_code LIKE concat ('%', #{userCode}, '%')
|
||||||
|
</if>
|
||||||
<if test="account != null and account != ''">
|
<if test="account != null and account != ''">
|
||||||
AND u.account LIKE concat ('%', #{account}, '%')
|
AND u.account LIKE concat ('%', #{account}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
@ -24,20 +29,17 @@
|
||||||
<if test="mobile != null and mobile != ''">
|
<if test="mobile != null and mobile != ''">
|
||||||
AND u.mobile LIKE concat ('%', #{mobile}, '%')
|
AND u.mobile LIKE concat ('%', #{mobile}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="email != null and email != ''">
|
|
||||||
AND u.email LIKE concat ('%', #{email}, '%')
|
|
||||||
</if>
|
|
||||||
<if test="deptId != null and deptId != ''">
|
<if test="deptId != null and deptId != ''">
|
||||||
AND d.dept_id = #{deptId}
|
AND d.dept_id = #{deptId}
|
||||||
</if>
|
</if>
|
||||||
<if test="postId != null and postId != ''">
|
<if test="userStatus != null and userStatus!=''">
|
||||||
AND p.post_id = #{postId}
|
AND u.user_status = #{userStatus}
|
||||||
</if>
|
</if>
|
||||||
<if test="status != null">
|
<if test="userType != null and userType!=''">
|
||||||
AND u.status = #{status}
|
AND u.user_Type = #{userType}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
GROUP BY u.user_id, u.account, u.status, u.name, d.dept_name, u.identity_card, u.mobile, u.email, u.hiredate, u.birthdate
|
GROUP BY u.user_id, u.account, u.status, u.name, u.user_code, u.user_type, u.user_status, d.dept_name, u.mobile, u.create_time
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue