Commit 2fce4508 authored by 技术部-任文超's avatar 技术部-任文超

找回合并时丢失的代码

parent 5147293c
package cn.quantgroup.xyqb.controller.external.user; package cn.quantgroup.xyqb.controller.external.user;
import cn.quantgroup.user.enums.Relation; import cn.quantgroup.user.enums.Relation;
import cn.quantgroup.xyqb.Constants; import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.aspect.logcaller.LogHttpCaller; import cn.quantgroup.xyqb.aspect.logcaller.LogHttpCaller;
import cn.quantgroup.xyqb.controller.IBaseController; import cn.quantgroup.xyqb.controller.IBaseController;
import cn.quantgroup.xyqb.entity.*; import cn.quantgroup.xyqb.entity.*;
import cn.quantgroup.xyqb.entity.enumerate.*; import cn.quantgroup.xyqb.entity.enumerate.*;
import cn.quantgroup.xyqb.exception.UserNotExistException;
import cn.quantgroup.xyqb.model.*; import cn.quantgroup.xyqb.model.*;
import cn.quantgroup.xyqb.service.api.IUserApiService; import cn.quantgroup.xyqb.service.api.IUserApiService;
import cn.quantgroup.xyqb.service.auth.IIdCardService; import cn.quantgroup.xyqb.service.auth.IIdCardService;
import cn.quantgroup.xyqb.service.http.IHttpService; import cn.quantgroup.xyqb.service.http.IHttpService;
import cn.quantgroup.xyqb.service.register.IUserRegisterService; import cn.quantgroup.xyqb.service.register.IUserRegisterService;
import cn.quantgroup.xyqb.service.session.ISessionService; import cn.quantgroup.xyqb.service.session.ISessionService;
import cn.quantgroup.xyqb.service.sms.ISmsService;
import cn.quantgroup.xyqb.service.user.*; import cn.quantgroup.xyqb.service.user.*;
import cn.quantgroup.xyqb.service.wechat.IWechatService; import cn.quantgroup.xyqb.service.wechat.IWechatService;
import cn.quantgroup.xyqb.util.*; import cn.quantgroup.xyqb.util.*;
...@@ -25,20 +26,27 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -25,20 +26,27 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils; import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.ParseException; import java.text.ParseException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* Created by Miraculous on 2016/12/19. * Created by Miraculous on 2016/12/19.
*/ */
...@@ -70,7 +78,8 @@ public class InnerController implements IBaseController { ...@@ -70,7 +78,8 @@ public class InnerController implements IBaseController {
private ISessionService sessionService; private ISessionService sessionService;
@Autowired @Autowired
private IUserApiService userApiService; private IUserApiService userApiService;
@Autowired
private ISmsService smsService;
@Autowired @Autowired
private IHttpService httpService; private IHttpService httpService;
@Autowired @Autowired
...@@ -88,6 +97,7 @@ public class InnerController implements IBaseController { ...@@ -88,6 +97,7 @@ public class InnerController implements IBaseController {
MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
MAPPER.configure(SerializationFeature.WRITE_ENUMS_USING_INDEX, true); MAPPER.configure(SerializationFeature.WRITE_ENUMS_USING_INDEX, true);
} }
private static final char[] PWD_BASE = { private static final char[] PWD_BASE = {
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
...@@ -118,8 +128,8 @@ public class InnerController implements IBaseController { ...@@ -118,8 +128,8 @@ public class InnerController implements IBaseController {
return JsonResult.buildSuccessResult("", userRet); return JsonResult.buildSuccessResult("", userRet);
} }
@LogHttpCaller
@RequestMapping("/userInfo/search/uuid") @RequestMapping("/userInfo/search/uuid")
@LogHttpCaller
public JsonResult findUserInfoByUuid(@RequestParam(value = "uuid") String uuid) { public JsonResult findUserInfoByUuid(@RequestParam(value = "uuid") String uuid) {
LOGGER.info("需要查询的用户uuidid, uuid:" + uuid); LOGGER.info("需要查询的用户uuidid, uuid:" + uuid);
...@@ -127,19 +137,19 @@ public class InnerController implements IBaseController { ...@@ -127,19 +137,19 @@ public class InnerController implements IBaseController {
return JsonResult.buildSuccessResult(null, null); return JsonResult.buildSuccessResult(null, null);
} }
User user = userService.findByUuidInDb(uuid); User user = userService.findByUuidInDb(uuid);
if(null!=user){ if (null != user) {
if(!user.getEnable()){ if (!user.getEnable()) {
return JsonResult.buildSuccessResult("", null); return JsonResult.buildSuccessResult("", null);
} }
UserDetail userDetail = userDetailService.findByUserId(user.getId()); UserDetail userDetail = userDetailService.findByUserId(user.getId());
UserInfo info = new UserInfo(user,userDetail); UserInfo info = new UserInfo(user, userDetail);
return JsonResult.buildSuccessResult("", info); return JsonResult.buildSuccessResult("", info);
} }
return JsonResult.buildSuccessResult("", null); return JsonResult.buildSuccessResult("", null);
} }
@LogHttpCaller
@RequestMapping("/userInfo/search/phone") @RequestMapping("/userInfo/search/phone")
@LogHttpCaller
public JsonResult findUserInfoByPhone(@RequestParam(value = "phone") String phone) { public JsonResult findUserInfoByPhone(@RequestParam(value = "phone") String phone) {
LOGGER.info("需要查询的用户phone, phone:" + phone); LOGGER.info("需要查询的用户phone, phone:" + phone);
...@@ -147,12 +157,12 @@ public class InnerController implements IBaseController { ...@@ -147,12 +157,12 @@ public class InnerController implements IBaseController {
return JsonResult.buildSuccessResult(null, null); return JsonResult.buildSuccessResult(null, null);
} }
User user = userService.findByPhoneInDb(phone); User user = userService.findByPhoneInDb(phone);
if(null!=user){ if (null != user) {
if(!user.getEnable()){ if (!user.getEnable()) {
return JsonResult.buildSuccessResult("", null); return JsonResult.buildSuccessResult("", null);
} }
UserDetail userDetail = userDetailService.findByUserId(user.getId()); UserDetail userDetail = userDetailService.findByUserId(user.getId());
UserInfo info = new UserInfo(user,userDetail); UserInfo info = new UserInfo(user, userDetail);
return JsonResult.buildSuccessResult("", info); return JsonResult.buildSuccessResult("", info);
} }
return JsonResult.buildSuccessResult("", null); return JsonResult.buildSuccessResult("", null);
...@@ -180,7 +190,7 @@ public class InnerController implements IBaseController { ...@@ -180,7 +190,7 @@ public class InnerController implements IBaseController {
public JsonResult saveUser( public JsonResult saveUser(
String phoneNo, Long registeredFrom, Long createdAt, Long updatedAt, String phoneNo, Long registeredFrom, Long createdAt, Long updatedAt,
String password, String uuid) { String password, String uuid) {
LOGGER.info("保存用户,phoneNo:{},registeredFrom;{},uuid:{}",phoneNo,registeredFrom,uuid); LOGGER.info("保存用户,phoneNo:{},registeredFrom;{},uuid:{}", phoneNo, registeredFrom, uuid);
//参数验证 //参数验证
if (StringUtils.isBlank(phoneNo)) { if (StringUtils.isBlank(phoneNo)) {
return JsonResult.buildErrorStateResult("用户手机号不能为空.", null); return JsonResult.buildErrorStateResult("用户手机号不能为空.", null);
...@@ -189,7 +199,7 @@ public class InnerController implements IBaseController { ...@@ -189,7 +199,7 @@ public class InnerController implements IBaseController {
registeredFrom = 0L; registeredFrom = 0L;
} }
if (StringUtils.isBlank(password)) { if (StringUtils.isBlank(password)) {
password= genRandomPwd(); password = genRandomPwd();
password = PasswordUtil.MD5(password.toLowerCase() + Constants.PASSWORD_SALT); password = PasswordUtil.MD5(password.toLowerCase() + Constants.PASSWORD_SALT);
} }
if (StringUtils.isBlank(uuid)) { if (StringUtils.isBlank(uuid)) {
...@@ -203,7 +213,7 @@ public class InnerController implements IBaseController { ...@@ -203,7 +213,7 @@ public class InnerController implements IBaseController {
if (user == null) { if (user == null) {
user = new User(); user = new User();
} else if (!user.getEnable()) { } else if (!user.getEnable()) {
LOGGER.info("用户已经注销,phoneNo:{},",phoneNo); LOGGER.info("用户已经注销,phoneNo:{}", phoneNo);
return JsonResult.buildErrorStateResult("用户已经注销", null); return JsonResult.buildErrorStateResult("用户已经注销", null);
} }
if (org.apache.commons.lang.StringUtils.isEmpty(user.getUuid())) { if (org.apache.commons.lang.StringUtils.isEmpty(user.getUuid())) {
...@@ -219,7 +229,7 @@ public class InnerController implements IBaseController { ...@@ -219,7 +229,7 @@ public class InnerController implements IBaseController {
user = userService.saveUser(user); user = userService.saveUser(user);
UserRet userRet = null; UserRet userRet = null;
if (user != null) { if (user != null) {
userRet = MqUtils.sendRegisterMessage(registeredFrom, null,user); userRet = MqUtils.sendRegisterMessage(registeredFrom, null, user);
} }
return JsonResult.buildSuccessResult(null, userRet); return JsonResult.buildSuccessResult(null, userRet);
} }
...@@ -231,7 +241,7 @@ public class InnerController implements IBaseController { ...@@ -231,7 +241,7 @@ public class InnerController implements IBaseController {
@RequestMapping("/user_detail/save") @RequestMapping("/user_detail/save")
public JsonResult saveUserDetail(Long userId, String phoneNo, String name, String idNo, public JsonResult saveUserDetail(Long userId, String phoneNo, String name, String idNo,
String email, Long id) { String email, Long id) {
LOGGER.info("保存用户详细信息,phoneNo:{},userId;{},name:{},idNo:{},email;{}",phoneNo,userId,name,idNo,email); LOGGER.info("保存用户详细信息,phoneNo:{},userId;{},name:{},idNo:{},email;{}", phoneNo, userId, name, idNo, email);
//参数验证 //参数验证
if (userId == null || userId == 0L) { if (userId == null || userId == 0L) {
return JsonResult.buildErrorStateResult("用户id为空.", null); return JsonResult.buildErrorStateResult("用户id为空.", null);
...@@ -258,9 +268,9 @@ public class InnerController implements IBaseController { ...@@ -258,9 +268,9 @@ public class InnerController implements IBaseController {
if (Objects.isNull(info) || !info.isValid()) { if (Objects.isNull(info) || !info.isValid()) {
return JsonResult.buildErrorStateResult("身份证号码错误", null); return JsonResult.buildErrorStateResult("身份证号码错误", null);
} }
UserDetail userDetail=userDetailService.findByUserId(userId); UserDetail userDetail = userDetailService.findByUserId(userId);
Timestamp time = new Timestamp(System.currentTimeMillis()); Timestamp time = new Timestamp(System.currentTimeMillis());
if(null==userDetail){ if (null == userDetail) {
userDetail = new UserDetail(); userDetail = new UserDetail();
userDetail.setCreatedAt(time); userDetail.setCreatedAt(time);
} }
...@@ -317,6 +327,7 @@ public class InnerController implements IBaseController { ...@@ -317,6 +327,7 @@ public class InnerController implements IBaseController {
/** /**
* 根据phone查找用户完整信息 * 根据phone查找用户完整信息
*
* @param phoneNo * @param phoneNo
* @return * @return
*/ */
...@@ -337,6 +348,7 @@ public class InnerController implements IBaseController { ...@@ -337,6 +348,7 @@ public class InnerController implements IBaseController {
/** /**
* 根据uuid查找用户完整信息 * 根据uuid查找用户完整信息
*
* @param uuid * @param uuid
* @return * @return
*/ */
...@@ -379,7 +391,7 @@ public class InnerController implements IBaseController { ...@@ -379,7 +391,7 @@ public class InnerController implements IBaseController {
@RequestMapping("/contact/save/contacts") @RequestMapping("/contact/save/contacts")
public JsonResult save2Contact(Long userId, @RequestParam(value = "contacts") String contactsStr) { public JsonResult save2Contact(Long userId, @RequestParam(value = "contacts") String contactsStr) {
LOGGER.info("保存用户联系人:userId:{}, contacts:{}",userId, contactsStr); LOGGER.info("保存用户联系人:userId:{}, contacts:{}", userId, contactsStr);
if (StringUtils.isEmpty(contactsStr)) { if (StringUtils.isEmpty(contactsStr)) {
return JsonResult.buildErrorStateResult(null, null); return JsonResult.buildErrorStateResult(null, null);
} }
...@@ -392,7 +404,7 @@ public class InnerController implements IBaseController { ...@@ -392,7 +404,7 @@ public class InnerController implements IBaseController {
LOGGER.info("联系人不能空"); LOGGER.info("联系人不能空");
return JsonResult.buildErrorStateResult(null, null); return JsonResult.buildErrorStateResult(null, null);
} }
for(Contact contact : contacts){ for (Contact contact : contacts) {
if (!contact.valid()) { if (!contact.valid()) {
LOGGER.info("用户手机号或姓名错误, phoneNo:{},name:{}", contact.getPhoneNo(), contact.getName()); LOGGER.info("用户手机号或姓名错误, phoneNo:{},name:{}", contact.getPhoneNo(), contact.getName());
return JsonResult.buildErrorStateResult(null, null); return JsonResult.buildErrorStateResult(null, null);
...@@ -406,12 +418,12 @@ public class InnerController implements IBaseController { ...@@ -406,12 +418,12 @@ public class InnerController implements IBaseController {
public JsonResult updateContact(@RequestParam Long contactId, @RequestParam(required = false) String name, public JsonResult updateContact(@RequestParam Long contactId, @RequestParam(required = false) String name,
@RequestParam(required = false) String phoneNo, @RequestParam(required = false) String phoneNo,
@RequestParam(required = false) Relation relation, String key, @RequestParam(required = false) Relation relation, String key,
@RequestParam String reason,HttpServletRequest request) { @RequestParam String reason, HttpServletRequest request) {
if (!"@qwsdedad131323213w!".equals(key) || contactId == null) { if (!"@qwsdedad131323213w!".equals(key) || contactId == null) {
return JsonResult.buildErrorStateResult("参数不合法", null); return JsonResult.buildErrorStateResult("参数不合法", null);
} }
if (StringUtils.isEmpty(name) && StringUtils.isEmpty(phoneNo) ){ if (StringUtils.isEmpty(name) && StringUtils.isEmpty(phoneNo)) {
return JsonResult.buildErrorStateResult("修改联系人修改条件不能都为空", null); return JsonResult.buildErrorStateResult("修改联系人修改条件不能都为空", null);
} }
if (!ValidationUtil.validatePhoneNo(phoneNo)) { if (!ValidationUtil.validatePhoneNo(phoneNo)) {
...@@ -422,7 +434,7 @@ public class InnerController implements IBaseController { ...@@ -422,7 +434,7 @@ public class InnerController implements IBaseController {
LOGGER.info("用户姓名错误, name:{}", name); LOGGER.info("用户姓名错误, name:{}", name);
return JsonResult.buildErrorStateResult("用户姓名错误", null); return JsonResult.buildErrorStateResult("用户姓名错误", null);
} }
if(StringUtils.isEmpty(reason)){ if (StringUtils.isEmpty(reason)) {
return JsonResult.buildErrorStateResult("修改原因不能为空", null); return JsonResult.buildErrorStateResult("修改原因不能为空", null);
} }
Contact contact = contactService.findById(contactId); Contact contact = contactService.findById(contactId);
...@@ -430,7 +442,7 @@ public class InnerController implements IBaseController { ...@@ -430,7 +442,7 @@ public class InnerController implements IBaseController {
return JsonResult.buildErrorStateResult("修改联系人不存在", null); return JsonResult.buildErrorStateResult("修改联系人不存在", null);
} }
contact = contactService.saveContact(name, phoneNo, relation, contact); contact = contactService.saveContact(name, phoneNo, relation, contact);
LOGGER.info("修改后联系人信息:{},修改原因:{},操作ip:{}",contact,reason,IPUtil.getRemoteIP(request)); LOGGER.info("修改后联系人信息:{},修改原因:{},操作ip:{}", contact, reason, IPUtil.getRemoteIP(request));
return JsonResult.buildSuccessResult("修改联系人成功", contact); return JsonResult.buildSuccessResult("修改联系人成功", contact);
} }
...@@ -451,9 +463,9 @@ public class InnerController implements IBaseController { ...@@ -451,9 +463,9 @@ public class InnerController implements IBaseController {
public JsonResult saveAddress( public JsonResult saveAddress(
Long userId, Long provinceCode, Long cityCode, String city, Long userId, Long provinceCode, Long cityCode, String city,
Long districtCode, String district, String address, String province) { Long districtCode, String district, String address, String province) {
LOGGER.info("保存地址详情:city:{},province:{},district:{}, address:{},userId:{}" , city, province, district, address, userId); LOGGER.info("保存地址详情:city:{},province:{},district:{}, address:{},userId:{}", city, province, district, address, userId);
if (userId == null || provinceCode == null || cityCode == null || StringUtils.isBlank(address)) { if (userId == null || provinceCode == null || cityCode == null || StringUtils.isBlank(address)) {
LOGGER.info("错误保存地址详情,其中参数不能为空:city:{},province:{},district:{}, address:{},userId:{}" , city, province, district, address, userId); LOGGER.info("错误保存地址详情,其中参数不能为空:city:{},province:{},district:{}, address:{},userId:{}", city, province, district, address, userId);
return JsonResult.buildErrorStateResult("参数不能为空", null); return JsonResult.buildErrorStateResult("参数不能为空", null);
} }
Address addressObj = addressService.findByUserId(userId); Address addressObj = addressService.findByUserId(userId);
...@@ -472,7 +484,7 @@ public class InnerController implements IBaseController { ...@@ -472,7 +484,7 @@ public class InnerController implements IBaseController {
addressObj.setAddress(address); addressObj.setAddress(address);
addressObj.setProvince(province); addressObj.setProvince(province);
addressObj = addressService.save(addressObj); addressObj = addressService.save(addressObj);
LOGGER.info("保存后地址详情:{}",addressObj); LOGGER.info("保存后地址详情:{}", addressObj);
return JsonResult.buildSuccessResult(null, AddressRet.address2AddressRet(addressObj)); return JsonResult.buildSuccessResult(null, AddressRet.address2AddressRet(addressObj));
} }
...@@ -581,8 +593,44 @@ public class InnerController implements IBaseController { ...@@ -581,8 +593,44 @@ public class InnerController implements IBaseController {
} }
/** /**
* 按照用户主键查询用户综合信息模型 * 按照用户主键、账号或uuid查询用户详细信息
* 综合信息模型包含: *
* @param id - 用户表主键
* @param phoneNo - 用户账号
* @param uuid - 用户全球唯一键(uuid)
* @return 详细信息包含:
* {
* 账号信息
* 个人信息
* }
*/
@LogHttpCaller
@RequestMapping("/user-association/search")
public JsonResult findUserAssociationModel(Long id, String phoneNo, String uuid) {
User user = null;
if (!Objects.isNull(id) && id > 0) {
user = userService.findById(id);
}else if (ValidationUtil.validatePhoneNo(phoneNo)) {
user = userService.findByPhoneWithCache(phoneNo);
}else if (StringUtils.isNotBlank(uuid)) {
user = userService.findByUuidWithCache(uuid);
}
UserDetail userDetail = null;
if (!Objects.isNull(user) && !Objects.isNull(user.getId()) && user.getId() > 0) {
userDetail = userDetailService.findByUserId(user.getId());
}
if (Objects.isNull(user)) {
return JsonResult.buildErrorStateResult("用户不存在", "");
}else{
return JsonResult.buildSuccessResult("", new UserInfo(user, userDetail));
}
}
/**
* 查询用户综合信息模型
*
* @param user - 用户User
* @return 综合信息模型包含:
* { * {
* 账号信息 * 账号信息
* 个人信息 * 个人信息
...@@ -590,17 +638,15 @@ public class InnerController implements IBaseController { ...@@ -590,17 +638,15 @@ public class InnerController implements IBaseController {
* 地址信息 * 地址信息
* 联系人信息 * 联系人信息
* } * }
* @param userId - 用户表主键
* @return
*/ */
@RequestMapping("/user-association/search/userId") private UserAssociationModel findUserAssociationModelByUser(User user) {
@LogHttpCaller if (Objects.isNull(user) || Objects.isNull(user.getId()) || user.getId() < 1) {
public JsonResult findUserAssociationModelByUserId(Long userId) { return null;
if(Objects.isNull(userId) || userId < 0){
return JsonResult.buildErrorStateResult("", "");
} }
UserAssociationModel bean = new UserAssociationModel(); UserAssociationModel bean = new UserAssociationModel();
UserDetail userDetail = userDetailService.findByUserId(userId); bean.setUuid(user.getUuid());
bean.setRegisterFrom(user.getRegisteredFrom());
UserDetail userDetail = userDetailService.findByUserId(user.getId());
if (!Objects.isNull(userDetail)) { if (!Objects.isNull(userDetail)) {
bean.setId(userDetail.getUserId()); bean.setId(userDetail.getUserId());
bean.setPhoneNo(userDetail.getPhoneNo()); bean.setPhoneNo(userDetail.getPhoneNo());
...@@ -609,30 +655,25 @@ public class InnerController implements IBaseController { ...@@ -609,30 +655,25 @@ public class InnerController implements IBaseController {
bean.setQq(userDetail.getQq()); bean.setQq(userDetail.getQq());
bean.setGender(Optional.ofNullable(userDetail.getGender()).orElse(cn.quantgroup.xyqb.model.Gender.UNKNOWN).getName()); bean.setGender(Optional.ofNullable(userDetail.getGender()).orElse(cn.quantgroup.xyqb.model.Gender.UNKNOWN).getName());
} }
User user = userService.findById(userId); UserBtRegister userBtRegister = userBtRegisterService.findByUserId(user.getId());
if (!Objects.isNull(user)) {
bean.setUuid(user.getUuid());
bean.setRegisterFrom(user.getRegisteredFrom());
}
UserBtRegister userBtRegister = userBtRegisterService.findByUserId(userId);
if (!Objects.isNull(userBtRegister)) { if (!Objects.isNull(userBtRegister)) {
bean.setMerchantId(userBtRegister.getRegisterBtMerchantId()); bean.setMerchantId(userBtRegister.getRegisterBtMerchantId());
} }
UserExtInfo extInfo = userExtInfoService.findByUserId(userDetail.getUserId()); UserExtInfo extInfo = userExtInfoService.findByUserId(userDetail.getUserId());
if (!Objects.isNull(extInfo)) { if (!Objects.isNull(extInfo)) {
if(null==extInfo.getEducationEnum()){ if (null == extInfo.getEducationEnum()) {
bean.setEducationEnum(cn.quantgroup.user.enums.EducationEnum.UNKNOWN.getName()); bean.setEducationEnum(cn.quantgroup.user.enums.EducationEnum.UNKNOWN.getName());
}else{ } else {
bean.setEducationEnum(extInfo.getEducationEnum().getName()); bean.setEducationEnum(extInfo.getEducationEnum().getName());
} }
if(null==extInfo.getOccupationEnum()){ if (null == extInfo.getOccupationEnum()) {
bean.setOccupationEnum(cn.quantgroup.user.enums.OccupationEnum.UNKNOWN.getName()); bean.setOccupationEnum(cn.quantgroup.user.enums.OccupationEnum.UNKNOWN.getName());
}else{ } else {
bean.setOccupationEnum(extInfo.getOccupationEnum().getName()); bean.setOccupationEnum(extInfo.getOccupationEnum().getName());
} }
if(null==extInfo.getMarryStatus()){ if (null == extInfo.getMarryStatus()) {
bean.setMarryStatus(cn.quantgroup.user.enums.MaritalStatus.UNKNOWN.getDescription()); bean.setMarryStatus(cn.quantgroup.user.enums.MaritalStatus.UNKNOWN.getDescription());
}else{ } else {
bean.setMarryStatus(extInfo.getMarryStatus().getDescription()); bean.setMarryStatus(extInfo.getMarryStatus().getDescription());
} }
} }
...@@ -644,6 +685,20 @@ public class InnerController implements IBaseController { ...@@ -644,6 +685,20 @@ public class InnerController implements IBaseController {
if (!Objects.isNull(address)) { if (!Objects.isNull(address)) {
bean.putContactList(contacts); bean.putContactList(contacts);
} }
return bean;
}
@LogHttpCaller
@RequestMapping("/user-association/search/userId")
public JsonResult findUserAssociationModelByUserId(Long userId) {
if (Objects.isNull(userId) || userId < 1) {
return JsonResult.buildErrorStateResult("", "");
}
UserAssociationModel bean = null;
User user = userService.findById(userId);
if (!Objects.isNull(user)) {
bean = findUserAssociationModelByUser(user);
}
return JsonResult.buildSuccessResult("", bean); return JsonResult.buildSuccessResult("", bean);
} }
...@@ -655,8 +710,8 @@ public class InnerController implements IBaseController { ...@@ -655,8 +710,8 @@ public class InnerController implements IBaseController {
return JsonResult.buildSuccessResult("", bean); return JsonResult.buildSuccessResult("", bean);
} }
@RequestMapping("/user-association/search/uid")
@LogHttpCaller @LogHttpCaller
@RequestMapping("/user-association/search/uid")
public JsonResult findUserAssociationByUid(Long uid) { public JsonResult findUserAssociationByUid(Long uid) {
UserDetail userDetail = userDetailService.findByUserId(uid); UserDetail userDetail = userDetailService.findByUserId(uid);
UserAssociation bean = getUserAssociation(userDetail); UserAssociation bean = getUserAssociation(userDetail);
...@@ -665,10 +720,11 @@ public class InnerController implements IBaseController { ...@@ -665,10 +720,11 @@ public class InnerController implements IBaseController {
/** /**
* 获取用户综合信息 * 获取用户综合信息
*
* @param userDetail * @param userDetail
* @return * @return
*/ */
private UserAssociation getUserAssociation(UserDetail userDetail){ private UserAssociation getUserAssociation(UserDetail userDetail) {
UserAssociation bean = new UserAssociation(); UserAssociation bean = new UserAssociation();
if (null != userDetail) { if (null != userDetail) {
Address address = addressService.findByUserId(userDetail.getUserId()); Address address = addressService.findByUserId(userDetail.getUserId());
...@@ -687,19 +743,19 @@ public class InnerController implements IBaseController { ...@@ -687,19 +743,19 @@ public class InnerController implements IBaseController {
bean.setAddress(address.getAddress()); bean.setAddress(address.getAddress());
} }
if (null != extInfo) { if (null != extInfo) {
if(null==extInfo.getEducationEnum()){ if (null == extInfo.getEducationEnum()) {
bean.setEducationEnum(cn.quantgroup.user.enums.EducationEnum.UNKNOWN.getName()); bean.setEducationEnum(cn.quantgroup.user.enums.EducationEnum.UNKNOWN.getName());
}else{ } else {
bean.setEducationEnum(extInfo.getEducationEnum().getName()); bean.setEducationEnum(extInfo.getEducationEnum().getName());
} }
if(null==extInfo.getOccupationEnum()){ if (null == extInfo.getOccupationEnum()) {
bean.setOccupationEnum(cn.quantgroup.user.enums.OccupationEnum.UNKNOWN.getName()); bean.setOccupationEnum(cn.quantgroup.user.enums.OccupationEnum.UNKNOWN.getName());
}else{ } else {
bean.setOccupationEnum(extInfo.getOccupationEnum().getName()); bean.setOccupationEnum(extInfo.getOccupationEnum().getName());
} }
if(null==extInfo.getMarryStatus()){ if (null == extInfo.getMarryStatus()) {
bean.setMarryStatus(cn.quantgroup.user.enums.MaritalStatus.UNKNOWN.getDescription()); bean.setMarryStatus(cn.quantgroup.user.enums.MaritalStatus.UNKNOWN.getDescription());
}else{ } else {
bean.setMarryStatus(extInfo.getMarryStatus().getDescription()); bean.setMarryStatus(extInfo.getMarryStatus().getDescription());
} }
} }
...@@ -734,6 +790,7 @@ public class InnerController implements IBaseController { ...@@ -734,6 +790,7 @@ public class InnerController implements IBaseController {
} }
return contactRets; return contactRets;
} }
@RequestMapping("/user/wechat/phone_no") @RequestMapping("/user/wechat/phone_no")
@LogHttpCaller @LogHttpCaller
public JsonResult queryOpenIdByPhoneNo(String phoneNo) { public JsonResult queryOpenIdByPhoneNo(String phoneNo) {
...@@ -786,6 +843,7 @@ public class InnerController implements IBaseController { ...@@ -786,6 +843,7 @@ public class InnerController implements IBaseController {
LOGGER.info("删除用户缓存信息,phoneNo:{},userId:{},", user.getPhoneNo(), user.getId()); LOGGER.info("删除用户缓存信息,phoneNo:{},userId:{},", user.getPhoneNo(), user.getId());
return JsonResult.buildSuccessResult("用户缓存信息已经删除", null); return JsonResult.buildSuccessResult("用户缓存信息已经删除", null);
} }
@RequestMapping("/user/spouse/save") @RequestMapping("/user/spouse/save")
public JsonResult saveSpouse(Long userId, MaritalStatus status, String spousePhone, String spouseName) { public JsonResult saveSpouse(Long userId, MaritalStatus status, String spousePhone, String spouseName) {
if (userId == null || userId == 0) { if (userId == null || userId == 0) {
...@@ -858,6 +916,7 @@ public class InnerController implements IBaseController { ...@@ -858,6 +916,7 @@ public class InnerController implements IBaseController {
return JsonResult.buildErrorStateResult("主库不提供查询", null); return JsonResult.buildErrorStateResult("主库不提供查询", null);
} }
/** /**
* 重置密码接口,供内部人员使用(例如绝影) * 重置密码接口,供内部人员使用(例如绝影)
*/ */
...@@ -898,7 +957,7 @@ public class InnerController implements IBaseController { ...@@ -898,7 +957,7 @@ public class InnerController implements IBaseController {
String districtCode, String districtCode,
String district, String district,
String address, String address,
String contacts,@RequestParam(defaultValue = "0",required =false ) Long btRegisterChannelId) { String contacts, @RequestParam(defaultValue = "0", required = false) Long btRegisterChannelId) {
LOGGER.info("[/innerapi/user/save_multi]保存用户、联系人、地址信息:registeredFrom:[{}], phoneNo[{}],name[{}],idNo[{}],provinceCode[{}],cityCode[{}],districtCode[{}]," + LOGGER.info("[/innerapi/user/save_multi]保存用户、联系人、地址信息:registeredFrom:[{}], phoneNo[{}],name[{}],idNo[{}],provinceCode[{}],cityCode[{}],districtCode[{}]," +
"address[{}],contacts[{}]", registeredFrom, phoneNo, name, idNo, provinceCode, cityCode, districtCode, address, contacts); "address[{}],contacts[{}]", registeredFrom, phoneNo, name, idNo, provinceCode, cityCode, districtCode, address, contacts);
...@@ -950,7 +1009,7 @@ public class InnerController implements IBaseController { ...@@ -950,7 +1009,7 @@ public class InnerController implements IBaseController {
return JsonResult.buildErrorStateResult("用户已存在,手机号被占用", null); return JsonResult.buildErrorStateResult("用户已存在,手机号被占用", null);
} }
user = userRegisterService.register(Long.valueOf(registeredFrom), Long.valueOf(channelId), phoneNo, name, idNo, provinceCode, province, cityCode, city, districtCode, district, address, contacts,btRegisterChannelId); user = userRegisterService.register(Long.valueOf(registeredFrom), Long.valueOf(channelId), phoneNo, name, idNo, provinceCode, province, cityCode, city, districtCode, district, address, contacts, btRegisterChannelId);
UserRet userRet = new UserRet(user); UserRet userRet = new UserRet(user);
return JsonResult.buildSuccessResult(null, userRet); return JsonResult.buildSuccessResult(null, userRet);
...@@ -976,11 +1035,11 @@ public class InnerController implements IBaseController { ...@@ -976,11 +1035,11 @@ public class InnerController implements IBaseController {
@RequestMapping("/contract/queryRegisterUsers") @RequestMapping("/contract/queryRegisterUsers")
@LogHttpCaller @LogHttpCaller
public JsonResult findRegisterUserByTime(String beginTime,String endTime) { public JsonResult findRegisterUserByTime(String beginTime, String endTime) {
if (null == beginTime||endTime==null) { if (null == beginTime || endTime == null) {
return JsonResult.buildErrorStateResult(null, null); return JsonResult.buildErrorStateResult(null, null);
} }
List<User> userList=userService.findRegisterUserByTime(beginTime,endTime); List<User> userList = userService.findRegisterUserByTime(beginTime, endTime);
return JsonResult.buildSuccessResult(null, userList); return JsonResult.buildSuccessResult(null, userList);
} }
...@@ -997,13 +1056,13 @@ public class InnerController implements IBaseController { ...@@ -997,13 +1056,13 @@ public class InnerController implements IBaseController {
if (null == str || !str.equals(userId.toString())) { if (null == str || !str.equals(userId.toString())) {
return JsonResult.buildErrorStateResult("解密有误", null); return JsonResult.buildErrorStateResult("解密有误", null);
} }
int affectedRows=wechatService.forbiddenUserWeChat(userId); int affectedRows = wechatService.forbiddenUserWeChat(userId);
LOGGER.info("用户微信禁用,userId:{},禁用的原因reason:{},受影响的行数affectedRows:{}",userId,reason,affectedRows); LOGGER.info("用户微信禁用,userId:{},禁用的原因reason:{},受影响的行数affectedRows:{}", userId, reason, affectedRows);
return JsonResult.buildSuccessResult("用户禁用微信成功", affectedRows); return JsonResult.buildSuccessResult("用户禁用微信成功", affectedRows);
} }
@RequestMapping("/updateIdCard") @RequestMapping("/updateIdCard")
public JsonResult updateIdCard(@RequestParam(required = false)String name, @RequestParam(required = false)String idNo, public JsonResult updateIdCard(@RequestParam(required = false) String name, @RequestParam(required = false) String idNo,
@RequestParam String phoneNo, @RequestParam String reason, @RequestParam String content) { @RequestParam String phoneNo, @RequestParam String reason, @RequestParam String content) {
//密文 //密文
if (null != content) { if (null != content) {
...@@ -1013,18 +1072,18 @@ public class InnerController implements IBaseController { ...@@ -1013,18 +1072,18 @@ public class InnerController implements IBaseController {
if (null == str || !str.equals(phoneNo)) { if (null == str || !str.equals(phoneNo)) {
return JsonResult.buildErrorStateResult("解密有误", null); return JsonResult.buildErrorStateResult("解密有误", null);
} }
if(StringUtils.isBlank(name) && StringUtils.isBlank(idNo)){ if (StringUtils.isBlank(name) && StringUtils.isBlank(idNo)) {
return JsonResult.buildErrorStateResult("不能全为空", null); return JsonResult.buildErrorStateResult("不能全为空", null);
} }
if ( StringUtils.isBlank(phoneNo) || StringUtils.isBlank(reason)) { if (StringUtils.isBlank(phoneNo) || StringUtils.isBlank(reason)) {
return JsonResult.buildErrorStateResult("参数有误", null); return JsonResult.buildErrorStateResult("参数有误", null);
} }
if (!ValidationUtil.validatePhoneNo(phoneNo)) { if (!ValidationUtil.validatePhoneNo(phoneNo)) {
LOGGER.info("手机号有误, phoneNo:{}", phoneNo); LOGGER.info("手机号有误, phoneNo:{}", phoneNo);
return JsonResult.buildErrorStateResult("用户手机号错误", null); return JsonResult.buildErrorStateResult("用户手机号错误", null);
} }
int affectedRows=userDetailService.updateIdCard(name, idNo, phoneNo); int affectedRows = userDetailService.updateIdCard(name, idNo, phoneNo);
LOGGER.info("更新用户的信息,name;{},idNo:{},phoneNo:{},操作的理由reason:{},受影响的行数affectedRows:{}", name, idNo, phoneNo, reason,affectedRows); LOGGER.info("更新用户的信息,name;{},idNo:{},phoneNo:{},操作的理由reason:{},受影响的行数affectedRows:{}", name, idNo, phoneNo, reason, affectedRows);
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
builder.put("phoneNo", phoneNo); builder.put("phoneNo", phoneNo);
builder.put("name", name); builder.put("name", name);
...@@ -1056,8 +1115,8 @@ public class InnerController implements IBaseController { ...@@ -1056,8 +1115,8 @@ public class InnerController implements IBaseController {
return JsonResult.buildErrorStateResult("用户手机号错误", null); return JsonResult.buildErrorStateResult("用户手机号错误", null);
} }
int affectedRows=userService.forbiddenUser(enable, phoneNo); int affectedRows = userService.forbiddenUser(enable, phoneNo);
LOGGER.info("禁用或者重启用户的理由,reason:{},手机号phoneNo:{},受影响的行数affectedRows:{}", reason, phoneNo,affectedRows); LOGGER.info("禁用或者重启用户的理由,reason:{},手机号phoneNo:{},受影响的行数affectedRows:{}", reason, phoneNo, affectedRows);
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
builder.put("phoneNo", phoneNo); builder.put("phoneNo", phoneNo);
builder.put("enable", String.valueOf(enable)); builder.put("enable", String.valueOf(enable));
...@@ -1068,6 +1127,7 @@ public class InnerController implements IBaseController { ...@@ -1068,6 +1127,7 @@ public class InnerController implements IBaseController {
httpService.get(hanguguanUrl.concat("/innerapi/forbiddenUserOrNot"), param); httpService.get(hanguguanUrl.concat("/innerapi/forbiddenUserOrNot"), param);
return JsonResult.buildSuccessResult("用户禁用或重启成功成功", affectedRows); return JsonResult.buildSuccessResult("用户禁用或重启成功成功", affectedRows);
} }
private String genRandomPwd() { private String genRandomPwd() {
int pwdMax = PWD_BASE.length; int pwdMax = PWD_BASE.length;
// 生成的随机数 // 生成的随机数
...@@ -1086,4 +1146,91 @@ public class InnerController implements IBaseController { ...@@ -1086,4 +1146,91 @@ public class InnerController implements IBaseController {
} }
return pwd.toString(); return pwd.toString();
} }
/**
* 验证手机号和验证码是否匹配
* 仅供可信任的内部服务调用,不执行限次记数、销毁等安全策略
*
* @param phoneNo 手机号
* @param verificationCode 验证码(短信/语音)
* @return
*/
@LogHttpCaller
@RequestMapping("/verifyPhoneAndCode")
public JsonResult verifyPhoneAndCode(@RequestParam String phoneNo, @RequestParam String verificationCode) {
User user = null;
if (smsService.verifyPhoneAndCode(phoneNo, verificationCode)) {
user = userService.findByPhoneWithCache(phoneNo);
}else {
return JsonResult.buildErrorStateResult("校验失败", "");
}
if (Objects.isNull(user)) {
return JsonResult.buildErrorStateResult("用户不存在", "");
}else{
return JsonResult.buildSuccessResult("校验成功", new UserRet(user));
}
}
@LogHttpCaller
@RequestMapping("/login")
public JsonResult login(@RequestParam String phoneNo, @RequestParam String password) {
User user = checkPhoneNoAndPassword(phoneNo, password);
if (user == null) {
return JsonResult.buildErrorStateResult("用户名或密码不正确", null);
}
UserRet model = new UserRet(user);
return JsonResult.buildSuccessResult("校验成功", model);
}
private User checkPhoneNoAndPassword(String phoneNo, String password) {
byte[] byPhoneNo = Base64.decodeBase64(phoneNo);
String bufPhoneNo = "";
try {
bufPhoneNo = new String(byPhoneNo, "UTF-8");
} catch (UnsupportedEncodingException e) {
LOGGER.error("不支持的编码: ", e);
}
if (!ValidationUtil.validatePhoneNo(bufPhoneNo)) {
LOGGER.info("手机号错误, phoneNo:{}", bufPhoneNo);
throw new UserNotExistException("手机号错误");
}
byte[] byPassword = Base64.decodeBase64(password);
String bufPassword = "";
try {
bufPassword = new String(byPassword, "UTF-8");
} catch (UnsupportedEncodingException e) {
LOGGER.error("不支持的编码: ", e);
}
User user = userService.findByPhoneWithCache(bufPhoneNo);
if (Objects.isNull(user) || Objects.equals(Boolean.FALSE, user.getEnable())) {
return null;
}
//验证密码
if (!Objects.equals(PasswordUtil.MD5(bufPassword.toLowerCase() + Constants.PASSWORD_SALT), user.getPassword())) {
return null;
}
return user;
}
/**
* 查询用户是否存在
*
* @param phoneNo
* @return
*/
@RequestMapping("/user/enable")
public JsonResult isEnable(String phoneNo) {
boolean flag = false;
Map validMap = Maps.newHashMap();
validMap.put("valid", flag);
User user = userService.findByPhoneInDb(phoneNo);
if (user != null && user.getEnable()) {
validMap.put("valid", true);
validMap.put("id", user.getId());
validMap.put("uuid", user.getUuid());
return JsonResult.buildSuccessResult("查询成功", validMap);
}
return JsonResult.buildErrorStateResult("用户不存在", validMap);
}
} }
\ No newline at end of file
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