Commit 9b7f907d authored by 李健华's avatar 李健华

相关接口改造

parent b5d25191
......@@ -2,47 +2,18 @@ package cn.quantgroup.xyqb.controller.internal.user;
import cn.quantgroup.tech.db.DSType;
import cn.quantgroup.tech.db.TargetDataSource;
import cn.quantgroup.user.enums.BizType;
import cn.quantgroup.user.enums.EducationEnum;
import cn.quantgroup.user.enums.IncomeEnum;
import cn.quantgroup.user.enums.IncomeRangeEnum;
import cn.quantgroup.user.enums.MaritalStatus;
import cn.quantgroup.user.enums.OccupationEnum;
import cn.quantgroup.user.enums.Relation;
import cn.quantgroup.user.enums.*;
import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.aspect.accessable.IpValidator;
import cn.quantgroup.xyqb.controller.IBaseController;
import cn.quantgroup.xyqb.controller.internal.user.resp.UserFullResp;
import cn.quantgroup.xyqb.entity.Address;
import cn.quantgroup.xyqb.entity.Contact;
import cn.quantgroup.xyqb.entity.Merchant;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserBtRegister;
import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.entity.UserExtInfo;
import cn.quantgroup.xyqb.entity.UserSpouse;
import cn.quantgroup.xyqb.entity.WechatUserInfo;
import cn.quantgroup.xyqb.entity.*;
import cn.quantgroup.xyqb.event.DisableActiveEvent;
import cn.quantgroup.xyqb.event.UserDetailUpdateEvent;
import cn.quantgroup.xyqb.event.UserExtInfoSaveEvent;
import cn.quantgroup.xyqb.exception.UserNotExistException;
import cn.quantgroup.xyqb.model.AddressRet;
import cn.quantgroup.xyqb.model.ContactInfo;
import cn.quantgroup.xyqb.model.ContactRet;
import cn.quantgroup.xyqb.model.Gender;
import cn.quantgroup.xyqb.model.IdCardInfo;
import cn.quantgroup.xyqb.model.IdType;
import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.model.Tuple;
import cn.quantgroup.xyqb.model.UserAssociation;
import cn.quantgroup.xyqb.model.UserAssociationModel;
import cn.quantgroup.xyqb.model.UserDetailRet;
import cn.quantgroup.xyqb.model.UserExtInfoRet;
import cn.quantgroup.xyqb.model.UserFullInfo;
import cn.quantgroup.xyqb.model.UserInfo;
import cn.quantgroup.xyqb.model.UserRet;
import cn.quantgroup.xyqb.model.UserSpouseRet;
import cn.quantgroup.xyqb.model.UserStatistics;
import cn.quantgroup.xyqb.model.*;
import cn.quantgroup.xyqb.service.api.IUserApiService;
import cn.quantgroup.xyqb.service.auth.IIdCardService;
import cn.quantgroup.xyqb.service.merchant.IMerchantService;
......@@ -52,14 +23,9 @@ import cn.quantgroup.xyqb.service.sms.ISmsService;
import cn.quantgroup.xyqb.service.user.*;
import cn.quantgroup.xyqb.service.user.vo.UserDetailVO;
import cn.quantgroup.xyqb.service.wechat.IWechatService;
import cn.quantgroup.xyqb.util.AesUtil;
import cn.quantgroup.xyqb.util.IpUtil;
import cn.quantgroup.xyqb.util.MqUtils;
import cn.quantgroup.xyqb.util.PasswordUtil;
import cn.quantgroup.xyqb.util.ValidationUtil;
import cn.quantgroup.xyqb.util.*;
import cn.quantgroup.xyqb.util.encrypt.Md5Util;
import cn.quantgroup.xyqb.validator.ChineseName;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
......@@ -76,7 +42,6 @@ import org.apache.commons.lang3.math.NumberUtils;
import org.apache.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -85,14 +50,8 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.Min;
import java.io.UnsupportedEncodingException;
import java.sql.Timestamp;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.*;
import java.util.stream.Collectors;
......@@ -138,6 +97,11 @@ public class InnerController implements IBaseController {
@Resource
private CleanDataService cleanDataService;
@Autowired
private ITenantService tenantService;
private static final String RESET_PWD_TOKEN = "ecf75c1f-2ccb-4661-8e4b-2874c0f45a2b";
private static final String MODIFY_CONTACT_TOKEN = "@qwsdedad131323213w!";
......@@ -169,12 +133,18 @@ public class InnerController implements IBaseController {
*/
@RequestMapping("/user/search/phoneNo")
@ApiOperation(httpMethod = "GET", value = "根据手机号查询用户信息")
public JsonResult findByPhoneNo(String phoneNo) {
public JsonResult findByPhoneNo(String phoneNo, String tenantId) {
User user = userService.findByPhoneInDb(phoneNo);
if (user == null) {
return JsonResult.buildErrorStateResult("", null);
}
if (tenantId != null) {
// userId 查询对应productLogin 获取手机号和customerId
user = tenantService.getTenantUser(user, tenantId);
if (user == null ) {
return JsonResult.buildErrorStateResult("", null);
}
}
UserRet userRet = new UserRet(user);
return JsonResult.buildSuccessResult("", userRet);
}
......@@ -184,11 +154,19 @@ public class InnerController implements IBaseController {
*/
@RequestMapping("/user/search/uuid")
@ApiOperation(httpMethod = "POST", value = "根据UUID查询用户信息")
public JsonResult findByUuid(String uuid) {
public JsonResult findByUuid(String uuid, String tenantId) {
User user = userService.findByUuidWithCache(uuid);
if (user == null) {
return JsonResult.buildErrorStateResult("", null);
}
if (tenantId != null) {
// userId 查询对应productLogin 获取手机号和customerId
user = tenantService.getTenantUser(user, tenantId);
if (user == null ) {
return JsonResult.buildErrorStateResult("", null);
}
}
UserRet userRet = new UserRet(user);
return JsonResult.buildSuccessResult("", userRet);
}
......@@ -415,7 +393,7 @@ public class InnerController implements IBaseController {
*/
@RequestMapping("/user_detail/search/userId")
@ApiOperation(httpMethod = "POST", value = "查询用户详情")
public JsonResult findUserDetailByUserId(Long userId) {
public JsonResult findUserDetailByUserId(Long userId, String tenantId) {
UserDetail userDetail = null;
// 增加容错性,防备DB中存在的脏数据触发异常
if (userId != null && userId > 0) {
......@@ -424,6 +402,13 @@ public class InnerController implements IBaseController {
if (Objects.isNull(userDetail)) {
return JsonResult.buildErrorStateResult("该用户无实名信息", null);
}
if (tenantId != null) {
userDetail = tenantService.getTenantUserDetail(userDetail, tenantId);
if (userDetail == null) {
return JsonResult.buildErrorStateResult("该用户详情信息不存在", null);
}
}
return JsonResult.buildSuccessResult("用户实名信息", UserDetailRet.getUserDetail(userDetail));
}
......@@ -432,11 +417,19 @@ public class InnerController implements IBaseController {
*/
@RequestMapping("/user/search/userId")
@ApiOperation(httpMethod = "POST", value = "查询用户基本信息")
public JsonResult findUserByUserId(Long userId) {
public JsonResult findUserByUserId(Long userId, String tenantId) {
User user = userService.findById(userId);
if (user != null) {
if (tenantId != null) {
// userId 查询对应productLogin 获取手机号和customerId
user = tenantService.getTenantUser(user, tenantId);
if (user == null ) {
return JsonResult.buildErrorStateResult("", null);
}
}
return JsonResult.buildSuccessResult(null, new UserRet(user));
}
return JsonResult.buildErrorStateResult("", null);
}
......@@ -445,11 +438,19 @@ public class InnerController implements IBaseController {
*/
@RequestMapping("/user_detail/search/phone")
@ApiOperation(httpMethod = "POST", value = "查询用户详情")
public JsonResult findUserDetailByPhone(String phoneNo) {
UserDetail userDetail = userDetailService.findSlaveByPhoneNo(phoneNo);
public JsonResult findUserDetailByPhone(String phoneNo, String tenantId) {
UserDetail userDetail = null;
userDetail = userDetailService.findSlaveByPhoneNo(phoneNo);
if (userDetail != null) {
if (tenantId != null) {
userDetail = tenantService.getTenantUserDetail(userDetail, tenantId);
if (userDetail == null) {
return JsonResult.buildErrorStateResult("该用户详情信息不存在", null);
}
}
return JsonResult.buildSuccessResult(null, UserDetailRet.getUserDetail(userDetail));
}
return JsonResult.buildErrorStateResult("该用户详情信息不存在", null);
}
......
package cn.quantgroup.xyqb.controller.internal.user.center;
import cn.quantgroup.user.enums.*;
import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.aspect.limit.PasswordFreeAccessValidator;
import cn.quantgroup.xyqb.aspect.lock.RedisLock;
import cn.quantgroup.xyqb.entity.*;
import cn.quantgroup.xyqb.event.UserExtInfoSaveEvent;
import cn.quantgroup.xyqb.entity.OauthClientDetailsEntity;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.service.user.*;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import io.swagger.annotations.ApiOperation;
import cn.quantgroup.xyqb.service.user.IOauthClientDetailsService;
import cn.quantgroup.xyqb.service.user.IOauthLoginInfoService;
import cn.quantgroup.xyqb.service.user.ISmsService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Created by 11 on 2017/3/22.
......@@ -35,14 +25,17 @@ public class OauthClientDetailsController {
@Autowired
private IOauthLoginInfoService oauthLoginInfoService;
@Autowired
private ISmsService smsService;
@PostMapping("/getOauthClient")
public JsonResult getOauthClient(Long clientId) {
public JsonResult getOauthClient(String clientId) {
OauthClientDetailsEntity oauthClientDetailsEntity = oauthClientDetailsService.findFirstByClientId(clientId);
return JsonResult.buildSuccessResultGeneric(oauthClientDetailsEntity);
}
@PostMapping("/addLoginInfo")
public JsonResult addLoginInfo(Long tenantId, String phoneNo) {
public JsonResult addLoginInfo(String tenantId, String phoneNo) {
User user = new User();
user.setPhoneNo(phoneNo);
user.setId(new Long("111111"));
......@@ -50,4 +43,10 @@ public class OauthClientDetailsController {
return JsonResult.buildSuccessResultGeneric("12");
}
@PostMapping("/sendSms")
public JsonResult sendSms(Long tenantId, String phoneNo) {
String code = smsService.sendSms(tenantId, "login", phoneNo);
return JsonResult.buildSuccessResultGeneric(code);
}
}
......@@ -28,7 +28,7 @@ public class OauthClientDetailsEntity extends OptimisticEntity implements Serial
@Id
@Column(name = "CLIENT_ID", nullable = false)
private long clientId;
private String clientId;
@Column(name = "INSTITUTION_ID", nullable = false, length = 4)
private String institutionId;
......@@ -76,11 +76,11 @@ public class OauthClientDetailsEntity extends OptimisticEntity implements Serial
private String smsRegisterTemplate;
public long getClientId() {
public String getClientId() {
return clientId;
}
public void setClientId(long clientId) {
public void setClientId(String clientId) {
this.clientId = clientId;
}
......
package cn.quantgroup.xyqb.entity;
import cn.quantgroup.xyqb.entity.baseEntity.OptimisticEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
/**
* Created with IntelliJ IDEA.
*
* @author: Li JianHua
* @Date: 2021/9/23
* @Time: 11:02
* Description: No Description
*/
@Entity
@Table(name = "sms_template")
public class SmsTemplateEntity extends OptimisticEntity implements Serializable {
private final static String CLASS_NAME = SmsTemplateEntity.class.getSimpleName();
private static final long serialVersionUID = -190846609680723652L;
@Id
@Column(name = "ID", nullable = false)
private long id;
@Column(name = "CLIENT_ID", nullable = false)
private long clientId;
@Column(name = "TYPE", nullable = false, updatable = false, length = 11)
private String type;
@Column(name = "MERCHANT_ID", nullable = false, updatable = false, length = 11)
private String merchantId;
@Column(name = "CONTENT_ID", nullable = false, updatable = false, length = 11)
private String contentId;
@Column(name = "CONTENT", nullable = false, updatable = false)
private String content;
@Override
public String getPersistentKey() {
return null;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getClientId() {
return clientId;
}
public void setClientId(long clientId) {
this.clientId = clientId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getMerchantId() {
return merchantId;
}
public void setMerchantId(String merchantId) {
this.merchantId = merchantId;
}
public String getContentId() {
return contentId;
}
public void setContentId(String contentId) {
this.contentId = contentId;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
......@@ -9,5 +9,5 @@ import org.springframework.stereotype.Repository;
*/
@Repository
public interface ICustomerInfoRepository extends JpaRepository<CustomerInfoEntity, Long> {
CustomerInfoEntity findByCustomerId(Long customerId);
}
\ No newline at end of file
......@@ -9,8 +9,8 @@ import org.springframework.stereotype.Repository;
* Created by hechao on 2020/2/17.
*/
@Repository
public interface IOauthClientDetailsRepository extends JpaRepository<OauthClientDetailsEntity, Long> {
OauthClientDetailsEntity findFirstByClientId(Long clientID);
public interface IOauthClientDetailsRepository extends JpaRepository<OauthClientDetailsEntity, String> {
OauthClientDetailsEntity findFirstByClientId(String clientID);
OauthClientDetailsEntity findFirstByInstitutionIdAndProductId(String institutionId, String productId);
}
\ No newline at end of file
package cn.quantgroup.xyqb.repository;
import cn.quantgroup.xyqb.entity.ProductLoginEntity;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.data.jpa.repository.JpaRepository;
import javax.transaction.Transactional;
import org.springframework.stereotype.Repository;
/**
......@@ -20,4 +15,6 @@ public interface IProductLoginRepository extends JpaRepository<ProductLoginEntit
ProductLoginEntity findFirstByInstitutionIdAndProductIdAndPhoneNo(String institutionId, String productId, String phoneNo);
ProductLoginEntity findFirstByPhoneNo(String phoneNo);
ProductLoginEntity findByInstitutionIdAndProductIdAndExtensionAccountId(String institutionId, String productId, Long userId);
}
\ No newline at end of file
package cn.quantgroup.xyqb.repository;
import cn.quantgroup.xyqb.entity.SmsTemplateEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Optional;
/**
* Created by hechao on 2020/2/17.
*/
@Repository
public interface ISmsTemplateRepository extends JpaRepository<SmsTemplateEntity, Long> {
Optional<SmsTemplateEntity> findFirstByClientIdAndType(Long clientId, String type);
}
\ No newline at end of file
package cn.quantgroup.xyqb.service.user;
import cn.quantgroup.xyqb.entity.CustomerInfoEntity;
/**
* Created by 11 on 2016/12/29.
*/
public interface ICustomerInfoService {
CustomerInfoEntity findSlaveByCustomerId(Long customerId);
}
package cn.quantgroup.xyqb.service.user;
import cn.quantgroup.xyqb.entity.CustomerLoginEntity;
/**
* Created by 11 on 2016/12/29.
*/
public interface ICustomerLoginService {
CustomerLoginEntity findSlaveByCustomerId(Long customerId);
}
package cn.quantgroup.xyqb.service.user;
import cn.quantgroup.xyqb.entity.Address;
import cn.quantgroup.xyqb.entity.OauthClientDetailsEntity;
import java.util.List;
/**
* Created by Miraculous on 2017/1/3.
*/
public interface IOauthClientDetailsService {
OauthClientDetailsEntity findFirstByClientId(Long clientId);
OauthClientDetailsEntity findFirstByClientId(String clientId);
}
package cn.quantgroup.xyqb.service.user;
import cn.quantgroup.xyqb.entity.OauthClientDetailsEntity;
import cn.quantgroup.xyqb.entity.User;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
* Created by Li Jianhua on 2017/1/3.
*/
public interface IOauthLoginInfoService {
void addLoginInfo(User user, Long tenantId);
void addLoginInfo(User user, String tenantId);
}
package cn.quantgroup.xyqb.service.user;
import cn.quantgroup.xyqb.entity.ProductLoginEntity;
/**
* Created by 11 on 2016/12/29.
*/
public interface IProductLoginService {
ProductLoginEntity findSlaveByPloginInfo(String institutionId, String productId, Long userId);
}
package cn.quantgroup.xyqb.service.user;
import cn.quantgroup.xyqb.entity.SmsTemplateEntity;
import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.repository.ISmsTemplateRepository;
import cn.quantgroup.xyqb.util.GcodeUtils;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import javax.inject.Inject;
import java.util.*;
/**
* Created by hechao on 2020/2/17.
*/
@Slf4j
@Service
public class ISmsService {
@Inject
private ISmsTemplateRepository smsTemplateRepository;
public String sendSms(Long clientId, String type, String phoneNo) {
JsonResult res = new JsonResult();
String code = null;
try {
Optional<SmsTemplateEntity> optional = smsTemplateRepository.findFirstByClientIdAndType(clientId, type);
if (!optional.isPresent()) {
log.error("没有指定的模板");
return code;
}
SmsTemplateEntity smsTemplateEntity = optional.orElse(new SmsTemplateEntity());
RestTemplate restTemplate = new RestTemplate();
Map<String, Object> user = new HashMap<>();
List<String> contentArgs = new ArrayList<>();
code = GcodeUtils.generatedcode(5);
contentArgs.add(code);
user.put("merchantId", smsTemplateEntity.getMerchantId());
user.put("phoneNo", phoneNo);
user.put("contentId", smsTemplateEntity.getContentId());
user.put("contentArgs", contentArgs);
ResponseEntity<String> responseEntity = restTemplate.postForEntity("https://msgapi-qa.liangkebang.net/middle_office/send/message/quick", user, String.class); //提交的body内容为user对象,请求的返回的body类型为String
int statusCode = responseEntity.getStatusCodeValue();
String bodyCode = JSONObject.parseObject(responseEntity.getBody(), HashMap.class).get("code").toString();
if (200 != statusCode || !"0".equals(bodyCode)) {
log.error("验证码发送失败");
return null;
}
} catch (Exception e) {
e.printStackTrace();
log.error("发送验证码异常---{}", e.getMessage());
}
return code;
}
}
package cn.quantgroup.xyqb.service.user;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserDetail;
/**
* Created by 11 on 2016/12/29.
*/
public interface ITenantService {
User getTenantUser(User user, String tenantId);
UserDetail getTenantUserDetail(UserDetail userDetail, String tenantId);
}
package cn.quantgroup.xyqb.service.user.impl;
import cn.quantgroup.tech.db.DSType;
import cn.quantgroup.tech.db.TargetDataSource;
import cn.quantgroup.xyqb.entity.CustomerInfoEntity;
import cn.quantgroup.xyqb.repository.ICustomerInfoRepository;
import cn.quantgroup.xyqb.service.user.ICustomerInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Created by 11 on 2016/12/29.
*/
@Slf4j
@Service
public class CustomerInfoServiceImpl implements ICustomerInfoService {
@Autowired
private ICustomerInfoRepository customerInfoRepository;
@Override
@TargetDataSource(type = DSType.SLAVE)//查询从库
public CustomerInfoEntity findSlaveByCustomerId(Long customerId) {
CustomerInfoEntity customerInfo = customerInfoRepository.findByCustomerId(customerId);
return customerInfo;
}
}
package cn.quantgroup.xyqb.service.user.impl;
import cn.quantgroup.tech.db.DSType;
import cn.quantgroup.tech.db.TargetDataSource;
import cn.quantgroup.xyqb.entity.CustomerLoginEntity;
import cn.quantgroup.xyqb.repository.ICustomerLoginRepository;
import cn.quantgroup.xyqb.service.user.ICustomerLoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Created by 11 on 2016/12/29.
*/
@Slf4j
@Service
public class CustomerLoginServiceImpl implements ICustomerLoginService {
@Autowired
private ICustomerLoginRepository customerLoginRepository;
@Override
@TargetDataSource(type = DSType.SLAVE)//查询从库
public CustomerLoginEntity findSlaveByCustomerId(Long customerId) {
CustomerLoginEntity customerLogin = customerLoginRepository.findFirstByCustomerId(customerId);
return customerLogin;
}
}
package cn.quantgroup.xyqb.service.user.impl;
import cn.quantgroup.tech.db.DSType;
import cn.quantgroup.tech.db.TargetDataSource;
import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.entity.OauthClientDetailsEntity;
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.IOauthClientDetailsRepository;
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.IOauthClientDetailsService;
import cn.quantgroup.xyqb.service.user.IUserDetailService;
import cn.quantgroup.xyqb.service.user.vo.UserDetailVO;
import cn.quantgroup.xyqb.util.AddressFilter;
import cn.quantgroup.xyqb.util.ValidationUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.persistence.criteria.Predicate;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
/**
* Created by 11 on 2016/12/29.
*/
......@@ -48,7 +18,7 @@ public class OauthClientDetailsServiceImpl implements IOauthClientDetailsService
@Override
public OauthClientDetailsEntity findFirstByClientId(Long clientId) {
public OauthClientDetailsEntity findFirstByClientId(String clientId) {
OauthClientDetailsEntity oauthClientDetailsEntity = oauthClientDetailsRepository.findFirstByClientId(clientId);
return oauthClientDetailsEntity;
}
......
......@@ -5,21 +5,16 @@ import cn.quantgroup.xyqb.repository.ICustomerInfoRepository;
import cn.quantgroup.xyqb.repository.ICustomerLoginRepository;
import cn.quantgroup.xyqb.repository.IOauthClientDetailsRepository;
import cn.quantgroup.xyqb.repository.IProductLoginRepository;
import cn.quantgroup.xyqb.service.user.IOauthClientDetailsService;
import cn.quantgroup.xyqb.service.user.IOauthLoginInfoService;
import cn.quantgroup.xyqb.util.AtomicSequencer;
import cn.quantgroup.xyqb.util.RandomSequencer;
import com.sun.media.sound.AutoConnectSequencer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.util.Date;
import java.util.Map;
import java.util.UUID;
/**
* Created by 11 on 2016/12/29.
......@@ -44,7 +39,7 @@ public class OauthLoginInfoServiceImpl implements IOauthLoginInfoService {
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void addLoginInfo(User user, Long tenantId) {
public void addLoginInfo(User user, String tenantId) {
System.out.println(atomicSequencer.nextId());
OauthClientDetailsEntity oauthClientDetailsEntity = oauthClientDetailsRepository.findFirstByClientId(tenantId);
String institutionId = oauthClientDetailsEntity.getInstitutionId();
......
package cn.quantgroup.xyqb.service.user.impl;
import cn.quantgroup.tech.db.DSType;
import cn.quantgroup.tech.db.TargetDataSource;
import cn.quantgroup.xyqb.entity.ProductLoginEntity;
import cn.quantgroup.xyqb.repository.IProductLoginRepository;
import cn.quantgroup.xyqb.service.user.IProductLoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Created by 11 on 2016/12/29.
*/
@Slf4j
@Service
public class ProductLoginServiceImpl implements IProductLoginService {
@Autowired
private IProductLoginRepository productLoginRepository;
@Override
@TargetDataSource(type = DSType.SLAVE)//查询从库
public ProductLoginEntity findSlaveByPloginInfo(String institutionId, String productId, Long userId) {
ProductLoginEntity productLogin = productLoginRepository.findByInstitutionIdAndProductIdAndExtensionAccountId(institutionId, productId, userId);
return productLogin;
}
}
package cn.quantgroup.xyqb.service.user.impl;
import cn.quantgroup.xyqb.entity.*;
import cn.quantgroup.xyqb.service.user.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Created by 11 on 2016/12/29.
*/
@Slf4j
@Service
public class TenantServiceImpl implements ITenantService {
@Autowired
private IProductLoginService productLoginService;
@Autowired
private ICustomerInfoService customerInfoService;
@Autowired
private IOauthClientDetailsService oauthClientDetailsService;
@Override
public User getTenantUser(User user, String tenantId) {
OauthClientDetailsEntity oauthClientDetails = oauthClientDetailsService.findFirstByClientId(tenantId);
if (oauthClientDetails != null) {
ProductLoginEntity productLogin = productLoginService.findSlaveByPloginInfo(oauthClientDetails.getInstitutionId(), oauthClientDetails.getProductId(), user.getId());
if (productLogin != null) {
if (!user.getPhoneNo().equals(productLogin.getPhoneNo())) {
return null;
}
user.setPassword(productLogin.getPassword());
return user;
}
}
return null;
}
@Override
public UserDetail getTenantUserDetail(UserDetail userDetail, String tenantId) {
OauthClientDetailsEntity oauthClientDetails = oauthClientDetailsService.findFirstByClientId(tenantId);
if (oauthClientDetails != null) {
ProductLoginEntity productLogin = productLoginService.findSlaveByPloginInfo(oauthClientDetails.getInstitutionId(), oauthClientDetails.getProductId(), userDetail.getUserId());
if (productLogin != null) {
if (!userDetail.getPhoneNo().equals(productLogin.getPhoneNo())) {
return null;
}
CustomerInfoEntity customerInfo = customerInfoService.findSlaveByCustomerId(productLogin.getCustomerId());
if (customerInfo == null) {
return null;
}
UserDetail tenantUserDetail = new UserDetail();
tenantUserDetail.setUserId(userDetail.getUserId());
tenantUserDetail.setPhoneNo(userDetail.getPhoneNo());
tenantUserDetail.setIdNo(customerInfo.getIdCardNo());
tenantUserDetail.setName(customerInfo.getName());
tenantUserDetail.setCreatedAt(userDetail.getCreatedAt());
tenantUserDetail.setUpdatedAt(userDetail.getUpdatedAt());
return tenantUserDetail;
}
}
return null;
}
}
package cn.quantgroup.xyqb.util;
/**
* Created with IntelliJ IDEA.
*
* @author: Li JianHua
* @Date: 2021/10/13
* @Time: 16:53
* Description: No Description
*/
public class GcodeUtils {
/**
* 生成?位的数字类型的短信验证码
*
* @param count
* @return
*/
public static String generatedcode(int count) {
String code = String.valueOf((int)((Math.random()*9+1)* Math.pow(10,count-1)));
return code;
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
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