Compare commits

..

No commits in common. "7fa63d12bcd7e3d4b4955c9263716dd7ca328fac" and "b38c52c2c29044082dac225e4d4dc941a2231ba2" have entirely different histories.

10 changed files with 30 additions and 90 deletions

View File

@ -81,14 +81,6 @@ 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();
@ -377,13 +369,6 @@ 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 {

View File

@ -26,7 +26,6 @@ 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;
@ -75,10 +74,10 @@ public class UserRemoveExe {
try { try {
//TODO 处理所有未完成的工作,如果是非固定人员,包括所有企业的未完成工作 //TODO 处理所有未完成的工作,如果是非固定人员,包括所有企业的未完成工作
// 如果是固定人员,判断是否离职 // 如果是固定人员,判断是否离职
List<Integer> employmentFlagList = Arrays.asList(UserEmploymentFlagEnum.ON.getCode(), UserEmploymentFlagEnum.RESIGNATION_AUDIT.getCode()); List<UserDO> userDOList = userRepository.getListByPhone(userDO.getPhone());
List<UserDO> userDOList = userRepository.getListByPhone(userDO.getPhone(),employmentFlagList);
//过滤出固定人员 //过滤出固定人员
if(CollUtil.isNotEmpty(userDOList)){ List<UserDO> fixedUserDOList = userDOList.stream().filter(userDO1 -> UserEmploymentFlagEnum.ON.equals(userDO1.getEmploymentFlag().toString())).collect(Collectors.toList());
if(CollUtil.isNotEmpty(fixedUserDOList)){
throw new BizException("您目前还有未离职信息,无法直接注销,请先在\"就职单位\"页面中离职"); throw new BizException("您目前还有未离职信息,无法直接注销,请先在\"就职单位\"页面中离职");
} }

View File

@ -80,9 +80,6 @@ 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);
// 对比用户老数据与要修改数据,查看是否涉及调岗及入职 // 对比用户老数据与要修改数据,查看是否涉及调岗及入职
@ -133,11 +130,13 @@ public class UserUpdateExe {
public boolean executePasswordRecover(AppUserRegisterCmd cmd) { public boolean executePasswordRecover(AppUserRegisterCmd cmd) {
// 根据手机号查询用户信息 // 根据手机号查询用户信息
List<UserDO> listByPhone = userRepository.getListByPhone(cmd.getPhone(),null); List<UserDO> listByPhone = userRepository.getListByPhone(cmd.getPhone());
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())) {

View File

@ -35,7 +35,5 @@ 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);
} }

View File

@ -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(),null); List<UserDO> userDOList = userRepository.getListByPhone(userDO.getPhone());
//获取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);

View File

@ -215,7 +215,7 @@ public class UserQueryExe {
} }
//返回企业列表 //返回企业列表
//根据手机号获取用户列表 //根据手机号获取用户列表
List<UserDO> userDOList = userRepository.getListByPhone(cmd.getPhone(),null); List<UserDO> userDOList = userRepository.getListByPhone(cmd.getPhone());
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(),null); List<UserDO> userDOList = userRepository.getListByPhone(userDO.getPhone());
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);

View File

