Commit ff156b33 authored by shihuajun's avatar shihuajun

基础方法

parent 6bd29b52
......@@ -60,12 +60,15 @@ public class HttpClientConfig {
* 创建TrustManager
*/
X509TrustManager xtm = new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
......@@ -86,16 +89,17 @@ public class HttpClientConfig {
HttpRequestRetryHandler retryHandler = new HttpRequestRetryHandler() {
@Override
public boolean retryRequest(IOException arg0, int retryTimes, HttpContext arg2) {
if (retryTimes >= 2)
if (retryTimes >= 2) {
return false;
}
if (arg0 instanceof UnknownHostException || arg0 instanceof ConnectTimeoutException
|| !(arg0 instanceof SSLException) || arg0 instanceof SocketTimeoutException)
|| !(arg0 instanceof SSLException) || arg0 instanceof SocketTimeoutException) {
return true;
}
HttpClientContext clientContext = HttpClientContext.adapt(arg2);
HttpRequest request = clientContext.getRequest();
if (!(request instanceof HttpEntityEnclosingRequest)) // 如果请求被认为是幂等的,那么就重试。即重复执行不影响程序其他效果的
return true;
return false;
// 如果请求被认为是幂等的,那么就重试。即重复执行不影响程序其他效果的
return !(request instanceof HttpEntityEnclosingRequest);
}
};
// keep alive strategy
......@@ -153,16 +157,17 @@ public class HttpClientConfig {
HttpRequestRetryHandler retryHandler = new HttpRequestRetryHandler() {
@Override
public boolean retryRequest(IOException arg0, int retryTimes, HttpContext arg2) {
if (retryTimes >= 2)
if (retryTimes >= 2) {
return false;
}
if (arg0 instanceof UnknownHostException || arg0 instanceof ConnectTimeoutException
|| !(arg0 instanceof SSLException) || arg0 instanceof SocketTimeoutException)
|| !(arg0 instanceof SSLException) || arg0 instanceof SocketTimeoutException) {
return true;
}
HttpClientContext clientContext = HttpClientContext.adapt(arg2);
HttpRequest request = clientContext.getRequest();
if (!(request instanceof HttpEntityEnclosingRequest)) // 如果请求被认为是幂等的,那么就重试。即重复执行不影响程序其他效果的
return true;
return false;
// 如果请求被认为是幂等的,那么就重试。即重复执行不影响程序其他效果的
return !(request instanceof HttpEntityEnclosingRequest);
}
};
// keep alive strategy
......
......@@ -27,6 +27,7 @@ public class ChannelRuleEntity {
private String userLevel;
private int priority;
private Byte enable;
private Byte routeWait;
private Timestamp createdAt;
private Timestamp updatedAt;
......@@ -180,6 +181,16 @@ public class ChannelRuleEntity {
this.enable = enable;
}
@Basic
@Column(name = "route_wait", nullable = true)
public Byte getRouteWait() {
return routeWait;
}
public void setRouteWait(Byte routeWait) {
this.routeWait = routeWait;
}
@Basic
@Column(name = "created_at", nullable = false)
public Timestamp getCreatedAt() {
......
......@@ -14,7 +14,7 @@ import java.util.Objects;
public class FundProductEntity {
private long id;
private long fundId;
private long fundCorpId;
private Long fundProId;
private String fundName;
private String fundType;
private String orgType;
......@@ -48,13 +48,13 @@ public class FundProductEntity {
}
@Basic
@Column(name = "fund_corp_id", nullable = false)
public long getFundCorpId() {
return fundCorpId;
@Column(name = "fund_pro_id", nullable = false)
public Long getFundProId() {
return fundProId;
}
public void setFundCorpId(long fundCorpId) {
this.fundCorpId = fundCorpId;
public void setFundProId(Long fundProId) {
this.fundProId = fundProId;
}
@Basic
......@@ -117,16 +117,6 @@ public class FundProductEntity {
this.basicRule = basicRule;
}
@Basic
@Column(name = "other_rule", nullable = false, length = 500)
public String getOtherRule() {
return otherRule;
}
public void setOtherRule(String otherRule) {
this.otherRule = otherRule;
}
@Basic
@Column(name = "rule_list", nullable = false, length = 500)
public String getRuleList() {
......@@ -169,14 +159,18 @@ public class FundProductEntity {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
FundProductEntity that = (FundProductEntity) o;
return id == that.id && fundId == that.fundId && fundCorpId == that.fundCorpId && Objects.equals(fundName, that.fundName) && Objects.equals(fundType, that.fundType) && Objects.equals(orgType, that.orgType) && Objects.equals(businessType, that.businessType) && Objects.equals(systermType, that.systermType) && Objects.equals(basicRule, that.basicRule) && Objects.equals(otherRule, that.otherRule) && Objects.equals(ruleList, that.ruleList) && Objects.equals(enable, that.enable) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
return id == that.id && fundId == that.fundId && Objects.equals(fundProId,that.fundProId) && Objects.equals(fundName, that.fundName) && Objects.equals(fundType, that.fundType) && Objects.equals(orgType, that.orgType) && Objects.equals(businessType, that.businessType) && Objects.equals(systermType, that.systermType) && Objects.equals(basicRule, that.basicRule) && Objects.equals(otherRule, that.otherRule) && Objects.equals(ruleList, that.ruleList) && Objects.equals(enable, that.enable) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
}
@Override
public int hashCode() {
return Objects.hash(id, fundId, fundCorpId, fundName, fundType, orgType, businessType, systermType, basicRule, otherRule, ruleList, enable, createdAt, updatedAt);
return Objects.hash(id, fundId, fundProId, fundName, fundType, orgType, businessType, systermType, basicRule, otherRule, ruleList, enable, createdAt, updatedAt);
}
}
......@@ -92,8 +92,12 @@ public class ProductRuleEntity {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ProductRuleEntity that = (ProductRuleEntity) o;
return id == that.id && Objects.equals(ruleName, that.ruleName) && Objects.equals(ruleEnglish, that.ruleEnglish) && Objects.equals(ruleChinese, that.ruleChinese) && Objects.equals(enable, that.enable) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
}
......
......@@ -5,5 +5,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
public interface IChannelRuleRepository extends JpaRepository<ChannelRuleEntity, Long>{
ChannelRuleEntity getByFundProductIdEquals(long fundProductId);
}
......@@ -5,5 +5,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
public interface IProductRuleRepository extends JpaRepository<ProductRuleEntity, Long>{
ProductRuleEntity getByRuleNameEquals(String ruleName);
}
......@@ -5,5 +5,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
public interface IWhiteListRepository extends JpaRepository<WhiteListEntity, Long>{
WhiteListEntity getByPhoneEquals(String phone);
}
/**
* @date 2021/8/26 19:23
* @author shihuajun
* @ describing
*/
package com.quantgroup.asset.distribution.service.newrule;
\ No newline at end of file
package com.quantgroup.asset.distribution.service.user;
import cn.quantgroup.motan.bean.UserAssociationBean;
import cn.quantgroup.motan.bean.UserInfo;
import cn.quantgroup.motan.retbean.XUserExtInfo;
import com.quantgroup.asset.distribution.model.entity.user.SDKUserInfo;
/**
......@@ -25,4 +25,11 @@ public interface IUserCenterService {
* @return
*/
SDKUserInfo getSDKUserExtInfo(String phoneNo, String uuid);
/**
* 根据uuid查询带有联系人的信息
* @param uuid 入参
* @return 结果
*/
UserAssociationBean getUserAssociationBean(String uuid);
}
package com.quantgroup.asset.distribution.service.user.impl;
import cn.quantgroup.motan.bean.UserAssociationBean;
import cn.quantgroup.motan.bean.UserInfo;
import cn.quantgroup.motan.retbean.XUserExtInfo;
import cn.quantgroup.motan.vo.UserSysResult;
......@@ -14,6 +15,7 @@ import com.quantgroup.asset.distribution.service.httpclient.IHttpService;
import com.quantgroup.asset.distribution.service.redis.IRedisService;
import com.quantgroup.asset.distribution.service.user.IUserCenterService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.http.impl.client.CloseableHttpClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
......@@ -93,6 +95,25 @@ public class UserCenterServiceImpl implements IUserCenterService {
return sdkUserInfo;
}
@Override
public UserAssociationBean getUserAssociationBean(String uuid) {
UserSysResult<UserInfo> result = userSdkService.findUserInfoByUuid(uuid);
UserInfo userInfo = new UserInfo();
if (result.isSuccess() && result.getData() != null && result.getData().getId() == null) {
userInfo = result.getData();
} else {
log.error("调用用户中心接口findUserInfoByUuid异常 {}",JSON.toJSONString(userInfo));
throw new RuntimeException("调用用户中心接口findUserInfoByUuid异常");
}
UserSysResult<UserAssociationBean> association = userSdkService.findUserAssociationByUid(userInfo.getId().toString());
if (association == null || !association.isSuccess() || association.getData() == null
|| CollectionUtils.isEmpty(association.getData().getContractResults())){
log.error("调用用户中心接口findUserAssociationByUid异常 {}",JSON.toJSONString(association));
throw new RuntimeException("调用用户中心接口findUserAssociationByUid异常");
}
return association.getData();
}
/**
* 从用户中心获取SDKUserInfo
* @param uuid
......
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