实现用户管理功能增强与企业类型密码策略
parent
da25463bf9
commit
5381c299e6
|
|
@ -2,20 +2,22 @@ package com.zcloud.basic.info.facade;
|
|||
|
||||
import com.alibaba.cola.dto.MultiResponse;
|
||||
import com.alibaba.cola.dto.SingleResponse;
|
||||
import com.zcloud.basic.info.api.CorpInfoServiceI;
|
||||
import com.zcloud.basic.info.api.UserServiceI;
|
||||
import com.zcloud.basic.info.command.convertor.CorpInfoCoConvertor;
|
||||
import com.zcloud.basic.info.command.convertor.UserCoConvertor;
|
||||
import com.zcloud.basic.info.dto.clientobject.UserCO;
|
||||
import com.zcloud.basic.info.persistence.dataobject.UserDO;
|
||||
import com.zcloud.basic.info.persistence.repository.UserRepository;
|
||||
import com.zcloud.gbscommon.utils.PageQueryHelper;
|
||||
import com.zcloud.gbscommon.zclouduser.facade.ZcloudUserFacade;
|
||||
import com.zcloud.gbscommon.zclouduser.request.ZcloudUserQry;
|
||||
import com.zcloud.gbscommon.zclouduser.response.ZcloudUserCo;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lin
|
||||
|
|
@ -27,6 +29,9 @@ public class ZcloudUserFacadeImpl implements ZcloudUserFacade {
|
|||
@Resource
|
||||
private UserCoConvertor userCoConvertor;
|
||||
|
||||
@Resource
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Override
|
||||
public MultiResponse<ZcloudUserCo> listByUserIdAndDeptId() {
|
||||
System.out.println("listByUserIdAndDeptId");
|
||||
|
|
@ -71,4 +76,13 @@ public class ZcloudUserFacadeImpl implements ZcloudUserFacade {
|
|||
List<ZcloudUserCo> zcloudUserCo = userCoConvertor.converCOsToDubboCOs(users);
|
||||
return MultiResponse.of(zcloudUserCo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiResponse<ZcloudUserCo> listUserByCorpInfoId(ZcloudUserQry zcloudUserQry) {
|
||||
Map<String, Object> parmas = PageQueryHelper.toHashMap(zcloudUserQry);
|
||||
List<UserDO> userList = userRepository.listAll(parmas);
|
||||
List<ZcloudUserCo> zcloudUserCos = userCoConvertor.converDOsToDubboCOs(userList);
|
||||
return MultiResponse.of(zcloudUserCos);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,10 +57,12 @@ public class CorpInfoAddExe {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long execute(CorpInfoAddCmd cmd) {
|
||||
CorpInfoE examTypeE = new CorpInfoE();
|
||||
if (!ObjectUtils.isEmpty(cmd.getCode())){
|
||||
List<CorpInfoDO> corpinfoByCode = corpInfoRepository.getCorpinfoByCode(cmd.getCode());
|
||||
examTypeE.checkList(corpinfoByCode == null ? 0 : corpinfoByCode.size());
|
||||
}
|
||||
try {
|
||||
examTypeE.initPassWord();
|
||||
examTypeE.initPassWord(cmd.getType());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -62,9 +63,10 @@ public class CorpInfoUpdateExe {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public void execute(CorpInfoUpdateCmd corpInfoUpdateCmd) {
|
||||
CorpInfoE corpInfoE = new CorpInfoE();
|
||||
|
||||
if (!ObjectUtils.isEmpty(corpInfoUpdateCmd.getCode())){
|
||||
List<CorpInfoDO> corpinfoByCodeAndId = corpInfoRepository.getCorpinfoByCodeAndId(corpInfoUpdateCmd.getCode(), corpInfoUpdateCmd.getId());
|
||||
corpInfoE.checkList(corpinfoByCodeAndId == null ? 0 : corpinfoByCodeAndId.size());
|
||||
}
|
||||
|
||||
BeanUtils.copyProperties(corpInfoUpdateCmd, corpInfoE);
|
||||
boolean res = corpInfoGateway.update(corpInfoE);
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ public class UserAddExe {
|
|||
try {
|
||||
userE.setUserType(CorpTypeEnum.getUserTypeByCode(corpInfoDO.getType()));
|
||||
|
||||
userE.resetPassword();
|
||||
userE.resetPassword(corpInfoDO.getType());
|
||||
res = userGateway.add(userE);
|
||||
if (corpInfoDO != null && !ObjectUtils.isEmpty(corpInfoDO.getCorpName())) {
|
||||
corpName = corpInfoDO.getCorpName();
|
||||
|
|
@ -505,6 +505,8 @@ public class UserAddExe {
|
|||
}
|
||||
}
|
||||
//userE.setUserId(userList.get(0).getUserId());
|
||||
userE.setPassword( userList.get(0).getPassword());
|
||||
|
||||
}
|
||||
|
||||
boolean res = false;
|
||||
|
|
|
|||
|
|
@ -118,11 +118,12 @@ public class UserUpdateExe {
|
|||
}
|
||||
if(detail.getData() != null){
|
||||
// 调用底座修改账号
|
||||
userGateway.updateByGBS(userE);
|
||||
userE.resetPassword(corpInfoDO.getType());
|
||||
userGateway.updateInfoAndPasswordByGBS(userE);
|
||||
if(!userE.getPhone().equals(userDO.getPhone())){
|
||||
// 修改账号了,需要重置密码
|
||||
UserE u = new UserE();
|
||||
u.resetPassword();
|
||||
u.resetPassword(corpInfoDO.getType());
|
||||
for (Long userId : userIds) {
|
||||
userRepository.changePassword(userId, u.getPassword());
|
||||
}
|
||||
|
|
@ -154,11 +155,12 @@ public class UserUpdateExe {
|
|||
}
|
||||
if(detail.getData() != null){
|
||||
// 调用底座修改账号
|
||||
userGateway.updateByGBS(userE);
|
||||
userGateway.updateInfoAndPasswordByGBS(userE);
|
||||
userE.resetPassword(corpInfoDO.getType());
|
||||
if(!userE.getPhone().equals(userDO.getPhone())){
|
||||
// 账号修改了,需要重置密码
|
||||
UserE u = new UserE();
|
||||
u.resetPassword();
|
||||
u.resetPassword(corpInfoDO.getType());
|
||||
userRepository.changePassword(userDO.getId(), u.getPassword());
|
||||
}
|
||||
}
|
||||
|
|
@ -245,7 +247,9 @@ public class UserUpdateExe {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public void executeChangePassword(Long id) {
|
||||
UserE userE = new UserE();
|
||||
userE.resetPassword();
|
||||
UserDO userDO = userRepository.getById( id);
|
||||
CorpInfoDO corpInfoDO = corpInfoRepository.getById(userDO.getCorpinfoId());
|
||||
userE.resetPassword(corpInfoDO.getType());
|
||||
userRepository.changePassword(id, userE.getPassword());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,5 +37,7 @@ public interface UserCoConvertor {
|
|||
List<UserXmfCO> converDOsToXgfCOs(List<UserDO> data);
|
||||
|
||||
List<UserE> convertDOsToEs(List<UserDO> userList);
|
||||
|
||||
List<ZcloudUserCo> converDOsToDubboCOs(List<UserDO> userCOList);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,11 +48,9 @@ public class AppUserInfoCmd extends Command {
|
|||
private String nationName;
|
||||
|
||||
@ApiModelProperty(value = "现住址", name = "currentAddress", required = true)
|
||||
@NotEmpty(message = "现住址不能为空")
|
||||
private String currentAddress;
|
||||
|
||||
@ApiModelProperty(value = "户口所在地", name = "locationAddress", required = true)
|
||||
@NotEmpty(message = "户口所在地不能为空")
|
||||
private String locationAddress;
|
||||
|
||||
@ApiModelProperty(value = "文化程度 数据字典", name = "culturalLevel", required = true)
|
||||
|
|
@ -72,11 +70,9 @@ public class AppUserInfoCmd extends Command {
|
|||
private String politicalAffiliationName;
|
||||
|
||||
@ApiModelProperty(value = "婚姻状态", name = "maritalStatus", required = true)
|
||||
@NotEmpty(message = "婚姻状态不能为空")
|
||||
private String maritalStatus;
|
||||
|
||||
@ApiModelProperty(value = "婚姻状态名称", name = "maritalStatusName", required = true)
|
||||
@NotEmpty(message = "婚姻状态名称不能为空")
|
||||
private String maritalStatusName;
|
||||
|
||||
@ApiModelProperty(value = "是否流动人员,1-流动,0-固定人员", required = true)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ public class CorpInfoAddCmd extends Command {
|
|||
@ApiModelProperty(value = "是否启用,1:启用,0:关闭", name = "useFlag", required = true)
|
||||
private Integer useFlag;
|
||||
@ApiModelProperty(value = "统一社会信用代码", name = "code", required = true)
|
||||
@NotEmpty(message = "统一社会信用代码不能为空")
|
||||
private String code;
|
||||
@ApiModelProperty(value = "通讯地址", name = "address", required = true)
|
||||
private String address;
|
||||
|
|
|
|||
|
|
@ -80,11 +80,9 @@ public class UserXgfAddCmd extends Command {
|
|||
private String userAvatarUrl;
|
||||
|
||||
@ApiModelProperty(value = "现住址", name = "currentAddress", required = true)
|
||||
@NotEmpty(message = "现住址不能为空")
|
||||
private String currentAddress;
|
||||
|
||||
@ApiModelProperty(value = "户口所在地", name = "locationAddress", required = true)
|
||||
@NotEmpty(message = "户口所在地不能为空")
|
||||
private String locationAddress;
|
||||
@ApiModelProperty(value = "职级", name = "rankLevel")
|
||||
private String rankLevel;
|
||||
|
|
@ -111,11 +109,9 @@ public class UserXgfAddCmd extends Command {
|
|||
private String culturalLevelName;
|
||||
|
||||
@ApiModelProperty(value = "婚姻状态", name = "maritalStatus", required = true)
|
||||
@NotEmpty(message = "婚姻状态不能为空")
|
||||
private String maritalStatus;
|
||||
|
||||
@ApiModelProperty(value = "婚姻状态名称", name = "maritalStatusName", required = true)
|
||||
@NotEmpty(message = "婚姻状态名称不能为空")
|
||||
private String maritalStatusName;
|
||||
|
||||
@ApiModelProperty(value = "政治面貌", name = "politicalAffiliation", required = true)
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
@Getter
|
||||
public enum CorpTypeEnum {
|
||||
OrdinaryEnterprises(0,"普通企业",UserTypeEnum.QY.getCode()),
|
||||
groupUnits(1, "集团单位",UserTypeEnum.QY.getCode()),
|
||||
share(2,"股份单位",UserTypeEnum.JG.getCode()),
|
||||
serviceProvider(3, "相关方企业",UserTypeEnum.XGF.getCode()),
|
||||
cargoOwner(4, "货主单位",UserTypeEnum.XGF.getCode()),
|
||||
portUnit(5, "驻港单位",UserTypeEnum.XGF.getCode()),
|
||||
materialCenter(6, "物资中心",UserTypeEnum.QY.getCode());
|
||||
OrdinaryEnterprises(0,"普通企业",UserTypeEnum.QY.getCode(), "Bb@12345678"),
|
||||
groupUnits(1, "集团单位",UserTypeEnum.QY.getCode(), "Bb@12345678"),
|
||||
share(2,"股份单位",UserTypeEnum.JG.getCode(), "Aa@12345678"),
|
||||
serviceProvider(3, "相关方企业",UserTypeEnum.XGF.getCode(), "Cc@12345678"),
|
||||
cargoOwner(4, "货主单位",UserTypeEnum.XGF.getCode(), "Cc@12345678"),
|
||||
portUnit(5, "驻港单位",UserTypeEnum.XGF.getCode(), "Cc@12345678"),
|
||||
materialCenter(6, "物资中心",UserTypeEnum.QY.getCode(), "Bb@12345678");
|
||||
|
||||
private static final Map<Integer, List<Integer>> ENTERPRISE_TYPE_CODE_MAP = new HashMap<>();
|
||||
|
||||
|
|
@ -27,11 +27,13 @@ public enum CorpTypeEnum {
|
|||
private final String name;
|
||||
//传入的企业类型企业类型 1:监管 2:企业 3:相关方
|
||||
private final Integer userType;
|
||||
private final String defaultPassword;
|
||||
|
||||
CorpTypeEnum(Integer code, String name,Integer userType) {
|
||||
CorpTypeEnum(Integer code, String name, Integer userType, String defaultPassword) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.userType = userType;
|
||||
this.defaultPassword = defaultPassword;
|
||||
}
|
||||
static {
|
||||
Arrays.stream(CorpTypeEnum.values())
|
||||
|
|
@ -68,6 +70,15 @@ public enum CorpTypeEnum {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static String getPasswordByCode(Integer code) {
|
||||
for (CorpTypeEnum corpType : values()) {
|
||||
if (corpType.code.equals(code)) {
|
||||
return corpType.defaultPassword;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getNameByCode(Integer code) {
|
||||
for (CorpTypeEnum corpType : values()) {
|
||||
if (corpType.code.equals(code)) {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ public interface UserGateway {
|
|||
|
||||
Boolean updateByGBS(UserE userE);
|
||||
|
||||
Boolean updateInfoAndPasswordByGBS(UserE userE);
|
||||
|
||||
Boolean updateByAppGBS(UserE userE);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -175,14 +175,14 @@ public class CorpInfoE extends BaseE {
|
|||
private final Long parentTenantId = 1989259383784415232L;
|
||||
// sm2公钥
|
||||
private final String publicKey = "0402df2195296d4062ac85ad766994d73e871b887e18efb9a9a06b4cebc72372869b7da6c347c129dee2b46a0f279ff066b01c76208c2a052af75977c722a2ccee";
|
||||
// 默认密码
|
||||
private final String defaultPassword = "Aa@12345678";
|
||||
// 默认密码
|
||||
// private final String defaultPassword = "Aa@12345678";
|
||||
// 密码
|
||||
private String password;
|
||||
|
||||
|
||||
public void initPassWord() {
|
||||
String encrypt = Sm2Util.encryptHex(MD5.md5(defaultPassword), publicKey);
|
||||
public void initPassWord(Integer type) {
|
||||
String encrypt = Sm2Util.encryptHex(MD5.md5(CorpTypeEnum.getPasswordByCode(type)), publicKey);
|
||||
this.setPassword(encrypt);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -288,8 +288,8 @@ public class UserE extends BaseE {
|
|||
}
|
||||
}
|
||||
|
||||
public void resetPassword() {
|
||||
String encrypt = Sm2Util.encryptHex(MD5.md5(defaultPassword), publicKey);
|
||||
public void resetPassword(Integer type) {
|
||||
String encrypt = Sm2Util.encryptHex(MD5.md5(CorpTypeEnum.getPasswordByCode(type)), publicKey);
|
||||
this.setPassword(encrypt);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.jjb.saas.system.client.user.facade.UserFacade;
|
||||
import com.jjb.saas.system.client.user.request.RoleDeptAddCmd;
|
||||
import com.jjb.saas.system.client.user.request.UserUpdatePasswordCmd;
|
||||
import com.zcloud.basic.info.domain.enums.UserEmploymentFlagEnum;
|
||||
import com.zcloud.basic.info.domain.gateway.UserGateway;
|
||||
import com.zcloud.basic.info.domain.model.UserE;
|
||||
|
|
@ -61,7 +62,7 @@ public class UserGatewayImpl implements UserGateway {
|
|||
// 新增用户默认在职
|
||||
userE.setEmploymentFlag(UserEmploymentFlagEnum.ON.getCode());
|
||||
BeanUtils.copyProperties(userE, d);
|
||||
userE.resetPassword();
|
||||
userE.resetPassword(3);
|
||||
d.setPassword(userE.getPassword());
|
||||
userRepository.saveUserXgf(d);
|
||||
userE.setId(d.getId());
|
||||
|
|
@ -157,6 +158,31 @@ public class UserGatewayImpl implements UserGateway {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean updateInfoAndPasswordByGBS(UserE userE) {
|
||||
com.jjb.saas.system.client.user.request.UserUpdateCmd updateCmd = new com.jjb.saas.system.client.user.request.UserUpdateCmd();
|
||||
updateCmd.setId(userE.getId());
|
||||
updateCmd.setAccount(userE.getPhone());
|
||||
updateCmd.setMobile(userE.getPhone());
|
||||
updateCmd.setName(userE.getName());
|
||||
updateCmd.setEmail(userE.getEmail());
|
||||
RoleDeptAddCmd roleDeptAddCmd = new RoleDeptAddCmd();
|
||||
roleDeptAddCmd.setRoleId(userE.getRoleId());
|
||||
roleDeptAddCmd.setDeptId(userE.getDepartmentId());
|
||||
List<RoleDeptAddCmd> roleDeptAddCmdList = Collections.singletonList(roleDeptAddCmd);
|
||||
updateCmd.setRoleDepts(roleDeptAddCmdList);
|
||||
log.info("GBS修改用户开始,用户信息:{}", JSONUtil.toJsonStr(updateCmd));
|
||||
Response response = userFacade.update(updateCmd);
|
||||
log.info("GBS修改用户结束,用户id:{},结果:{}", JSONUtil.toJsonStr(response));
|
||||
UserUpdatePasswordCmd updatePasswordCmd = new UserUpdatePasswordCmd();
|
||||
updatePasswordCmd.setId(userE.getId());
|
||||
updatePasswordCmd.setPassword(userE.getPassword());
|
||||
updatePasswordCmd.setVersion(1);
|
||||
userFacade.updatePassword(updatePasswordCmd);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateByAppGBS(UserE userE) {
|
||||
com.jjb.saas.system.client.user.request.UserUpdateCmd updateCmd = new com.jjb.saas.system.client.user.request.UserUpdateCmd();
|
||||
|
|
@ -208,7 +234,7 @@ public class UserGatewayImpl implements UserGateway {
|
|||
}
|
||||
Integer flowFlag = userE.getFlowFlag();
|
||||
//修改所有手机号的信息
|
||||
userE.resetPassword();
|
||||
// userE.resetPassword();
|
||||
userE.setEmploymentFlag(null);
|
||||
userE.setFlowFlag(null);
|
||||
this.updateByPhone(userE);
|
||||
|
|
|
|||
|
|
@ -391,6 +391,7 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
|
|||
List<RoleDeptAddCmd> roleDeptAddCmdList = Collections.singletonList(roleDeptAddCmd);
|
||||
userAddCmd.setRoleDepts(roleDeptAddCmdList);
|
||||
userAddCmd.setId(userDO.getId());
|
||||
userAddCmd.setPassword(userDO.getPassword());
|
||||
log.info("GBS新增用户开始,用户信息:{}", JSONUtil.toJsonStr(userAddCmd));
|
||||
SingleResponse<Long> gbsResult = userFacade.add(userAddCmd);
|
||||
log.info("GBS新增用户结束,用户id:{},结果:{}", gbsResult.getData(), JSONUtil.toJsonStr(gbsResult));
|
||||
|
|
@ -675,6 +676,7 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
|
|||
com.jjb.saas.system.client.user.request.UserAddCmd userAddCmd = new com.jjb.saas.system.client.user.request.UserAddCmd();
|
||||
userAddCmd.setAccount(userE.getUsername());
|
||||
userAddCmd.setName(userE.getName());
|
||||
// userAddCmd.setPassword(userE.getPassword());
|
||||
RoleDeptAddCmd roleDeptAddCmd = new RoleDeptAddCmd();
|
||||
roleDeptAddCmd.setRoleId(userE.getRoleId());
|
||||
roleDeptAddCmd.setDeptId(userE.getDepartmentId());
|
||||
|
|
|
|||
Loading…
Reference in New Issue