Commit fb662dba authored by 唐峰's avatar 唐峰

1冻结或注销用户关联用户id为空问题,2根据手机号查询用户信息加密非加密查询数据缺失 3去掉非必要告警

parent 7fea5ffb
......@@ -168,7 +168,7 @@ public class UserApiV2Controller implements IBaseController {
if (StringUtils.isNotEmpty(batchInfoReq.getAppId()) && CollectionUtils.isNotEmpty(batchInfoReq.getUnionIds())) {
wechatUserInfo = wechatService.findUnionIdsAndOpenIdAndTenantId(batchInfoReq.getUnionIds(), batchInfoReq.getAppId(), tenantId);
List<Long> userIds = wechatUserInfo.stream().map(WechatUserInfo::getUserId).collect(Collectors.toList());
List<Long> userIds = wechatUserInfo.stream().filter(e->e.getUserId() != null).map(WechatUserInfo::getUserId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(wechatUserInfo) || CollectionUtils.isEmpty(userIds)) {
throw new BizException(BizExceptionEnum.UN_EXIT_USER);
}
......
......@@ -184,21 +184,24 @@ public class UserServiceImpl implements IUserService, IBaseController {
return userRepository.findByIdAndTenantId(userId, tenantId);
}
@Override
public List<User> findByPhones(List<String> phones, Integer tenantId) {
Pageable pageable = new PageRequest(0, 500, new Sort(Sort.Direction.DESC, "id"));
Page<User> userPageList = userRepository.findAll((root, query, cb) -> {
query.where(root.get(Constants.ENCRYPTED_PHONE_NO).as(String.class).in(phones)
, root.get("tenantId").as(Integer.class).in(tenantId))
;
Page<User> userPageList = userRepository.findAll((root, query, cb) -> {
query.where(root.get(Constants.PHONE_NO).as(String.class).in(phones), root.get("tenantId").as(Integer.class).in(tenantId));
return query.getRestriction();
}, pageable);
},pageable);
List<User> userList = userPageList.getContent();
if (userList.isEmpty()) {
userList = userRepository.findAll((root, query, cb) -> {
query.where(root.get(Constants.PHONE_NO).as(String.class).in(phones), root.get("tenantId").as(Integer.class).in(tenantId));
userPageList = userRepository.findAll((root, query, cb) -> {
query.where(root.get(Constants.ENCRYPTED_PHONE_NO).as(String.class).in(phones)
, root.get("tenantId").as(Integer.class).in(tenantId))
;
return query.getRestriction();
});
}, pageable);
userList = userPageList.getContent();
}
return userList;
}
......
......@@ -5,6 +5,7 @@ import cn.quantgroup.xyqb.controller.req.v2.LoginReq;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.exception.BizException;
import cn.quantgroup.xyqb.exception.BizExceptionEnum;
import cn.quantgroup.xyqb.exception.SilentBizException;
import cn.quantgroup.xyqb.exception.UserNotExistException;
import cn.quantgroup.xyqb.exception.VerificationCodeErrorException;
import cn.quantgroup.xyqb.model.AuthBean;
......@@ -71,11 +72,11 @@ public class SMSLoginStrategy implements LoginStrategy {
User user = userService.findByPhoneWithCache(smsLoginParam.getPhone(), sessionStruct.getTenantId());
//需要返回用户是否首次注册
//需要返回用户是否首次注册VerificationCodeContext
boolean register = user == null;
if (user != null) {
if (!user.getEnable()) {
throw new BizException(BizExceptionEnum.ERROR_OR_ENABLE_ERROR);
throw new SilentBizException(BizExceptionEnum.ERROR_OR_ENABLE_ERROR);
}
} else {
// Service层会负责发送注册消息到LoanVest
......
......@@ -4,6 +4,7 @@ import cn.quantgroup.xyqb.controller.req.v2.SMSReq;
import cn.quantgroup.xyqb.controller.req.v2.SMSVerifyReq;
import cn.quantgroup.xyqb.exception.BizException;
import cn.quantgroup.xyqb.exception.BizExceptionEnum;
import cn.quantgroup.xyqb.exception.SilentBizException;
import cn.quantgroup.xyqb.model.SMSCodeBean;
import cn.quantgroup.xyqb.service.sms.ISmsService;
import org.springframework.stereotype.Service;
......@@ -35,10 +36,10 @@ public class VerificationCodeContext {
if (!smsService.verifyPhoneAndCode(smsVerifyReq)) {
// 是否需要重新发送短信验证码
if (smsService.needResendCode(smsVerifyReq.getPhoneNo())) {
throw new BizException(BizExceptionEnum.INVALID_SMS_CODE);
throw new SilentBizException(BizExceptionEnum.INVALID_SMS_CODE);
}
throw new BizException(BizExceptionEnum.ERROR_SMS_CODE);
throw new SilentBizException(BizExceptionEnum.ERROR_SMS_CODE);
}
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment