dev:app端扫码入职流程代码修改
parent
683a681e10
commit
9b6dc266d8
|
|
@ -77,5 +77,18 @@ public class AppUserController {
|
|||
return SingleResponse.buildSuccess();
|
||||
}
|
||||
|
||||
@ApiOperation("修改密码")
|
||||
@PostMapping("/updatePassword")
|
||||
public Response updatePassword(@Validated @RequestBody AppUserUpdatePassWordCmd cmd){
|
||||
return SingleResponse.of(userService.updatePasswordFromApp(cmd));
|
||||
}
|
||||
|
||||
@ApiOperation("注销")
|
||||
@PostMapping("/logOut")
|
||||
public Response logOut(@Validated @RequestBody AppUserLogOutCmd cmd){
|
||||
userService.logOut(cmd);
|
||||
return SingleResponse.buildSuccess();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import com.jjb.saas.message.client.message.request.MessageTargetCmd;
|
|||
import com.zcloud.basic.info.command.convertor.UserCoConvertor;
|
||||
import com.zcloud.basic.info.command.query.CorpInfoQueryExe;
|
||||
import com.zcloud.basic.info.constant.RedisConstant;
|
||||
import com.zcloud.basic.info.domain.enums.UserEmploymentFlagEnum;
|
||||
import com.zcloud.basic.info.domain.enums.UserFlowFlagEnum;
|
||||
import com.zcloud.basic.info.domain.gateway.*;
|
||||
import com.zcloud.basic.info.domain.model.*;
|
||||
|
|
@ -107,7 +108,7 @@ public class UserAddExe {
|
|||
public boolean execute(AppUserRegisterCmd cmd) {
|
||||
|
||||
UserE userE = new UserE();
|
||||
userE.checkPassword(cmd.getPassword(), cmd.getConfirmPassword());
|
||||
userE.checkPassword(cmd.getNewPassword(), cmd.getConfirmPassword());
|
||||
// 获取redis验证码
|
||||
// Object phoneCodeObj = zcloudRedisUtil.get(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
|
||||
// if(phoneCodeObj == null || !phoneCodeObj.toString().equals(cmd.getPhoneCode())){
|
||||
|
|
@ -120,6 +121,7 @@ public class UserAddExe {
|
|||
throw new BizException("未创建相关方通用租户");
|
||||
}
|
||||
BeanUtils.copyProperties(cmd, userE);
|
||||
userE.setPassword(cmd.getNewPassword());
|
||||
userE.setCorpinfoId(corpInfoDO.getId());
|
||||
userE.setDepartmentId(corpInfoDO.getId());
|
||||
userGateway.register(userE);
|
||||
|
|
@ -144,6 +146,9 @@ public class UserAddExe {
|
|||
public boolean execute(AppUserOnboardingCmd cmd) {
|
||||
|
||||
// 如果是流动人员, 判断user_corp表是否有未离职的数据, 如果有则不能入职(0-离职)
|
||||
/**
|
||||
* 如果是离职的话, 则将离职改为入职
|
||||
*/
|
||||
List<UserCorpDO> userCorpDOS = userCorpRepository.listByUserIdAndCorpIdAndNoStatus(cmd.getId(), cmd.getCorpinfoId(), 0);
|
||||
if(CollUtil.isNotEmpty(userCorpDOS)){
|
||||
throw new BizException("该用户在当前企业存在未离职信息,无法入职");
|
||||
|
|
@ -152,6 +157,7 @@ public class UserAddExe {
|
|||
// 把user表和user_corp表相关企业,部门,岗位数据补充完整
|
||||
UserE userE = new UserE();
|
||||
BeanUtils.copyProperties(cmd, userE);
|
||||
userE.setEmploymentFlag(UserEmploymentFlagEnum.ENTRY_AUDIT.getCode());
|
||||
userGateway.update(userE);
|
||||
|
||||
// 查询用户信息, 获取是否流动人员
|
||||
|
|
@ -159,18 +165,31 @@ public class UserAddExe {
|
|||
if(userDO == null){
|
||||
throw new BizException("用户不存在");
|
||||
}
|
||||
if(userDO.getEmploymentFlag() == 1){
|
||||
// 插入user_corp表
|
||||
UserCorpE userCorpE = new UserCorpE();
|
||||
userCorpE.setUserId(userE.getId());
|
||||
userCorpE.setCorpinfoId(userE.getCorpinfoId());
|
||||
userCorpE.setDepartmentId(userE.getDepartmentId());
|
||||
userCorpE.setPostName(userE.getPostName());
|
||||
userCorpE.setRoleId(userE.getRoleId());
|
||||
userCorpE.setDepartmentLeaderFlag(0);
|
||||
userCorpE.setSort(9999);
|
||||
userCorpE.setEmploymentFlag(11);
|
||||
userCorpGateway.add(userCorpE);
|
||||
if(UserFlowFlagEnum.FLOW.getCode().equals(userDO.getFlowFlag())){
|
||||
//
|
||||
List<UserCorpDO> userCorpList = userCorpRepository.listByUserIdAndCorpIdAndNoStatus(cmd.getId(), cmd.getCorpinfoId(), 0);
|
||||
if(CollUtil.isNotEmpty(userCorpList)){
|
||||
if(userCorpList.size() > 1){
|
||||
throw new BizException("用户在当前企业存在多条离职数据,请联系管理员。");
|
||||
}
|
||||
UserCorpDO userCorpDO = userCorpList.get(0);
|
||||
userCorpDO.setEmploymentFlag(UserEmploymentFlagEnum.ENTRY_AUDIT.getCode());
|
||||
UserCorpE userCorpE = new UserCorpE();
|
||||
BeanUtils.copyProperties(userCorpDO, userCorpE);
|
||||
userCorpGateway.update(userCorpE);
|
||||
}else {
|
||||
// 插入user_corp表
|
||||
UserCorpE userCorpE = new UserCorpE();
|
||||
userCorpE.setUserId(userE.getId());
|
||||
userCorpE.setCorpinfoId(userE.getCorpinfoId());
|
||||
userCorpE.setDepartmentId(userE.getDepartmentId());
|
||||
userCorpE.setPostName(userE.getPostName());
|
||||
userCorpE.setRoleId(userE.getRoleId());
|
||||
userCorpE.setDepartmentLeaderFlag(0);
|
||||
userCorpE.setSort(9999);
|
||||
userCorpE.setEmploymentFlag(UserEmploymentFlagEnum.ENTRY_AUDIT.getCode());
|
||||
userCorpGateway.add(userCorpE);
|
||||
}
|
||||
}
|
||||
|
||||
// 插入user_change_record表
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.zcloud.basic.info.command;
|
|||
|
||||
import com.alibaba.cola.exception.BizException;
|
||||
import com.zcloud.basic.info.domain.gateway.UserGateway;
|
||||
import com.zcloud.basic.info.dto.AppUserLogOutCmd;
|
||||
import com.zcloud.basic.info.persistence.repository.UserCorpRepository;
|
||||
import com.zcloud.gbscommon.utils.Const;
|
||||
import com.zcloud.gbscommon.utils.ZcloudRedisUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
@ -22,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
@AllArgsConstructor
|
||||
public class UserRemoveExe {
|
||||
private final UserGateway userGateway;
|
||||
private final UserCorpRepository userCorpRepository;
|
||||
// @Autowired
|
||||
// private ZcloudRedisUtil zcloudRedisUtil;
|
||||
|
||||
|
|
@ -37,6 +40,22 @@ public class UserRemoveExe {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean execute(AppUserLogOutCmd cmd) {
|
||||
try {
|
||||
// 删除用户表
|
||||
Long userId = cmd.getId();
|
||||
userGateway.deletedUserById(userId);
|
||||
// 删除user_corp表
|
||||
userCorpRepository.removeByUserId(userId);
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
throw new BizException("删除失败");
|
||||
}
|
||||
// zcloudRedisUtil.del(Const.REDIS_USER_PREFIX+id);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean execute(Long[] ids) {
|
||||
boolean res = userGateway.deletedUserByIds(ids);
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ public class UserUpdateExe {
|
|||
|
||||
|
||||
UserE userE = new UserE();
|
||||
userE.checkPassword(cmd.getPassword(), cmd.getConfirmPassword());
|
||||
userE.checkPassword(cmd.getNewPassword(), cmd.getConfirmPassword());
|
||||
|
||||
// 获取redis验证码
|
||||
// Object phoneCodeObj = zcloudRedisUtil.get(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
|
||||
|
|
@ -149,6 +149,26 @@ public class UserUpdateExe {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updatePasswordFromApp(AppUserUpdatePassWordCmd cmd) {
|
||||
|
||||
UserE userE = new UserE();
|
||||
userE.checkPassword(cmd.getNewPassword(), cmd.getConfirmPassword());
|
||||
|
||||
BeanUtils.copyProperties(cmd, userE);
|
||||
userE.encryptionPassword();
|
||||
userGateway.updatePassword(userE);
|
||||
return true;
|
||||
|
||||
// 获取redis验证码
|
||||
// Object phoneCodeObj = zcloudRedisUtil.get(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
|
||||
// if(phoneCodeObj == null || !phoneCodeObj.toString().equals(cmd.getPhoneCode())){
|
||||
// throw new BizException("验证码已过期或错误");
|
||||
// }
|
||||
// zcloudRedisUtil.del(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void executeChangePassword(Long id) {
|
||||
|
|
@ -392,4 +412,4 @@ public class UserUpdateExe {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,5 +192,15 @@ public class UserServiceImpl implements UserServiceI {
|
|||
userUpdateExe.appUserResignation(appUserResignationCmd);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updatePasswordFromApp(AppUserUpdatePassWordCmd cmd) {
|
||||
return userUpdateExe.updatePasswordFromApp(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logOut(AppUserLogOutCmd cmd) {
|
||||
userRemoveExe.execute(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,5 +75,9 @@ public interface UserServiceI {
|
|||
void reviewStatus(UserReviewStatusCmd userReviewStatusCmd);
|
||||
|
||||
void appUserResignation(AppUserResignationCmd appUserResignationCmd);
|
||||
|
||||
Boolean updatePasswordFromApp(AppUserUpdatePassWordCmd cmd);
|
||||
|
||||
void logOut(AppUserLogOutCmd cmd);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
package com.zcloud.basic.info.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* web-client
|
||||
*
|
||||
* @Author zhangyue
|
||||
* @Date 2025-11-04 14:07:38
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AppUserLogOutCmd implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "用户id", name = "id", required = true)
|
||||
@NotNull(message = "用户id不能为空")
|
||||
private Long id;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -25,9 +25,9 @@ public class AppUserRegisterCmd extends Command {
|
|||
@NotEmpty(message = "手机号不能为空")
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "密码", name = "password", required = true)
|
||||
@ApiModelProperty(value = "密码", name = "newPassword", required = true)
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
private String password;
|
||||
private String newPassword;
|
||||
|
||||
@ApiModelProperty(value = "确认密码", name = "confirmPassword", required = true)
|
||||
@NotEmpty(message = "确认密码不能为空")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
package com.zcloud.basic.info.dto;
|
||||
|
||||
import com.alibaba.cola.dto.Command;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* web-client
|
||||
*
|
||||
* @Author zhangyue
|
||||
* @Date 2025-11-04 14:07:38
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AppUserUpdatePassWordCmd extends Command {
|
||||
@ApiModelProperty(value = "GBS用户id", name = "id", required = true)
|
||||
@NotNull(message = "GBS用户id不能为空")
|
||||
private Long id;
|
||||
@ApiModelProperty(value = "原密码", name = "password")
|
||||
@NotEmpty(message = "原密码不能为空")
|
||||
private String password;
|
||||
@ApiModelProperty(value = "新密码", name = "newPassword")
|
||||
@NotEmpty(message = "新密码不能为空")
|
||||
private String newPassword;
|
||||
@ApiModelProperty(value = "确认密码", name = "confirmPassword")
|
||||
@NotEmpty(message = "确认密码不能为空")
|
||||
private String confirmPassword;
|
||||
}
|
||||
|
||||
|
|
@ -23,8 +23,13 @@ public interface UserCorpRepository extends BaseRepository<UserCorpDO> {
|
|||
|
||||
List<UserCorpDO> listByUserIdAndCorpIdAndNoStatus(Long userId, Long corpinfoId, Integer status);
|
||||
|
||||
List<UserCorpDO> listByUserIdAndCorpIdAndStatus(Long userId, Long corpinfoId, Integer status);
|
||||
|
||||
UserE executeResignation(UserCorpDO userCorpDO, Long corpinfoId, Integer employmentFlag);
|
||||
|
||||
UserE executeReviewStatus(Long id, Long corpinfoId, Integer reviewStatus);
|
||||
|
||||
void removeByUserId(Long userId);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,15 @@ public class UserCorpRepositoryImpl extends BaseRepositoryImpl<UserCorpMapper, U
|
|||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserCorpDO> listByUserIdAndCorpIdAndStatus(Long userId, Long corpinfoId, Integer status) {
|
||||
QueryWrapper<UserCorpDO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", userId);
|
||||
queryWrapper.eq("corpinfo_id", corpinfoId);
|
||||
queryWrapper.eq("employment_flag", status);
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserE executeResignation(UserCorpDO userCorpDO, Long corpinfoId, Integer employmentFlag) {
|
||||
userCorpDO.setEmploymentFlag(employmentFlag);
|
||||
|
|
@ -85,6 +94,13 @@ public class UserCorpRepositoryImpl extends BaseRepositoryImpl<UserCorpMapper, U
|
|||
return userE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeByUserId(Long userId) {
|
||||
QueryWrapper<UserCorpDO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", userId);
|
||||
remove(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -365,13 +365,16 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
|
|||
@Override
|
||||
public Response updatePassword(UserDO userDO) {
|
||||
// TODO 验证老密码是否正确
|
||||
AccountPasswordCheckCmd accountPasswordCheckCmd = new AccountPasswordCheckCmd();
|
||||
accountPasswordCheckCmd.setUserId(userDO.getId());
|
||||
accountPasswordCheckCmd.setPassword(userDO.getPassword());
|
||||
SingleResponse<Long> response = accountFacade.checkPassword(accountPasswordCheckCmd);
|
||||
if(!response.isSuccess()){
|
||||
return Response.buildFailure("原密码不正确");
|
||||
if(userDO.getPassword() != null && !userDO.getPassword().equals("")){
|
||||
AccountPasswordCheckCmd accountPasswordCheckCmd = new AccountPasswordCheckCmd();
|
||||
accountPasswordCheckCmd.setUserId(userDO.getId());
|
||||
accountPasswordCheckCmd.setPassword(userDO.getPassword());
|
||||
SingleResponse<Long> response = accountFacade.checkPassword(accountPasswordCheckCmd);
|
||||
if(!response.isSuccess()){
|
||||
return Response.buildFailure("原密码不正确");
|
||||
}
|
||||
}
|
||||
|
||||
// 更新密码
|
||||
UserUpdatePasswordCmd userUpdatePasswordCmd = new UserUpdatePasswordCmd();
|
||||
userUpdatePasswordCmd.setId(userDO.getId());
|
||||
|
|
|
|||
Loading…
Reference in New Issue