Commit 53da9383 authored by 技术部-任文超's avatar 技术部-任文超

Merge branch 'master' into feature/junit_test

# Conflicts:
#	src/main/java/cn/quantgroup/xyqb/Bootstrap.java
parents dcbbdf37 e94e42f7
...@@ -333,6 +333,11 @@ ...@@ -333,6 +333,11 @@
<artifactId>quantgroup-sms-sdk</artifactId> <artifactId>quantgroup-sms-sdk</artifactId>
<version>3.0</version> <version>3.0</version>
</dependency> </dependency>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-spring</artifactId>
<version>1.6.3</version>
</dependency>
</dependencies> </dependencies>
......
package cn.quantgroup.xyqb; package cn.quantgroup.xyqb;
import cn.quantgroup.tech.shutdown.DefaultSignalHandler;
import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig; import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
import com.ctrip.framework.apollo.spring.config.ApolloPropertySourceInitializer;
import com.weibo.api.motan.common.MotanConstants; import com.weibo.api.motan.common.MotanConstants;
import com.weibo.api.motan.util.MotanSwitcherUtil; import com.weibo.api.motan.util.MotanSwitcherUtil;
import io.sentry.Sentry;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
...@@ -13,9 +16,9 @@ import org.springframework.context.ConfigurableApplicationContext; ...@@ -13,9 +16,9 @@ import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import cn.quantgroup.tech.shutdown.DefaultSignalHandler;
import sun.misc.Signal; import sun.misc.Signal;
@ComponentScan(basePackages = {"cn.quantgroup.sms", "cn.quantgroup.xyqb"}) @ComponentScan(basePackages = {"cn.quantgroup.sms", "cn.quantgroup.xyqb"})
...@@ -40,9 +43,10 @@ public class Bootstrap { ...@@ -40,9 +43,10 @@ public class Bootstrap {
}); });
springApplication.setRegisterShutdownHook(true); springApplication.setRegisterShutdownHook(true);
ConfigurableApplicationContext run = springApplication.run(args); ConfigurableApplicationContext run = springApplication.run(args);
springApplication.run(args);
log.info("server start..."); log.info("server start...");
// 启用平滑退出功能 // 启用平滑退出功能
Signal.handle(new Signal("INT"), new DefaultSignalHandler(run)); Signal.handle(new Signal("INT"), new DefaultSignalHandler(run));
Sentry.init("http://13ef5642903a414c910f8d0e0a2c56ee:8b351ad1abf44de3b4c25f39105fb927@172.16.4.89:9000/6");
} }
} }
package cn.quantgroup.xyqb.config.sentry;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.HandlerExceptionResolver;
/**
* @author xufei on 2017/12/27.
*/
@Controller
@EnableAutoConfiguration
@SpringBootApplication
public class SentryConfig {
@Bean
public HandlerExceptionResolver sentryExceptionResolver() {
return new io.sentry.spring.SentryExceptionResolver();
}
@Bean
public ServletContextInitializer sentryServletContextInitializer() {
return new io.sentry.spring.SentryServletContextInitializer();
}
}
...@@ -31,10 +31,7 @@ import org.slf4j.LoggerFactory; ...@@ -31,10 +31,7 @@ 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.PathVariable; import org.springframework.web.bind.annotation.*;
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.sql.Timestamp; import java.sql.Timestamp;
...@@ -56,6 +53,8 @@ public class InnerController implements IBaseController { ...@@ -56,6 +53,8 @@ public class InnerController implements IBaseController {
@Autowired @Autowired
private IUserDetailService userDetailService; private IUserDetailService userDetailService;
@Autowired @Autowired
private IUserBtRegisterService userBtRegisterService;
@Autowired
private IIdCardService idCardService; private IIdCardService idCardService;
@Autowired @Autowired
private IUserExtInfoService userExtInfoService; private IUserExtInfoService userExtInfoService;
...@@ -580,30 +579,46 @@ public class InnerController implements IBaseController { ...@@ -580,30 +579,46 @@ public class InnerController implements IBaseController {
return JsonResult.buildSuccessResult("success", wechatUserInfo.getOpenId()); return JsonResult.buildSuccessResult("success", wechatUserInfo.getOpenId());
} }
/**
* 按照用户主键查询用户综合信息模型
* 综合信息模型包含:
* {
* 账号信息
* 个人信息
* 扩展信息
* 地址信息
* 联系人信息
* }
* @param userId - 用户表主键
* @return
*/
@RequestMapping("/user-association/search/userId")
@LogHttpCaller @LogHttpCaller
@RequestMapping("/user-association/search/phone") public JsonResult findUserAssociationModelByUserId(Long userId) {
public JsonResult findUserAssociationByPhone(String phoneNo) { if(Objects.isNull(userId) || userId < 0){
UserDetail userDetail = userDetailService.findByPhoneNo(phoneNo); return JsonResult.buildErrorStateResult("", "");
UserAssociation bean = new UserAssociation(); }
UserAssociationModel bean = new UserAssociationModel();
if (null != userDetail) { UserDetail userDetail = userDetailService.findByUserId(userId);
Address address = addressService.findByUserId(userDetail.getUserId()); if (!Objects.isNull(userDetail)) {
List<Contact> contacts = contactService.findByUserId(userDetail.getUserId(), true); bean.setId(userDetail.getUserId());
UserExtInfo extInfo = userExtInfoService.findByUserId(userDetail.getUserId());
bean.setUserId(userDetail.getUserId());
bean.setPhoneNo(userDetail.getPhoneNo()); bean.setPhoneNo(userDetail.getPhoneNo());
bean.setName(userDetail.getName()); bean.setName(userDetail.getName());
bean.setIdNo(userDetail.getIdNo()); bean.setIdNo(userDetail.getIdNo());
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());
if (null != address) {
bean.setCity(address.getCity());
bean.setDistrict(address.getDistrict());
bean.setAddress(address.getAddress());
bean.setProvince(address.getProvince());
} }
if (null != extInfo) { User user = userService.findById(userId);
if (!Objects.isNull(user)) {
bean.setUuid(user.getUuid());
bean.setRegisterFrom(user.getRegisteredFrom());
}
UserBtRegister userBtRegister = userBtRegisterService.findByUserId(userId);
if (!Objects.isNull(userBtRegister)) {
bean.setMerchantId(userBtRegister.getRegisterBtMerchantId());
}
UserExtInfo extInfo = userExtInfoService.findByUserId(userDetail.getUserId());
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{
...@@ -614,20 +629,28 @@ public class InnerController implements IBaseController { ...@@ -614,20 +629,28 @@ public class InnerController implements IBaseController {
}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());
} }
} }
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(contacts)) { Address address = addressService.findByUserId(userDetail.getUserId());
List<XContactInfo> userContacts = contacts2ContactRets(contacts); if (!Objects.isNull(address)) {
bean.setContractResults(userContacts); bean.putAddressList(Arrays.asList(address));
} }
List<Contact> contacts = contactService.findByUserId(userDetail.getUserId(), true);
if (!Objects.isNull(address)) {
bean.putContactList(contacts);
}
return JsonResult.buildSuccessResult("", bean);
} }
@LogHttpCaller
@RequestMapping("/user-association/search/phone")
public JsonResult findUserAssociationByPhone(String phoneNo) {
UserDetail userDetail = userDetailService.findByPhoneNo(phoneNo);
UserAssociation bean = getUserAssociation(userDetail);
return JsonResult.buildSuccessResult("", bean); return JsonResult.buildSuccessResult("", bean);
} }
...@@ -635,8 +658,17 @@ public class InnerController implements IBaseController { ...@@ -635,8 +658,17 @@ public class InnerController implements IBaseController {
@LogHttpCaller @LogHttpCaller
public JsonResult findUserAssociationByUid(Long uid) { public JsonResult findUserAssociationByUid(Long uid) {
UserDetail userDetail = userDetailService.findByUserId(uid); UserDetail userDetail = userDetailService.findByUserId(uid);
UserAssociation bean = new UserAssociation(); UserAssociation bean = getUserAssociation(userDetail);
return JsonResult.buildSuccessResult("", bean);
}
/**
* 获取用户综合信息
* @param userDetail
* @return
*/
private UserAssociation getUserAssociation(UserDetail userDetail){
UserAssociation bean = new UserAssociation();
if (null != userDetail) { if (null != userDetail) {
Address address = addressService.findByUserId(userDetail.getUserId()); Address address = addressService.findByUserId(userDetail.getUserId());
List<Contact> contacts = contactService.findByUserId(userDetail.getUserId(), true); List<Contact> contacts = contactService.findByUserId(userDetail.getUserId(), true);
...@@ -647,12 +679,11 @@ public class InnerController implements IBaseController { ...@@ -647,12 +679,11 @@ public class InnerController implements IBaseController {
bean.setIdNo(userDetail.getIdNo()); bean.setIdNo(userDetail.getIdNo());
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());
if (null != address) { if (null != address) {
bean.setProvince(address.getProvince());
bean.setCity(address.getCity()); bean.setCity(address.getCity());
bean.setDistrict(address.getDistrict()); bean.setDistrict(address.getDistrict());
bean.setAddress(address.getAddress()); bean.setAddress(address.getAddress());
bean.setProvince(address.getProvince());
} }
if (null != extInfo) { if (null != extInfo) {
if(null==extInfo.getEducationEnum()){ if(null==extInfo.getEducationEnum()){
...@@ -665,7 +696,6 @@ public class InnerController implements IBaseController { ...@@ -665,7 +696,6 @@ public class InnerController implements IBaseController {
}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{
...@@ -677,8 +707,7 @@ public class InnerController implements IBaseController { ...@@ -677,8 +707,7 @@ public class InnerController implements IBaseController {
bean.setContractResults(userContacts); bean.setContractResults(userContacts);
} }
} }
return bean;
return JsonResult.buildSuccessResult("", bean);
} }
public static XContactInfo contact2ContactRet(Contact c) { public static XContactInfo contact2ContactRet(Contact c) {
...@@ -868,7 +897,7 @@ public class InnerController implements IBaseController { ...@@ -868,7 +897,7 @@ public class InnerController implements IBaseController {
String districtCode, String districtCode,
String district, String district,
String address, String address,
String contacts) { 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);
...@@ -920,7 +949,7 @@ public class InnerController implements IBaseController { ...@@ -920,7 +949,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); 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);
......
package cn.quantgroup.xyqb.model;
import cn.quantgroup.xyqb.entity.Address;
import lombok.Data;
import java.io.Serializable;
/**
* 地址信息数据模型
* @author renwc
* @date 2018-01-04
*/
@Data
public class AddressModel implements Serializable {
private static final long serialVersionUID = -1L;
private Long provinceCode;
private String province;
private Long cityCode;
private String city;
private Long districtCode;
private String district;
private String address;
private AddressModel(){}
public static AddressModel entity2Model(Address entity) {
if (entity == null) {
return null;
}
AddressModel model = new AddressModel();
model.setProvinceCode(entity.getProvinceCode());
model.setCityCode(entity.getCityCode());
model.setDistrictCode(entity.getDistrictCode());
model.setDistrict(entity.getDistrict());
model.setProvince(entity.getProvince());
model.setCity(entity.getCity());
model.setAddress(entity.getAddress());
return model;
}
}
package cn.quantgroup.xyqb.model;
import cn.quantgroup.user.enums.Relation;
import cn.quantgroup.xyqb.entity.Contact;
import lombok.Data;
import java.io.Serializable;
import java.util.Optional;
/**
* 联系人数据模型
* @author renwc
* @date 2018-01-04
*/
@Data
public class ContactModel implements Serializable {
private static final long serialVersionUID = -1L;
private String name;
private String phoneNo;
private String relationName;
private String relation;
private ContactModel(){}
public static ContactModel entity2Model(Contact entity) {
if (entity == null) {
return null;
}
ContactModel model = new ContactModel();
model.setName(entity.getName());
model.setPhoneNo(entity.getPhoneNo());
model.setRelationName(Optional.ofNullable(entity.getRelation()).orElse(Relation.OTHER).getDescription());
model.setRelation(entity.getRelation().name());
return model;
}
}
package cn.quantgroup.xyqb.model;
import cn.quantgroup.xyqb.entity.Address;
import cn.quantgroup.xyqb.entity.Contact;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* 用户综合信息数据模型
* @author renwc
* @date 2018-01-04
*/
@Data
public class UserAssociationModel implements Serializable {
private static final long serialVersionUID = -1L;
private Long id;
private String uuid;
private String phoneNo;
private String idNo;
private String name;
private String gender;
private String marryStatus;
private String educationEnum;
private String occupationEnum;
private String qq;
private Long registerFrom;
private Long merchantId;
private List<AddressModel> addressList;
private List<ContactModel> contactList;
/**
* 填充地址模型列表
* @param entitylist
*/
public void putAddressList(List<Address> entitylist){
if(Objects.isNull(entitylist)){
return;
}
if(Objects.isNull(this.addressList)){
this.addressList = new ArrayList<AddressModel>(entitylist.size());
}
for (Address entity : entitylist) {
this.addressList.add(AddressModel.entity2Model(entity));
}
}
/**
* 填充联系人模型列表
* @param entitylist
*/
public void putContactList(List<Contact> entitylist){
if(Objects.isNull(entitylist)){
return;
}
if(Objects.isNull(this.contactList)){
this.contactList = new ArrayList<ContactModel>(entitylist.size());
}
for (Contact entity : entitylist) {
this.contactList.add(ContactModel.entity2Model(entity));
}
}
}
package cn.quantgroup.xyqb.model;
import lombok.Data;
/**
* Created by xuran on 2017/8/1.
*/
@Data
public class XContactIn {
private static final long serialVersionUID = -1L;
private Long id;
private Long userId;
private String name;
private String phoneNo;
private String relation;
}
...@@ -92,7 +92,7 @@ public interface IUserRegisterService { ...@@ -92,7 +92,7 @@ public interface IUserRegisterService {
* @param contacts * @param contacts
* @return * @return
*/ */
User register(Long registeredFrom, Long channelId, String phoneNo, String name, String idNo, String provinceCode, String province, String cityCode, String city, String districtCode, String district, String address, String contacts); User register(Long registeredFrom, Long channelId, String phoneNo, String name, String idNo, String provinceCode, String province, String cityCode, String city, String districtCode, String district, String address, String contacts,Long btRegisterChannelId);
/** /**
* 替换MotanUserServiceImpl.appLoginAndFetchLoginInfo和MotanUserServiceImpl.appLogin里的register * 替换MotanUserServiceImpl.appLoginAndFetchLoginInfo和MotanUserServiceImpl.appLogin里的register
......
...@@ -79,7 +79,7 @@ public class UserRegisterServiceImpl extends AbstractUserRegisterService { ...@@ -79,7 +79,7 @@ public class UserRegisterServiceImpl extends AbstractUserRegisterService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public User register(Long registeredFrom, Long channelId, String phoneNo, String name, String idNo, String provinceCode, String province, String cityCode, String city, String districtCode, String district, String address, String contacts) { public User register(Long registeredFrom, Long channelId, String phoneNo, String name, String idNo, String provinceCode, String province, String cityCode, String city, String districtCode, String district, String address, String contacts,Long btRegisterChannelId) {
Address addressObj = new Address(); Address addressObj = new Address();
addressObj.setProvinceCode(Long.valueOf(provinceCode)); addressObj.setProvinceCode(Long.valueOf(provinceCode));
addressObj.setProvince(province); addressObj.setProvince(province);
...@@ -91,6 +91,7 @@ public class UserRegisterServiceImpl extends AbstractUserRegisterService { ...@@ -91,6 +91,7 @@ public class UserRegisterServiceImpl extends AbstractUserRegisterService {
UserRegisterParam userRegisterParam = UserRegisterParam.builder() UserRegisterParam userRegisterParam = UserRegisterParam.builder()
.registerFrom(registeredFrom).phoneNo(phoneNo).idNo(idNo).name(name) .registerFrom(registeredFrom).phoneNo(phoneNo).idNo(idNo).name(name)
.channelId(channelId) .channelId(channelId)
.btRegisterChannelId(btRegisterChannelId)
.address(addressObj).contacts(contacts) .address(addressObj).contacts(contacts)
.generateRandomPwd(true).sendSuccessSms(true).sendAppSms(true) .generateRandomPwd(true).sendSuccessSms(true).sendAppSms(true)
.sendSuccessMq(true) .sendSuccessMq(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