完善用户履职记录功能

main
zhangyue 2025-11-08 10:58:30 +08:00
parent 0489ce49dd
commit 0e5bf12b9b
9 changed files with 109 additions and 26 deletions

View File

@ -27,7 +27,7 @@ import java.util.ArrayList;
* @Author zhangyue * @Author zhangyue
* @Date 2025-11-06 19:15:37 * @Date 2025-11-06 19:15:37
*/ */
@Api(tags = "用户资质信息") @Api(tags = "用户履职记录")
@RequestMapping("/${application.gateway}/userEmploymentLog") @RequestMapping("/${application.gateway}/userEmploymentLog")
@RestController @RestController
@AllArgsConstructor @AllArgsConstructor

View File

@ -3,17 +3,17 @@ package com.zcloud.basic.info.command;
import com.alibaba.cola.exception.BizException; import com.alibaba.cola.exception.BizException;
import com.jjb.saas.framework.auth.model.SSOUser; import com.jjb.saas.framework.auth.model.SSOUser;
import com.jjb.saas.framework.auth.utils.AuthContext; import com.jjb.saas.framework.auth.utils.AuthContext;
import com.jjb.saas.system.client.role.facade.RoleFacade;
import com.jjb.saas.system.client.user.facade.UserFacade;
import com.jjb.saas.system.client.user.request.FacadeUserAddCmd;
import com.zcloud.basic.info.command.convertor.UserCoConvertor; import com.zcloud.basic.info.command.convertor.UserCoConvertor;
import com.zcloud.basic.info.domain.gateway.CorpInfoGateway;
import com.zcloud.basic.info.domain.gateway.UserEmploymentLogGateway; import com.zcloud.basic.info.domain.gateway.UserEmploymentLogGateway;
import com.zcloud.basic.info.domain.gateway.UserGateway; import com.zcloud.basic.info.domain.gateway.UserGateway;
import com.zcloud.basic.info.domain.model.UserE; import com.zcloud.basic.info.domain.model.UserE;
import com.zcloud.basic.info.domain.model.UserEmploymentLogE; import com.zcloud.basic.info.domain.model.UserEmploymentLogE;
import com.zcloud.basic.info.dto.UserAddCmd; import com.zcloud.basic.info.dto.UserAddCmd;
import com.zcloud.basic.info.dto.UserXgfAddCmd; import com.zcloud.basic.info.dto.UserXgfAddCmd;
import com.zcloud.basic.info.persistence.dataobject.CorpInfoDO;
import com.zcloud.basic.info.persistence.dataobject.UserEmploymentLogDO; import com.zcloud.basic.info.persistence.dataobject.UserEmploymentLogDO;
import com.zcloud.basic.info.persistence.repository.CorpInfoRepository;
import com.zcloud.gbscommon.utils.Tools; import com.zcloud.gbscommon.utils.Tools;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
@ -22,8 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
/** /**
@ -37,12 +36,13 @@ public class UserAddExe {
private final UserGateway userGateway; private final UserGateway userGateway;
private UserCoConvertor userCoConvertor; private UserCoConvertor userCoConvertor;
private final UserEmploymentLogGateway userEmploymentLogGateway; private final UserEmploymentLogGateway userEmploymentLogGateway;
private final CorpInfoRepository corpInfoRepository;
// @Autowired // @Autowired
// private RedisTemplate<String, Object> redisTemplate; // private RedisTemplate<String, Object> redisTemplate;
@DubboReference(check = false) // @DubboReference(check = false)
private UserFacade userFacade; // private UserFacade userFacade;
@DubboReference // @DubboReference
private RoleFacade roleFacade; // private RoleFacade roleFacade;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean execute(UserAddCmd cmd) { public boolean execute(UserAddCmd cmd) {
@ -51,17 +51,18 @@ 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);
CorpInfoDO corpInfoDO = corpInfoRepository.getById(userE.getCorpinfoId());
String corpName = null;
UserEmploymentLogE userEmploymentLogE = new UserEmploymentLogE(); UserEmploymentLogE userEmploymentLogE = new UserEmploymentLogE();
BeanUtils.copyProperties(userE, userEmploymentLogE); BeanUtils.copyProperties(userE, userEmploymentLogE);
userEmploymentLogE.initAdd(userEmploymentLogE);
boolean res = false; boolean res = false;
try { try {
res = userGateway.add(userE); res = userGateway.add(userE);
if(corpInfoDO != null && !ObjectUtils.isEmpty(corpInfoDO.getCorpName())){
corpName = corpInfoDO.getCorpName();
}
userEmploymentLogE.initAdd(userEmploymentLogE, corpName, userE.getId());
userEmploymentLogGateway.add(userEmploymentLogE); userEmploymentLogGateway.add(userEmploymentLogE);
// FacadeUserAddCmd facadeUserAddCmd = new FacadeUserAddCmd();
// facadeUserAddCmd.setAccount(userE.getUsername());
// FacadeUserAddCmd facadeUserAddCmd = userCoConvertor.converEToFacadeUserAddCmd(userE);
// userFacade.addUser(facadeUserAddCmd);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -77,14 +78,18 @@ 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);
CorpInfoDO corpInfoDO = corpInfoRepository.getById(userE.getCorpinfoId());
String corpName = null;
UserEmploymentLogE userEmploymentLogE = new UserEmploymentLogE();
BeanUtils.copyProperties(userE, userEmploymentLogE);
boolean res = false; boolean res = false;
try { try {
res = userGateway.add(userE); res = userGateway.add(userE);
// FacadeUserAddCmd facadeUserAddCmd = new FacadeUserAddCmd(); if(corpInfoDO != null && !ObjectUtils.isEmpty(corpInfoDO.getCorpName())){
// facadeUserAddCmd.setAccount(userE.getUsername()); corpName = corpInfoDO.getCorpName();
// FacadeUserAddCmd facadeUserAddCmd = userCoConvertor.converEToFacadeUserAddCmd(userE); }
// userFacade.addUser(facadeUserAddCmd); userEmploymentLogE.initAdd(userEmploymentLogE, corpName, userE.getId());
userEmploymentLogGateway.add(userEmploymentLogE);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -1,9 +1,15 @@
package com.zcloud.basic.info.command; package com.zcloud.basic.info.command;
import com.alibaba.cola.exception.BizException; import com.alibaba.cola.exception.BizException;
import com.zcloud.basic.info.domain.gateway.UserEmploymentLogGateway;
import com.zcloud.basic.info.domain.gateway.UserGateway; import com.zcloud.basic.info.domain.gateway.UserGateway;
import com.zcloud.basic.info.domain.model.UserE; import com.zcloud.basic.info.domain.model.UserE;
import com.zcloud.basic.info.domain.model.UserEmploymentLogE;
import com.zcloud.basic.info.dto.UserUpdateCmd; import com.zcloud.basic.info.dto.UserUpdateCmd;
import com.zcloud.basic.info.persistence.dataobject.CorpInfoDO;
import com.zcloud.basic.info.persistence.dataobject.UserDO;
import com.zcloud.basic.info.persistence.repository.CorpInfoRepository;
import com.zcloud.basic.info.persistence.repository.UserRepository;
import com.zcloud.gbscommon.utils.Const; import com.zcloud.gbscommon.utils.Const;
import com.zcloud.gbscommon.utils.ZcloudRedisUtil; import com.zcloud.gbscommon.utils.ZcloudRedisUtil;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -11,8 +17,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; 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 org.springframework.util.ObjectUtils;
/** /**
@ -24,6 +29,14 @@ import org.springframework.transaction.annotation.Transactional;
@AllArgsConstructor @AllArgsConstructor
public class UserUpdateExe { public class UserUpdateExe {
private final UserGateway userGateway; private final UserGateway userGateway;
private final UserRepository userRepository;
private final UserEmploymentLogGateway userEmploymentLogGateway;
private final UserEmploymentLogE userEmploymentLogE;
private final CorpInfoRepository corpInfoRepository;
@Autowired @Autowired
private ZcloudRedisUtil zcloudRedisUtil; private ZcloudRedisUtil zcloudRedisUtil;
@ -31,7 +44,28 @@ public class UserUpdateExe {
public void execute(UserUpdateCmd userUpdateCmd) { public void execute(UserUpdateCmd userUpdateCmd) {
UserE userE = new UserE(); UserE userE = new UserE();
BeanUtils.copyProperties(userUpdateCmd, userE); BeanUtils.copyProperties(userUpdateCmd, userE);
boolean res = userGateway.update(userE); UserDO userDO = userRepository.getInfoById(userUpdateCmd.getId());
UserE oldUserE = new UserE();
BeanUtils.copyProperties(userDO, oldUserE);
boolean transferPositionFlag = userE.verifyTransferPosition(oldUserE, userE);
String corpName = null;
boolean res = false;
try {
res = userGateway.update(userE);
if (transferPositionFlag) {
CorpInfoDO corpInfoDO = corpInfoRepository.getById(userE.getCorpinfoId());
if(corpInfoDO != null && !ObjectUtils.isEmpty(corpInfoDO.getCorpName())){
corpName = corpInfoDO.getCorpName();
}
userEmploymentLogE.initAdd(userEmploymentLogE, corpName, userE.getId());
userEmploymentLogGateway.add(userEmploymentLogE);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
if (!res) { if (!res) {
throw new BizException("修改失败"); throw new BizException("修改失败");
} }

View File

@ -120,5 +120,12 @@ public class UserAddCmd extends Command {
@ApiModelProperty(value = "政治面貌名称", name = "politicalAffiliationName") @ApiModelProperty(value = "政治面貌名称", name = "politicalAffiliationName")
private String politicalAffiliationName; private String politicalAffiliationName;
@ApiModelProperty(value = "企业名称")
private String corpinfoName;
@ApiModelProperty(value = "部门名称")
private String departmentName;
@ApiModelProperty(value = "岗位名称")
private String postName;
} }

View File

@ -13,6 +13,6 @@ import lombok.Data;
@Data @Data
public class UserEmploymentLogQryCmd{ public class UserEmploymentLogQryCmd{
private String likeUserEmploymentLogId; private Long eqUserId;
} }

View File

@ -78,7 +78,6 @@ public class UserXgfAddCmd extends Command {
private String userIdCard; private String userIdCard;
@ApiModelProperty(value = "人脸头像url", name = "userAvatarUrl", required = true) @ApiModelProperty(value = "人脸头像url", name = "userAvatarUrl", required = true)
@NotEmpty(message = "人脸头像url不能为空")
private String userAvatarUrl; private String userAvatarUrl;
@ApiModelProperty(value = "现住址", name = "currentAddress", required = true) @ApiModelProperty(value = "现住址", name = "currentAddress", required = true)
@ -128,5 +127,11 @@ public class UserXgfAddCmd extends Command {
@NotEmpty(message = "政治面貌名称不能为空") @NotEmpty(message = "政治面貌名称不能为空")
private String politicalAffiliationName; private String politicalAffiliationName;
@ApiModelProperty(value = "企业名称")
private String corpinfoName;
@ApiModelProperty(value = "部门名称")
private String departmentName;
@ApiModelProperty(value = "岗位名称")
private String postName;
} }

View File

@ -63,6 +63,13 @@ public class UserE extends BaseE {
private String phone; private String phone;
private String rankLevelName; private String rankLevelName;
//企业名称
private String corpinfoName;
//部门名称
private String departmentName;
//岗位名称
private String postName;
//人员在部门中的排序 //人员在部门中的排序
private Integer sort; private Integer sort;
//乐观锁 //乐观锁
@ -124,5 +131,27 @@ public class UserE extends BaseE {
return Response.buildSuccess(); return Response.buildSuccess();
} }
} }
/**
*
* @param oldUserE
* @param newUserE
* @return
*/
public boolean verifyTransferPosition(UserE oldUserE, UserE newUserE) {
if (oldUserE.getCorpinfoId() != newUserE.getCorpinfoId()){
return true;
}
if (oldUserE.getDepartmentId() != newUserE.getDepartmentId()){
return true;
}
if (oldUserE.getPostId() != newUserE.getPostId()){
return true;
}
if(oldUserE.getEmploymentFlag() != newUserE.getEmploymentFlag()){
return true;
}
return false;
}
} }

View File

@ -59,8 +59,10 @@ public class UserEmploymentLogE extends BaseE {
//环境 //环境
private String env; private String env;
public void initAdd(UserEmploymentLogE userEmploymentLogE) { public void initAdd(UserEmploymentLogE userEmploymentLogE, String corpinfoName, Long user_id) {
userEmploymentLogE.setUserEmploymentLogId(Tools.get32UUID()); userEmploymentLogE.setUserEmploymentLogId(Tools.get32UUID());
userEmploymentLogE.setCorpinfoName(corpinfoName);
userEmploymentLogE.setUserId(user_id);
} }
} }

View File

@ -27,6 +27,7 @@ public class UserGatewayImpl implements UserGateway {
UserDO d = new UserDO(); UserDO d = new UserDO();
BeanUtils.copyProperties(userE, d); BeanUtils.copyProperties(userE, d);
userRepository.save(d); userRepository.save(d);
userE.setId(d.getId());
return true; return true;
} }