k94314517
2024-07-18 c67f82dbe219ef214d5ab010c1fa648f98ce2b06
server/service/src/main/java/com/doumee/service/business/impl/UsersServiceImpl.java
@@ -332,26 +332,26 @@
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前账户已停用,请联系管理员");
        }
        //验证短信
        SmsEmail model = smsEmailMapper.selectOne(new QueryWrapper<SmsEmail>().lambda()
                .eq(SmsEmail::getType, Constants.ZERO)
                .eq(SmsEmail::getPhone, phone)
                .eq(SmsEmail::getRemark, code)
                .eq(SmsEmail::getIsdeleted, Constants.ZERO)
        );
        if(model == null){
            throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,验证码不正确,请重新发送再试!");
        }
        if(!Constants.equalsInteger(model.getStatus(),Constants.ZERO)){
            throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,验证码已失效,请重新发送再试!");
        }
        model.setStatus(Constants.ONE);
        model.setEditDate(new Date());
        if(model.getCreateDate() !=null &&
                System.currentTimeMillis() - model.getCreateDate().getTime() > 3*60*1000){
            smsEmailMapper.updateById(model);
            throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,验证码已失效,请重新发送再试~");
        }
        smsEmailMapper.updateById(model);
//        SmsEmail model = smsEmailMapper.selectOne(new QueryWrapper<SmsEmail>().lambda()
//                .eq(SmsEmail::getType, Constants.ZERO)
//                .eq(SmsEmail::getPhone, phone)
//                .eq(SmsEmail::getRemark, code)
//                .eq(SmsEmail::getIsdeleted, Constants.ZERO)
//        );
//        if(model == null){
//            throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,验证码不正确,请重新发送再试!");
//        }
//        if(!Constants.equalsInteger(model.getStatus(),Constants.ZERO)){
//            throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,验证码已失效,请重新发送再试!");
//        }
//        model.setStatus(Constants.ONE);
//        model.setEditDate(new Date());
//        if(model.getCreateDate() !=null &&
//                System.currentTimeMillis() - model.getCreateDate().getTime() > 3*60*1000){
//            smsEmailMapper.updateById(model);
//            throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,验证码已失效,请重新发送再试~");
//        }
//        smsEmailMapper.updateById(model);
        //创建token
        JwtPayLoad payLoad = new JwtPayLoad(users.getId(),Constants.ONE);
        String token = JwtTokenUtil.generateToken(payLoad);
@@ -738,11 +738,32 @@
    }
    @Override
    public Users usersDetail(Long userId){
        Users users = usersMapper.selectById(userId);
    public Users usersDetailByIamId(String iamId){
        Users users = usersMapper.selectOne(new QueryWrapper<Users>().lambda().eq(Users::getIamId,iamId).last("limit 1"));
        if(Objects.isNull(users)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY);
        }
        if(!Constants.equalsInteger(users.getIsdeleted(),Constants.ZERO)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"用户已禁用");
        }
        getUsersDetail(users);
        return users;
    }
    @Override
    public Users usersDetailById(Long id){
        Users users = usersMapper.selectById(id);
        if(Objects.isNull(users)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY);
        }
        if(Constants.equalsInteger(users.getIsdeleted(),Constants.ZERO)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"用户已禁用");
        }
        getUsersDetail(users);
        return users;
    }
    public void getUsersDetail(Users users){
        String prefix = StringUtils.trimToNull(systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE,Constants.RESOURCE_PATH).getCode()) +
                StringUtils.trimToNull(systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE,Constants.USERS_FILE).getCode());
        if(StringUtils.isNotBlank(users.getImgurl())){
@@ -769,7 +790,6 @@
                }
            }
        }
        return users;
    }