手机号验证及密码修改
parent
c1f71de612
commit
7fa63d12bc
|
|
@ -81,6 +81,14 @@ public class UserAddExe {
|
||||||
UserE userE = new UserE();
|
UserE userE = new UserE();
|
||||||
BeanUtils.copyProperties(cmd, userE);
|
BeanUtils.copyProperties(cmd, userE);
|
||||||
userE.initAdd(tenantId, userE);
|
userE.initAdd(tenantId, userE);
|
||||||
|
//校验手机号
|
||||||
|
// List<Integer> employmentFlagList = Arrays.asList(UserEmploymentFlagEnum.ON.getCode(), UserEmploymentFlagEnum.ENTRY_AUDIT.getCode(), UserEmploymentFlagEnum.RESIGNATION_AUDIT.getCode());
|
||||||
|
List<UserDO> userList = userRepository.getListByPhone( userE.getPhone(),null);
|
||||||
|
if (CollUtil.isNotEmpty(userList)) {
|
||||||
|
List<UserE> userEList = userCoConvertor.convertDOsToEs(userList);
|
||||||
|
userE.checkPhone(userEList);
|
||||||
|
}
|
||||||
|
|
||||||
CorpInfoDO corpInfoDO = corpInfoRepository.getById(userE.getCorpinfoId());
|
CorpInfoDO corpInfoDO = corpInfoRepository.getById(userE.getCorpinfoId());
|
||||||
String corpName = null;
|
String corpName = null;
|
||||||
UserEmploymentLogE userEmploymentLogE = new UserEmploymentLogE();
|
UserEmploymentLogE userEmploymentLogE = new UserEmploymentLogE();
|
||||||
|
|
@ -369,6 +377,13 @@ public class UserAddExe {
|
||||||
throw new BizException("未创建默认通用角色,请联系管理员");
|
throw new BizException("未创建默认通用角色,请联系管理员");
|
||||||
}
|
}
|
||||||
userE.setRoleId(roleId);
|
userE.setRoleId(roleId);
|
||||||
|
//校验手机号
|
||||||
|
List<Integer> employmentFlagList = Arrays.asList(UserEmploymentFlagEnum.ON.getCode(), UserEmploymentFlagEnum.ENTRY_AUDIT.getCode(), UserEmploymentFlagEnum.RESIGNATION_AUDIT.getCode());
|
||||||
|
List<UserDO> userList = userRepository.getListByPhone(userE.getPhone(),employmentFlagList);
|
||||||
|
if(CollUtil.isNotEmpty(userList)){
|
||||||
|
List<UserE> userEList = userCoConvertor.convertDOsToEs(userList);
|
||||||
|
userE.checkXGfPhone(userEList);
|
||||||
|
}
|
||||||
|
|
||||||
boolean res = false;
|
boolean res = false;
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
@ -74,10 +75,10 @@ public class UserRemoveExe {
|
||||||
try {
|
try {
|
||||||
//TODO 处理所有未完成的工作,如果是非固定人员,包括所有企业的未完成工作
|
//TODO 处理所有未完成的工作,如果是非固定人员,包括所有企业的未完成工作
|
||||||
// 如果是固定人员,判断是否离职
|
// 如果是固定人员,判断是否离职
|
||||||
List<UserDO> userDOList = userRepository.getListByPhone(userDO.getPhone());
|
List<Integer> employmentFlagList = Arrays.asList(UserEmploymentFlagEnum.ON.getCode(), UserEmploymentFlagEnum.RESIGNATION_AUDIT.getCode());
|
||||||
|
List<UserDO> userDOList = userRepository.getListByPhone(userDO.getPhone(),employmentFlagList);
|
||||||
//过滤出固定人员
|
//过滤出固定人员
|
||||||
List<UserDO> fixedUserDOList = userDOList.stream().filter(userDO1 -> UserEmploymentFlagEnum.ON.equals(userDO1.getEmploymentFlag().toString())).collect(Collectors.toList());
|
if(CollUtil.isNotEmpty(userDOList)){
|
||||||
if(CollUtil.isNotEmpty(fixedUserDOList)){
|
|
||||||
throw new BizException("您目前还有未离职信息,无法直接注销,请先在\"就职单位\"页面中离职");
|
throw new BizException("您目前还有未离职信息,无法直接注销,请先在\"就职单位\"页面中离职");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,9 @@ public class UserUpdateExe {
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void execute(UserUpdateCmd userUpdateCmd) {
|
public void execute(UserUpdateCmd userUpdateCmd) {
|
||||||
|
//pc端不允许修改固定和流动状态
|
||||||
|
userUpdateCmd.setFlowFlag(null);
|
||||||
|
|
||||||
UserE userE = new UserE();
|
UserE userE = new UserE();
|
||||||
BeanUtils.copyProperties(userUpdateCmd, userE);
|
BeanUtils.copyProperties(userUpdateCmd, userE);
|
||||||
// 对比用户老数据与要修改数据,查看是否涉及调岗及入职
|
// 对比用户老数据与要修改数据,查看是否涉及调岗及入职
|
||||||
|
|
@ -130,13 +133,11 @@ public class UserUpdateExe {
|
||||||
public boolean executePasswordRecover(AppUserRegisterCmd cmd) {
|
public boolean executePasswordRecover(AppUserRegisterCmd cmd) {
|
||||||
|
|
||||||
// 根据手机号查询用户信息
|
// 根据手机号查询用户信息
|
||||||
List<UserDO> listByPhone = userRepository.getListByPhone(cmd.getPhone());
|
List<UserDO> listByPhone = userRepository.getListByPhone(cmd.getPhone(),null);
|
||||||
|
|
||||||
UserE userE = new UserE();
|
UserE userE = new UserE();
|
||||||
userE.checkPassword(cmd.getNewPassword(), cmd.getConfirmPassword());
|
userE.checkPassword(cmd.getNewPassword(), cmd.getConfirmPassword());
|
||||||
if (!"123".equals(cmd.getPhoneCode())) {
|
if (!"123".equals(cmd.getPhoneCode())) {
|
||||||
|
|
||||||
|
|
||||||
// 获取redis验证码
|
// 获取redis验证码
|
||||||
Object phoneCodeObj = zcloudRedisUtil.get(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
|
Object phoneCodeObj = zcloudRedisUtil.get(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
|
||||||
if (phoneCodeObj == null || !phoneCodeObj.toString().equals(cmd.getPhoneCode())) {
|
if (phoneCodeObj == null || !phoneCodeObj.toString().equals(cmd.getPhoneCode())) {
|
||||||
|
|
|
||||||
|
|
@ -35,5 +35,7 @@ public interface UserCoConvertor {
|
||||||
ZcloudUserCo converCOToDubboCO(UserCO userCO);
|
ZcloudUserCo converCOToDubboCO(UserCO userCO);
|
||||||
|
|
||||||
List<UserXmfCO> converDOsToXgfCOs(List<UserDO> data);
|
List<UserXmfCO> converDOsToXgfCOs(List<UserDO> data);
|
||||||
|
|
||||||
|
List<UserE> convertDOsToEs(List<UserDO> userList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public class UserCorpRecordQueryExe {
|
||||||
return PageResponse.of(null, 0, userCorpRecordPageQry.getPageSize(), userCorpRecordPageQry.getPageIndex());
|
return PageResponse.of(null, 0, userCorpRecordPageQry.getPageSize(), userCorpRecordPageQry.getPageIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<UserDO> userDOList = userRepository.getListByPhone(userDO.getPhone());
|
List<UserDO> userDOList = userRepository.getListByPhone(userDO.getPhone(),null);
|
||||||
//获取id list
|
//获取id list
|
||||||
List<Long> userIdList = userDOList.stream().map(UserDO::getId).collect(Collectors.toList());
|
List<Long> userIdList = userDOList.stream().map(UserDO::getId).collect(Collectors.toList());
|
||||||
userCorpRecordPageQry.setEqUserId(null);
|
userCorpRecordPageQry.setEqUserId(null);
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ public class UserQueryExe {
|
||||||
}
|
}
|
||||||
//返回企业列表
|
//返回企业列表
|
||||||
//根据手机号获取用户列表
|
//根据手机号获取用户列表
|
||||||
List<UserDO> userDOList = userRepository.getListByPhone(cmd.getPhone());
|
List<UserDO> userDOList = userRepository.getListByPhone(cmd.getPhone(),null);
|
||||||
if(CollUtil.isEmpty(userDOList)){
|
if(CollUtil.isEmpty(userDOList)){
|
||||||
throw new BizException("用户不存在");
|
throw new BizException("用户不存在");
|
||||||
}
|
}
|
||||||
|
|
@ -247,7 +247,7 @@ public class UserQueryExe {
|
||||||
//返回企业列表
|
//返回企业列表
|
||||||
UserDO userDO = userRepository.getById(id);
|
UserDO userDO = userRepository.getById(id);
|
||||||
//根据手机号获取用户列表
|
//根据手机号获取用户列表
|
||||||
List<UserDO> userDOList = userRepository.getListByPhone(userDO.getPhone());
|
List<UserDO> userDOList = userRepository.getListByPhone(userDO.getPhone(),null);
|
||||||
|
|
||||||
List<Long> userIds = userDOList.stream().map(UserDO::getId).collect(Collectors.toList());
|
List<Long> userIds = userDOList.stream().map(UserDO::getId).collect(Collectors.toList());
|
||||||
List<UserCorpInfoDO> userCorpDOS = userRepository.getListByUserIds(userIds);
|
List<UserCorpInfoDO> userCorpDOS = userRepository.getListByUserIds(userIds);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||||
import com.alibaba.cola.dto.Response;
|
import com.alibaba.cola.dto.Response;
|
||||||
import com.alibaba.cola.exception.BizException;
|
import com.alibaba.cola.exception.BizException;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.jjb.saas.framework.auth.utils.AuthContext;
|
||||||
import com.jjb.saas.framework.domain.model.BaseE;
|
import com.jjb.saas.framework.domain.model.BaseE;
|
||||||
import com.jjb.saas.framework.utils.DataEncryptDecryptUtil;
|
import com.jjb.saas.framework.utils.DataEncryptDecryptUtil;
|
||||||
import com.zcloud.basic.info.domain.enums.CorpTypeEnum;
|
import com.zcloud.basic.info.domain.enums.CorpTypeEnum;
|
||||||
|
|
@ -297,6 +298,7 @@ public class UserE extends BaseE {
|
||||||
this.setNewPassword(Sm2Util.encryptHex(MD5.md5(newPassword), publicKey));
|
this.setNewPassword(Sm2Util.encryptHex(MD5.md5(newPassword), publicKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean checkUserPassword(String password, String content) {
|
public Boolean checkUserPassword(String password, String content) {
|
||||||
String s = DataEncryptDecryptUtil.sm2Decrypt(privateKey, publicKey, content);
|
String s = DataEncryptDecryptUtil.sm2Decrypt(privateKey, publicKey, content);
|
||||||
String s1 = MD5.md5(password);
|
String s1 = MD5.md5(password);
|
||||||
|
|
@ -317,6 +319,7 @@ public class UserE extends BaseE {
|
||||||
String inputMd5 = MD5.md5("1234");
|
String inputMd5 = MD5.md5("1234");
|
||||||
System.out.println(inputMd5);
|
System.out.println(inputMd5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOldFlowInfo(UserCorpE userCorpE) {
|
public void setOldFlowInfo(UserCorpE userCorpE) {
|
||||||
this.setDepartmentId(userCorpE.getDepartmentId());
|
this.setDepartmentId(userCorpE.getDepartmentId());
|
||||||
this.setPostId(userCorpE.getPostId());
|
this.setPostId(userCorpE.getPostId());
|
||||||
|
|
@ -336,5 +339,41 @@ public class UserE extends BaseE {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkPhone(List<UserE> userEList) {
|
||||||
|
if (CollUtil.isEmpty(userEList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//判断AuthContext.gettenantId在userList中是否存在
|
||||||
|
if (CollUtil.isNotEmpty(userEList)) {
|
||||||
|
//判断是否有当前企业
|
||||||
|
boolean flag = userEList.stream().anyMatch(userE -> userE.getCorpinfoId().equals(AuthContext.getTenantId()));
|
||||||
|
if (flag) {
|
||||||
|
//需要修改,不是提示
|
||||||
|
throw new BizException("当前手机号当前企业已存在");
|
||||||
|
}else{
|
||||||
|
throw new BizException("当前手机号已在其他企业存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkXGfPhone(List<UserE> userEList) {
|
||||||
|
|
||||||
|
if(UserFlowFlagEnum.FIXED.getCode().equals(this.getFlowFlag())){
|
||||||
|
this.checkPhone(userEList);
|
||||||
|
}else{
|
||||||
|
//判断在其他企业是否是固定人员
|
||||||
|
List<UserE> userList = userEList.stream().filter(userE -> UserFlowFlagEnum.FIXED.getCode().equals(userE.getFlowFlag())).collect(Collectors.toList());
|
||||||
|
if (CollUtil.isNotEmpty(userList)) {
|
||||||
|
throw new BizException("当前手机号已在其他企业属于固定人员");
|
||||||
|
}
|
||||||
|
//判断是否在当前企业存在
|
||||||
|
//判断是否有当前企业
|
||||||
|
boolean flag = userEList.stream().anyMatch(userE -> userE.getCorpinfoId().equals(AuthContext.getTenantId()));
|
||||||
|
if (flag) {
|
||||||
|
throw new BizException("当前手机号当前企业已存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ public interface UserRepository extends BaseRepository<UserDO> {
|
||||||
|
|
||||||
void checkUserIdCard(@NotNull(message = "主键id不能为空") Long id, String userIdCard);
|
void checkUserIdCard(@NotNull(message = "主键id不能为空") Long id, String userIdCard);
|
||||||
|
|
||||||
List<UserDO> getListByPhone(String phone);
|
List<UserDO> getListByPhone(String phone,List<Integer> employmentFlagList);
|
||||||
|
|
||||||
List<UserCorpInfoDO> getListByUserIds(List<Long> userIds);
|
List<UserCorpInfoDO> getListByUserIds(List<Long> userIds);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -201,10 +201,11 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
|
||||||
Map<String, Object> verifyParam = new HashMap<>();
|
Map<String, Object> verifyParam = new HashMap<>();
|
||||||
verifyParam.put("phone", params.get("phone"));
|
verifyParam.put("phone", params.get("phone"));
|
||||||
verifyParam.put("id", params.get("id"));
|
verifyParam.put("id", params.get("id"));
|
||||||
Integer count = userMapper.countUser(verifyParam);
|
//手机号验证改成提交时验证
|
||||||
|
/* Integer count = userMapper.countUser(verifyParam);
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
return Response.buildFailure("手机号已经存在,请联系管理员");
|
return Response.buildFailure("手机号已经存在,请联系管理员");
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
if (!ObjectUtils.isEmpty(params.get("userIdCard"))) {
|
if (!ObjectUtils.isEmpty(params.get("userIdCard"))) {
|
||||||
Map<String, Object> verifyParam = new HashMap<>();
|
Map<String, Object> verifyParam = new HashMap<>();
|
||||||
|
|
@ -383,7 +384,7 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
|
||||||
if(StringUtils.isEmpty( phone)){
|
if(StringUtils.isEmpty( phone)){
|
||||||
userChangePassword(id, password);
|
userChangePassword(id, password);
|
||||||
}else{
|
}else{
|
||||||
List<UserDO> userDOList = getListByPhone( phone);
|
List<UserDO> userDOList = getListByPhone( phone,null);
|
||||||
for (UserDO userDO1 : userDOList) {
|
for (UserDO userDO1 : userDOList) {
|
||||||
userChangePassword(userDO1.getId(), password);
|
userChangePassword(userDO1.getId(), password);
|
||||||
}
|
}
|
||||||
|
|
@ -470,8 +471,9 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
|
||||||
if(StringUtils.isEmpty( phone)){
|
if(StringUtils.isEmpty( phone)){
|
||||||
userChangePassword(userDO.getId(), userDO.getNewPassword());
|
userChangePassword(userDO.getId(), userDO.getNewPassword());
|
||||||
}else{
|
}else{
|
||||||
List<UserDO> userDOList = list(new QueryWrapper<UserDO>().eq("phone", phone));
|
List<UserDO> userDOList = getListByPhone( phone,null);
|
||||||
for (UserDO userDO1 : userDOList) {
|
for (UserDO userDO1 : userDOList) {
|
||||||
|
//过滤出在职,离职审核人员
|
||||||
userChangePassword(userDO1.getId(), userDO.getNewPassword());
|
userChangePassword(userDO1.getId(), userDO.getNewPassword());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -558,9 +560,13 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UserDO> getListByPhone(String phone) {
|
public List<UserDO> getListByPhone(String phone,List<Integer> employmentFlagList) {
|
||||||
QueryWrapper<UserDO> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<UserDO> queryWrapper = new QueryWrapper<>();
|
||||||
|
if(CollUtil.isNotEmpty(employmentFlagList)){
|
||||||
|
queryWrapper.in("employment_flag", employmentFlagList);
|
||||||
|
}
|
||||||
queryWrapper.eq("phone", phone);
|
queryWrapper.eq("phone", phone);
|
||||||
|
queryWrapper.orderByAsc("create_time");
|
||||||
return list(queryWrapper);
|
return list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue