| | |
| | | import com.gkhy.labRiskManage.application.account.dto.respDto.LoginRespDto; |
| | | import com.gkhy.labRiskManage.application.account.dto.respDto.TokenInfoDto; |
| | | import com.gkhy.labRiskManage.domain.account.converter.UserRoleBindConverter; |
| | | import com.gkhy.labRiskManage.domain.account.entity.User; |
| | | import com.gkhy.labRiskManage.domain.account.enums.IdentityStatusEnum; |
| | | import com.gkhy.labRiskManage.domain.account.enums.UserStatusEnum; |
| | | import com.gkhy.labRiskManage.application.account.service.AccountAppService; |
| | |
| | | import com.gkhy.labRiskManage.domain.account.model.bo.UpdateUserBO; |
| | | |
| | | import com.gkhy.labRiskManage.domain.account.model.dto.SysUserRoleBindDomainDTO; |
| | | import com.gkhy.labRiskManage.domain.account.repository.jpa.UserRepository; |
| | | import com.gkhy.labRiskManage.domain.account.service.SysUserIdentityBindDomainService; |
| | | import com.gkhy.labRiskManage.domain.account.service.UserDomainService; |
| | | import com.gkhy.labRiskManage.domain.account.model.dto.UserInfoDomainDTO; |
| | | import com.gkhy.labRiskManage.domain.account.service.UserRoleDomainService; |
| | | import com.gkhy.labRiskManage.domain.riskReport.utils.GetRoleTagUtils; |
| | | import org.redisson.api.RedissonClient; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | |
| | | @Service |
| | | public class AccountAppServiceImpl implements AccountAppService { |
| | |
| | | |
| | | @Autowired |
| | | private UserRoleBindConverter converter; |
| | | |
| | | |
| | | @Override |
| | | public SearchResult<UserInfoAppRespDTO> findUserByLoginName(String loginName){ |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Result updateUserPassword(ChangePasswdReqDto dto) { |
| | | public Result updateUserPassword(ChangePasswdReqDto dto, Long currentUserId) { |
| | | //人员校验 |
| | | if (!currentUserId.equals(dto.getUid())){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "修改密码遇到错误"); |
| | | } |
| | | Result result = new Result<>(); |
| | | if(userDomainService.updateUserPwd(dto.getUid(),dto.getOldPwd(),dto.getNewPwd()) == true){ |
| | | result.setSuccess(); |
| | |
| | | result.setCode(ResultCode.SYSTEM_ERROR.getCode()); |
| | | result.setMsg("修改密码失败"); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public Result resetUserPassword(ChangePasswdReqDto dto, Long currentUserId) { |
| | | //todo 身份校验 |
| | | |
| | | if (currentUserId.equals(53)){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR.getCode() ,"管理员用户不可重置"); |
| | | } |
| | | UserInfoDomainDTO userInfo = userDomainService.getUserById(currentUserId); |
| | | |
| | | if (ObjectUtils.isEmpty(userInfo)){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR.getCode() ,"用户不存在"); |
| | | } |
| | | |
| | | int roleTag = GetRoleTagUtils.GetRoleTagUtils(userInfo); |
| | | if (roleTag < 2){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR.getCode() ,"无权限重置"); |
| | | } |
| | | |
| | | Result result = new Result<>(); |
| | | |
| | | if(userDomainService.resetUserPassword(dto.getUid(), currentUserId) == true){ |
| | | result.setSuccess(); |
| | | }else { |
| | | result.setCode(ResultCode.SYSTEM_ERROR.getCode()); |
| | | result.setMsg("重置密码失败"); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | |
| | | result.setMsg("用户不存在"); |
| | | return result; |
| | | } |
| | | |
| | | if(!userDomainService.checkPassword(loginReqAppDTO.getPwd(), userInfoDomainDTO.getHash(), userInfoDomainDTO.getSalt())){ |
| | | result.setCode(ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode()); |
| | | result.setMsg("密码错误"); |
| | |
| | | loginRespDto.setRealName(userInfoDomainDTO.getRealName()); |
| | | loginRespDto.setTk(tokenInfoDto.getTk()); |
| | | loginRespDto.setRoles(converter.userRoleBindConverter(userInfoDomainDTO.getRoles())); |
| | | //todo:获取其他需返回的信息 |
| | | //获取其他需返回的信息 |
| | | |
| | | result.setSuccess(); |
| | | result.setData(loginRespDto); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Result logout(Long userId) { |
| | |
| | | createUserBO.setRealName(createNewUserAppReqDTO.getRealName()); |
| | | //如果没有提供密码,初始密码为“123456” |
| | | if(createNewUserAppReqDTO.getPwd() == null || createNewUserAppReqDTO.getPwd().isEmpty()){ |
| | | createNewUserAppReqDTO.setPwd("123456"); |
| | | createNewUserAppReqDTO.setPwd("Gs@123456"); |
| | | } |
| | | |
| | | //todo 2024 弱口令问题处理 |
| | | if (createNewUserAppReqDTO.getPwd().length() < 8){ |
| | | throw new BusinessException(this.getClass(),ResultCode.PARAM_ERROR_ILLEGAL.getCode(),"密码长度不够"); |
| | | } |
| | | if (!createNewUserAppReqDTO.getPwd().matches(".*[A-Z].*")){ |
| | | throw new BusinessException(this.getClass(),ResultCode.PARAM_ERROR_ILLEGAL.getCode(),"密码需要包含大小写字母、数字、特殊符号"); |
| | | } |
| | | if (!createNewUserAppReqDTO.getPwd().matches(".*[a-z].*")){ |
| | | throw new BusinessException(this.getClass(),ResultCode.PARAM_ERROR_ILLEGAL.getCode(),"密码需要包含大小写字母、数字、特殊符号"); |
| | | } |
| | | if (!createNewUserAppReqDTO.getPwd().matches(".*\\d.*")){ |
| | | throw new BusinessException(this.getClass(),ResultCode.PARAM_ERROR_ILLEGAL.getCode(),"密码需要包含大小写字母、数字、特殊符号"); |
| | | } |
| | | if (!createNewUserAppReqDTO.getPwd().matches(".*[!@#$%^&*.()?+`~<>,-].*")){ |
| | | throw new BusinessException(this.getClass(),ResultCode.PARAM_ERROR_ILLEGAL.getCode(),"密码需要包含大小写字母、数字、特殊符号"); |
| | | } |
| | | |
| | | createUserBO.setPwd(createNewUserAppReqDTO.getPwd()); |
| | | createUserBO.setPhone(createNewUserAppReqDTO.getPhone()); |
| | | createUserBO.setIdType(createNewUserAppReqDTO.getIdType()); |
| | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | |
| | | @Transactional |
| | | @Override |
| | | public Result deleteUser(Long userId) { |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |