Commit 2c45dd8f authored by 王亮's avatar 王亮

remove unused code.

parent 9e52f8e9
......@@ -681,7 +681,7 @@ public class UserController implements IBaseController {
String token = request.getHeader("x-auth-token");
if (null == token || "".equals(token)) {
if (org.apache.commons.lang3.StringUtils.isEmpty(token)) {
return JsonResult.buildErrorStateResult("服务器异常,请稍后再试", null);
}
......
package cn.quantgroup.xyqb.controller.external;
import cn.quantgroup.xyqb.controller.IBaseController;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.model.IdCardInfo;
import cn.quantgroup.xyqb.model.IdType;
import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.service.auth.IIdCardService;
import cn.quantgroup.xyqb.service.user.IUserDetailService;
import cn.quantgroup.xyqb.util.ValidationUtil;
import cn.quantgroup.xyqb.validator.ChineseName;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Objects;
/**
* Created by Miraculous on 2017/1/3.
*/
@Slf4j
@RestController
@RequestMapping("/user_detail")
@Validated
public class UserDetailController implements IBaseController {
@Autowired
private IUserDetailService userDetailService;
@Autowired
private IIdCardService idCardService;
/**
* 保存/更新用户实名信息
* 注:
* 本接口会验证用户登录状态,仅用于用户个人补全实名信息操作
* 产品逻辑是不允许用户重复设置实名信息的,但历史存在导流数据创建不完整实名信息的场景(可理解为和渠道有关)
* 故此本处保留修改逻辑,仍依赖业务端控制产品行为
*
* @param idNo
* @param name
* @return
* @yapi unknown
* @Deprecated 20210318
* @see cn.quantgroup.xyqb.controller.internal.user.InnerController#saveUserDetail(Long, String, String, String, String, String)
*/
@Deprecated
@RequestMapping("/save")
public JsonResult saveUserDetail(String idNo,
@ChineseName @RequestParam String name) {
if (!ValidationUtil.validateChinese(name)) {
log.error("姓名错误,name:{}", name);
return JsonResult.buildErrorStateResult("姓名错误", null);
}
User user = getCurrentUserFromRedis();
if (user == null) {
return JsonResult.buildErrorStateResult("系统错误", null);
}
IdCardInfo info = idCardService.getIdCardInfo(idNo);
if (info == null || !info.isValid()) {
log.error("身份证号错误,userId:{}, idNo: {}", user.getId(), idNo);
return JsonResult.buildErrorStateResult("身份证号码错误", null);
}
/* 保存或更新 */
UserDetail userDetail = userDetailService.findByUserId(user.getId());
if (Objects.isNull(userDetail)) {
userDetail = new UserDetail();
}
userDetail.setPhoneNo(user.getPhoneNo());
userDetail.setUserId(user.getId());
userDetail.setName(name);
userDetail.setGender(info.getGender());
userDetail.setIsAuthenticated(false);
log.info("UserDetailController saveUserDetail, userId:{}, phoneNo:{}, name:{}", user.getId(), user.getPhoneNo(), name);
try {
userDetailService.saveUserDetail(userDetail);
} catch (DataIntegrityViolationException ex) {
return JsonResult.buildSuccessResult("", null);
}
return JsonResult.buildSuccessResult("", null);
}
}
......@@ -162,7 +162,7 @@ public class AppController implements IBaseController {
log.info("第三方用户登录 [AppController] login --> loginFrom:{},channelId:{},btRegisterChannelId:{} requestIp:{},idNo:{},name:{}", registerFrom, channelId, btRegisterChannelId, IpUtil.getRemoteIP(request), idNo, name);
User user = userService.findByPhoneInDb(phoneNo);
if (user == null) {
user = userRegisterService.register(registerFrom, phoneNo, idNo, name, channelId, btRegisterChannelId);
user = userRegisterService.register(registerFrom, phoneNo, name, channelId, btRegisterChannelId);
}
if (user == null) {
return JsonResult.buildErrorStateResult(USER_ERROR_OR_PASSWORD_ERROR, null);
......@@ -222,7 +222,7 @@ public class AppController implements IBaseController {
boolean isRegister=false;
if (user == null) {
try {
user = userRegisterService.register(registerFrom, phoneNo, idNo, name, channelId, btRegisterChannelId);
user = userRegisterService.register(registerFrom, phoneNo, name, channelId, btRegisterChannelId);
isRegister=true;
} catch (PersistenceException e) {
user = userService.findByPhoneInDb(phoneNo);
......@@ -349,26 +349,4 @@ public class AppController implements IBaseController {
return JsonResult.buildSuccessResult("登录成功", bean);
}
// @RequestMapping("/login33")
// public JsonResult login233() {
// User user = new User();
// user.setUuid("3213213321");
// user.setRegisteredFrom(221L);
// try {
// EventRecord userRecord = EventRecord.builder().setDistinctId(user.getUuid()).isLoginId(Boolean.TRUE)
// .setEventName("PD_WUXIEC_UserLoginVccCash")
// .addProperty("son_channel_id", user.getRegisteredFrom())
// .addProperty("parent_channel_id",-1L)
// .addProperty("vcc_uuid", user.getUuid())
// .build();
// iSensorsAnalytics.track(userRecord);
// iSensorsAnalytics.flush();
// log.info("神策上报成功");
// } catch (Exception e) {
// log.info("神策埋点出现问题", e);
// }
// return JsonResult.buildSuccessResult("登录成功", null);
//
// }
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3,11 +3,8 @@ package cn.quantgroup.xyqb.controller.internal.user;
import cn.quantgroup.xyqb.aspect.accessable.IpValidator;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.model.IdCardInfo;
import cn.quantgroup.xyqb.model.IdType;
import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.model.UserModel;
import cn.quantgroup.xyqb.service.auth.IIdCardService;
import cn.quantgroup.xyqb.service.user.IUserDetailService;
import cn.quantgroup.xyqb.service.user.IUserService;
import cn.quantgroup.xyqb.util.ValidationUtil;
......@@ -38,8 +35,7 @@ public class SyncUserController {
private IUserService userService;
@Autowired
private IUserDetailService userDetailService;
@Autowired
private IIdCardService idCardService;
@RequestMapping("/save_detail")
public JsonResult saveUserDetail(String key, String phoneNo, String idNo,
......@@ -55,11 +51,7 @@ public class SyncUserController {
log.error("姓名错误,name:{}", name);
return JsonResult.buildErrorStateResult("姓名错误", name);
}
IdCardInfo info = idCardService.getIdCardInfo(idNo);
if (Objects.isNull(info) || !info.isValid()) {
log.error("身份证号错误,idNo:{}", idNo);
return JsonResult.buildErrorStateResult("身份证号码错误", idNo);
}
User user = userService.findByPhoneWithCache(phoneNo);
if (Objects.isNull(user)) {
log.error("用户不存在,phoneNo:{}", phoneNo);
......@@ -73,7 +65,6 @@ public class SyncUserController {
userDetail.setUserId(user.getId());
userDetail.setPhoneNo(phoneNo);
userDetail.setName(name);
userDetail.setGender(info.getGender());
userDetail.setIsAuthenticated(false);
log.info("SyncUserController saveUserDetail, userId:{}, phoneNo:{}, name:{}", user.getId(), phoneNo, name);
try {
......
......@@ -3,10 +3,7 @@ package cn.quantgroup.xyqb.controller.middleoffice.userdetail;
import cn.quantgroup.xyqb.controller.middleoffice.userdetail.req.UserDetailReq;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.model.IdCardInfo;
import cn.quantgroup.xyqb.model.IdType;
import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.service.auth.IIdCardService;
import cn.quantgroup.xyqb.service.user.IUserDetailService;
import cn.quantgroup.xyqb.service.user.IUserService;
import lombok.extern.slf4j.Slf4j;
......@@ -29,8 +26,6 @@ public class UserDetailController {
@Resource
private IUserService userService;
@Resource
private IIdCardService idCardService;
/**
* 修改用户实名信息
......
......@@ -2,10 +2,7 @@ package cn.quantgroup.xyqb.event;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.model.IdCardInfo;
import cn.quantgroup.xyqb.model.IdType;
import cn.quantgroup.xyqb.model.UserRegisterParam;
import cn.quantgroup.xyqb.service.auth.IIdCardService;
import cn.quantgroup.xyqb.service.user.IUserDetailService;
import cn.quantgroup.xyqb.util.ValidationUtil;
import lombok.extern.slf4j.Slf4j;
......@@ -19,8 +16,7 @@ import javax.annotation.Resource;
@Component
public class DetailRegisteredEventListener implements ApplicationListener<RegisterEvent> {
@Resource
private IIdCardService idCardService;
@Resource
private IUserDetailService userDetailService;
......@@ -29,23 +25,16 @@ public class DetailRegisteredEventListener implements ApplicationListener<Regist
UserRegisterParam userRegisterParam = event.getUserRegisterParam();
User user = userRegisterParam.getUser();
if (StringUtils.isAnyBlank(userRegisterParam.getIdNo(), userRegisterParam.getName()) ||
if (StringUtils.isAnyBlank(userRegisterParam.getName()) ||
!ValidationUtil.validateChinese(userRegisterParam.getName())) {
return;
}
String phoneNo = userRegisterParam.getPhoneNo();
String name = userRegisterParam.getName();
String idNo = userRegisterParam.getIdNo();
IdCardInfo cardInfo = idCardService.getIdCardInfo(idNo);
if (cardInfo == null || !cardInfo.isValid()) {
log.info("用户身份证号验证失败,userId:{},idNo:{}", user.getId(), idNo);
return;
}
UserDetail userDetail = new UserDetail();
userDetail.setPhoneNo(phoneNo);
userDetail.setName(name);
userDetail.setUserId(user.getId());
userDetail.setGender(cardInfo.getGender());
log.info("DetailRegisteredEventListener saveUserDetail, userId:{}, phoneNo:{}, name:{}", user.getId(), phoneNo, name);
userDetailService.saveUserDetail(userDetail);
}
......
......@@ -28,7 +28,7 @@ public class LkbRegisteredEventListener implements ApplicationListener<RegisterE
User user = userRegisterParam.getUser();
String uuid = user.getUuid();
boolean pushResult = lkbUserService.pushUser(uuid, userRegisterParam.getPhoneNo(),
userRegisterParam.getName(), userRegisterParam.getIdNo());
userRegisterParam.getName());
if (!pushResult) {
log.error("[userRegisterHandler][baseUserRegisterHandler]同步用户至Lkb出错,userRegisterParam:{}", JsonUtil.toJson(userRegisterParam));
throw new PushUserToLkbException("同步用户至Lkb出错");
......
......@@ -21,7 +21,6 @@ public class UserRegisterParam {
private Long registerFrom; // 注册渠道
private String phoneNo; // 手机号
private String password; // 密码
private String idNo; // 身份证号
private String name; // 姓名
private Long channelId; // 业务渠道
private Long btRegisterChannelId; // 白条渠道
......
package cn.quantgroup.xyqb.service.auth;
import cn.quantgroup.xyqb.model.IdCardInfo;
import java.text.ParseException;
/**
* Created by Miraculous on 15/7/10.
*/
public interface IIdCardService {
boolean isIdCardValid(String idCard) throws ParseException;
IdCardInfo getIdCardInfo(String idCardStr);
// 当身份证不合法,直接抛出异常。
IdCardInfo getIdCardInfoWithExceptions(String idCardStr) throws ParseException;
}
......@@ -17,15 +17,13 @@ public interface IUserRegisterService {
*
* @param registerFrom
* @param phoneNo
* @param idNo
* @param name
* @param channelId
* @param btRegisterChannelId
* @return
*/
User register(Long registerFrom, String phoneNo, String idNo, String name, Long channelId, Long btRegisterChannelId);
User register(Long registerFrom, String phoneNo,String name, Long channelId, Long btRegisterChannelId);
User register(Long registerFrom, String phoneNo, String idNo, String name, Long channelId, Long btRegisterChannelId, Integer tenantId);
User register(Long registerFrom, String phoneNo, String name, Long channelId, Long btRegisterChannelId, Integer tenantId);
......@@ -68,7 +66,7 @@ public interface IUserRegisterService {
* @author jinsong.zhu 2018年05月16日14:22:13
* 处理对address和contact的非必要兼容
*/
User register(Long registeredFrom, Long channelId, String phoneNo, String name, String idNo,String contacts, Long btRegisterChannelId);
User register(Long registeredFrom, Long channelId, String phoneNo, String name,String contacts, Long btRegisterChannelId);
}
......@@ -13,7 +13,6 @@ public interface ILkbUserService {
* @param uuid
* @param phoneNo
* @param name
* @param idNo
*/
boolean pushUser(String uuid, String phoneNo, String name, String idNo);
boolean pushUser(String uuid, String phoneNo, String name);
}
......@@ -34,7 +34,7 @@ public class LkbUserviceImpl implements ILkbUserService {
private String clientUrl;
@Override
public boolean pushUser(String uuid, String phoneNo, String name, String idNo) {
public boolean pushUser(String uuid, String phoneNo, String name) {
String timeunit = System.currentTimeMillis() + "";
String token = PasswordUtil.MD5(String.format(TOKEN_PATTERN, timeunit));
Map<String, String> parameters = Maps.newHashMap();
......@@ -46,9 +46,7 @@ public class LkbUserviceImpl implements ILkbUserService {
if (StringUtils.isNotBlank(name)) {
parameters.put("realName", name);
}
if (StringUtils.isNotBlank(idNo)) {
parameters.put("idCardNo", idNo);
}
String response = httpService.post(clientUrl + "/user/push.json", parameters);
Optional<Map> resultOptional = JsonUtil.fromJson(response, Map.class);
if (!resultOptional.isPresent() || !Constants.SUCCESS_CODE.equals(resultOptional.get().get(Constants.RESULT_CODE))) {
......
......@@ -4,11 +4,9 @@ import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.event.UserDetailUpdateEvent;
import cn.quantgroup.xyqb.model.Gender;
import cn.quantgroup.xyqb.model.IdCardInfo;
import cn.quantgroup.xyqb.model.IdType;
import cn.quantgroup.xyqb.repository.IUserDetailRepository;
import cn.quantgroup.xyqb.repository.IUserRepository;
import cn.quantgroup.xyqb.service.auth.IIdCardService;
import cn.quantgroup.xyqb.service.user.IUserDetailService;
import cn.quantgroup.xyqb.service.user.vo.UserDetailVO;
import cn.quantgroup.xyqb.util.AddressFilter;
......@@ -42,8 +40,7 @@ public class UserDetailServiceImpl implements IUserDetailService {
private IUserDetailRepository userDetailRepository;
@Autowired
private IUserRepository userRepository;
@Autowired
private IIdCardService idCardService;
@Resource
private ApplicationEventPublisher applicationEventPublisher;
@Resource
......
......@@ -5,7 +5,10 @@ import cn.quantgroup.xyqb.aspect.lock.RedisLock;
import cn.quantgroup.xyqb.constant.enums.LoginType;
import cn.quantgroup.xyqb.controller.IBaseController;
import cn.quantgroup.xyqb.controller.internal.user.resp.UserFullResp;
import cn.quantgroup.xyqb.entity.*;
import cn.quantgroup.xyqb.entity.Merchant;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.entity.UserHashMapping;
import cn.quantgroup.xyqb.event.PhoneNoUpdateEvent;
import cn.quantgroup.xyqb.exception.DataException;
import cn.quantgroup.xyqb.exception.UserNotExistException;
......@@ -154,7 +157,6 @@ public class UserServiceImpl implements IUserService, IBaseController {
if (CollectionUtils.isEmpty(userIds)) {
return Maps.newHashMap();
}
Map<Long, String> userIdAndPhoneMap = Maps.newHashMap();
List<User> users = userRepository.findByIdIn(userIds);
//校验租户ID
if (!TenantUtil.TENANT_DEFAULT.equals(tenantId)) {
......@@ -162,8 +164,7 @@ public class UserServiceImpl implements IUserService, IBaseController {
} else {
users = tenantService.validationTentIdByTentId(users, tenantId);
}
users.forEach(user -> userIdAndPhoneMap.put(user.getId(), user.getPhoneNo()));
return userIdAndPhoneMap;
return users.stream().collect(Collectors.toMap(User::getId, User::getPhoneNo));
}
@Override
......@@ -213,7 +214,6 @@ public class UserServiceImpl implements IUserService, IBaseController {
}
@Override
// @Cacheable(value = "usercache", key = "'xyqbuser' + #phone", unless = "#result == null", cacheManager = "cacheManager")
public User findByPhoneWithCache(String phone) {
if (StringUtils.isBlank(phone)) {
return null;
......@@ -510,33 +510,29 @@ public class UserServiceImpl implements IUserService, IBaseController {
@Override
public List<User> findByUuidsOrUserIds(List<String> vals, Integer type, Integer tenantId) {
if (CollectionUtils.isEmpty(vals)) {
return Collections.EMPTY_LIST;
return new ArrayList<>();
}
List<User> users;
if (type == 1) {//1是userids
List<Long> collect = vals.stream()
.map(Long::valueOf)
.collect(Collectors.toList());
List<User> users = userRepository.findByIdIn(collect);
if (!tenantId.equals(TenantUtil.TENANT_DEFAULT)) {
return tenantService.selectUsersByTenantId(users, tenantId);
} else {
return tenantService.validationTentIdByTentId(users, tenantId);
}
users = userRepository.findByIdIn(collect);
} else { //不是1 就是 uuids
List<User> users = userRepository.findByUuidIn(vals);
if (!tenantId.equals(TenantUtil.TENANT_DEFAULT)) {
return tenantService.selectUsersByTenantId(users, tenantId);
} else {
return tenantService.validationTentIdByTentId(users, tenantId);
}
users = userRepository.findByUuidIn(vals);
}
if (!tenantId.equals(TenantUtil.TENANT_DEFAULT)) {
users = tenantService.selectUsersByTenantId(users, tenantId);
} else {
users = tenantService.validationTentIdByTentId(users, tenantId);
}
return users;
}
@Override
public void logout(String token) {
sessionService.deleteSession(token);
}
......@@ -616,6 +612,7 @@ public class UserServiceImpl implements IUserService, IBaseController {
/**
* 不同渠道用户签署不同合同模板
*
* @param user
* @param loginFrom
*/
......@@ -627,7 +624,8 @@ public class UserServiceImpl implements IUserService, IBaseController {
if (Objects.nonNull(loginFrom) && Objects.equals(user.getRegisteredFrom(), loginFrom)) {
return;
}
Map<String, Long> channelMap = JSON.parseObject(channelTemplate, new TypeReference<HashMap<String, Long>>() {});
Map<String, Long> channelMap = JSON.parseObject(channelTemplate, new TypeReference<HashMap<String, Long>>() {
});
Long templateId = channelMap.get(String.valueOf(user.getRegisteredFrom()));
boolean needCheck = false;
if (Objects.nonNull(loginFrom) && !Objects.equals(user.getRegisteredFrom(), loginFrom)) {
......
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