@ -4,7 +4,6 @@ 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;
@ -163,12 +162,12 @@ public class UserE extends BaseE {
return StringUtils.isNotEmpty(userE.getUsername()) && return StringUtils.isNotEmpty(userE.getUsername()) &&
StringUtils.isNotEmpty(userE.getPhone()) && StringUtils.isNotEmpty(userE.getPhone()) &&
StringUtils.isNotEmpty(userE.getUserIdCard()) && StringUtils.isNotEmpty(userE.getUserIdCard()) &&
userE.getFlowFlag() != null; userE.getFlowFlag()!=null;
} }
public void initAdd(Long tenantId, UserE userE) { public void initAdd(Long tenantId, UserE userE) {
if (StringUtils.isEmpty(userE.getUserId())) { if(StringUtils.isEmpty(userE.getUserId())){
userE.setUserId(Tools.get32UUID()); userE.setUserId(Tools.get32UUID());
} }
userE.setTenantId(!ObjectUtils.isEmpty(userE.getTenantId()) ? userE.getTenantId() : tenantId); userE.setTenantId(!ObjectUtils.isEmpty(userE.getTenantId()) ? userE.getTenantId() : tenantId);
@ -177,17 +176,17 @@ public class UserE extends BaseE {
userE.setPassword(defaultPassword); userE.setPassword(defaultPassword);
} }
public void initFormOnboarding(Long corpinfoId, Long departmentId, String postName, String userId) { public void initFormOnboarding(Long corpinfoId, Long departmentId, String postName, String userId){
this.setCorpinfoId(corpinfoId); this.setCorpinfoId(corpinfoId);
this.setDepartmentId(departmentId); this.setDepartmentId(departmentId);
this.setPostName(postName); this.setPostName(postName);
this.setEmploymentFlag(UserEmploymentFlagEnum.ENTRY_AUDIT.getCode()); this.setEmploymentFlag(UserEmploymentFlagEnum.ENTRY_AUDIT.getCode());
if (StringUtils.isNotEmpty(userId)) { if(StringUtils.isNotEmpty(userId)){
this.setUserId(userId); this.setUserId(userId);
} }
} }
public void initFromRZ(Long corpinfoId, Long roleId, RzUserRecordE rzUserRecordE) { public void initFromRZ(Long corpinfoId, Long roleId, RzUserRecordE rzUserRecordE){
this.setCorpinfoId(corpinfoId); this.setCorpinfoId(corpinfoId);
this.setDepartmentId(corpinfoId); this.setDepartmentId(corpinfoId);
this.setName(rzUserRecordE.getEmployeeName()); this.setName(rzUserRecordE.getEmployeeName());
@ -291,15 +290,14 @@ public class UserE extends BaseE {
} }
public void encryptionPassword() { public void encryptionPassword() {
if (StringUtils.isNotEmpty(password)) { if(StringUtils.isNotEmpty(password)){
this.setPassword(Sm2Util.encryptHex(MD5.md5(password), publicKey)); this.setPassword(Sm2Util.encryptHex(MD5.md5(password), publicKey));
} }
if (StringUtils.isNotEmpty(newPassword)) { if (StringUtils.isNotEmpty(newPassword)) {
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);
return s.equalsIgnoreCase(s1); return s.equalsIgnoreCase(s1);
@ -312,14 +310,13 @@ public class UserE extends BaseE {
System.out.println(Sm2Util.encryptHex(MD5.md5("1234"), publicKey)); System.out.println(Sm2Util.encryptHex(MD5.md5("1234"), publicKey));
System.out.println(Sm2Util.encryptHex(MD5.md5("1234"), publicKey)); System.out.println(Sm2Util.encryptHex(MD5.md5("1234"), publicKey));
String sign = Sm2Util.sign(privateKey, "1234"); String sign = Sm2Util.sign(privateKey, "1234");
boolean verify = Sm2Util.verify(publicKey, "04cd0a62599ab4613c6f1c6af1e4eaf5e650fadfd1d4fd9b7350975011bf3bccdf31c7eda8096f182f44e5601bc99554057441370bb45a8baa3386e2b6fd21110b97e579df964612167ec264d8d9752fea3630ad4d67e1dd52defd3817ffa38a19966456574fa85e59bdb889d817ccac6763c90ffe2ba5fafd567188c7a6e4b098", sign); boolean verify = Sm2Util.verify(publicKey, "04cd0a62599ab4613c6f1c6af1e4eaf5e650fadfd1d4fd9b7350975011bf3bccdf31c7eda8096f182f44e5601bc99554057441370bb45a8baa3386e2b6fd21110b97e579df964612167ec264d8d9752fea3630ad4d67e1dd52defd3817ffa38a19966456574fa85e59bdb889d817ccac6763c90ffe2ba5fafd567188c7a6e4b098",sign);
System.out.println(verify); System.out.println(verify);
String s = DataEncryptDecryptUtil.sm2Decrypt(privateKey, publicKey, "04cd0a62599ab4613c6f1c6af1e4eaf5e650fadfd1d4fd9b7350975011bf3bccdf31c7eda8096f182f44e5601bc99554057441370bb45a8baa3386e2b6fd21110b97e579df964612167ec264d8d9752fea3630ad4d67e1dd52defd3817ffa38a19966456574fa85e59bdb889d817ccac6763c90ffe2ba5fafd567188c7a6e4b098"); String s = DataEncryptDecryptUtil.sm2Decrypt(privateKey, publicKey, "04cd0a62599ab4613c6f1c6af1e4eaf5e650fadfd1d4fd9b7350975011bf3bccdf31c7eda8096f182f44e5601bc99554057441370bb45a8baa3386e2b6fd21110b97e579df964612167ec264d8d9752fea3630ad4d67e1dd52defd3817ffa38a19966456574fa85e59bdb889d817ccac6763c90ffe2ba5fafd567188c7a6e4b098");
System.out.println(s); System.out.println(s);
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());
@ -331,7 +328,7 @@ public class UserE extends BaseE {
} }
public boolean verifyTransferFlow(UserE oldUserE, UserE newUserE) { public boolean verifyTransferFlow(UserE oldUserE, UserE newUserE) {
if (newUserE.getFlowFlag() == null) { if(newUserE.getFlowFlag() == null){
return false; return false;
} }
if (!oldUserE.getFlowFlag().equals(newUserE.getFlowFlag())) { if (!oldUserE.getFlowFlag().equals(newUserE.getFlowFlag())) {
@ -339,41 +336,5 @@ 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("当前手机号当前企业已存在");
}
}
}
} }

View File

@ -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<Integer> employmentFlagList); List<UserDO> getListByPhone(String phone);
List<UserCorpInfoDO> getListByUserIds(List<Long> userIds); List<UserCorpInfoDO> getListByUserIds(List<Long> userIds);
} }

View File

@ -201,11 +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"));
//手机号验证改成提交时验证 verifyParam.put("corpinfoId", AuthContext.getTenantId());
/* 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<>();
@ -384,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,null); List<UserDO> userDOList = getListByPhone( phone);
for (UserDO userDO1 : userDOList) { for (UserDO userDO1 : userDOList) {
userChangePassword(userDO1.getId(), password); userChangePassword(userDO1.getId(), password);
} }
@ -471,9 +471,8 @@ 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 = getListByPhone( phone,null); List<UserDO> userDOList = list(new QueryWrapper<UserDO>().eq("phone", phone));
for (UserDO userDO1 : userDOList) { for (UserDO userDO1 : userDOList) {
//过滤出在职,离职审核人员
userChangePassword(userDO1.getId(), userDO.getNewPassword()); userChangePassword(userDO1.getId(), userDO.getNewPassword());
} }
} }
@ -560,13 +559,9 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
} }
@Override @Override
public List<UserDO> getListByPhone(String phone,List<Integer> employmentFlagList) { public List<UserDO> getListByPhone(String phone) {
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);
} }

View File

@ -273,6 +273,9 @@
<if test="params.phone != null"> <if test="params.phone != null">
and phone = #{params.phone} and phone = #{params.phone}
</if> </if>
<if test="params.corpinfoId != null">
and corpinfo_id = #{params.corpinfoId}
</if>
</where> </where>
</select> </select>