init
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.newyetai.sdk.fangxinqian.config;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author sr on 2020-04-09
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class FxqCommonProperties{
|
||||
|
||||
/** 是否启用 **/
|
||||
private Boolean enable = Boolean.FALSE;
|
||||
/** id **/
|
||||
private String appId;
|
||||
/** secret **/
|
||||
private String appSecret;
|
||||
/** 接口地址 **/
|
||||
private String url;
|
||||
/** 次数限制 **/
|
||||
private Long numLimit;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.newyetai.sdk.fangxinqian.config;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 合同相关配置
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class FxqContractExtensionProperties {
|
||||
/**
|
||||
* 是否启用
|
||||
**/
|
||||
private Boolean enable = Boolean.FALSE;
|
||||
/**
|
||||
* 接口地址
|
||||
**/
|
||||
private String url;
|
||||
/**
|
||||
* 次数限制
|
||||
**/
|
||||
private Long numLimit;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.newyetai.sdk.fangxinqian.config;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 合同相关配置
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class FxqContractProperties extends FxqCommonProperties {
|
||||
|
||||
/**
|
||||
* 普通签署
|
||||
*/
|
||||
private FxqContractExtensionProperties commonSign;
|
||||
/**
|
||||
* 关键字签署
|
||||
*/
|
||||
private FxqContractExtensionProperties keySign;
|
||||
/**
|
||||
* 存证
|
||||
*/
|
||||
private FxqContractExtensionProperties evidenceSave;
|
||||
/**
|
||||
* 出证
|
||||
*/
|
||||
private FxqContractExtensionProperties evidenceGet;
|
||||
|
||||
public FxqCommonProperties build(FxqContractExtensionProperties properties) {
|
||||
FxqCommonProperties result = new FxqCommonProperties();
|
||||
result.setAppId(this.getAppId());
|
||||
result.setAppSecret(this.getAppSecret());
|
||||
result.setEnable(properties.getEnable());
|
||||
result.setNumLimit(properties.getNumLimit());
|
||||
result.setUrl(properties.getUrl());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.newyetai.sdk.fangxinqian.config;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 放心签配置
|
||||
*
|
||||
* @author sr on 2020-04-09
|
||||
*/
|
||||
@ConfigurationProperties(prefix = FxqProperties.PREFIX, ignoreUnknownFields = false)
|
||||
@Data
|
||||
@Component
|
||||
@NoArgsConstructor
|
||||
public class FxqProperties {
|
||||
|
||||
/**
|
||||
* 放心签配置前缀
|
||||
**/
|
||||
public static final String PREFIX = "fangxinqian";
|
||||
/**
|
||||
* 放心签三要素配置前缀
|
||||
**/
|
||||
public static final String BANK_CARD_THREE_PREFIX = PREFIX + ".bankCard3";
|
||||
/**
|
||||
* 放心签四要素配置前缀
|
||||
**/
|
||||
public static final String BANK_CARD_FOUR_PREFIX = PREFIX + ".bankCard4";
|
||||
|
||||
/**
|
||||
* 实名认证配置前缀
|
||||
*/
|
||||
public static final String REALNAME_AUTH_PREFIX = PREFIX + ".realname";
|
||||
|
||||
/**
|
||||
* 工商核验
|
||||
*/
|
||||
public static final String GOVERNMENT_AUTH_PREFIX = PREFIX + ".government";
|
||||
|
||||
/**
|
||||
* 普通签署
|
||||
*/
|
||||
public static final String COMMON_SIGN_PREFIX = PREFIX + ".contract.commonSign";
|
||||
|
||||
/**
|
||||
* 关键字签署
|
||||
*/
|
||||
public static final String KEY_SIGN_PREFIX = PREFIX + ".contract.keySign";
|
||||
/**
|
||||
* 存证
|
||||
*/
|
||||
public static final String EVIDENCE_SAVE_PREFIX = PREFIX + ".contract.evidenceSave";
|
||||
|
||||
/**
|
||||
* 出证
|
||||
*/
|
||||
public static final String EVIDENCE_GET_PREFIX = PREFIX + ".contract.evidenceGet";
|
||||
|
||||
|
||||
/**
|
||||
* https://api.fangxinqian.cn
|
||||
*/
|
||||
private String domain;
|
||||
|
||||
/**
|
||||
* 系统预留手机号
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 公章uri
|
||||
*/
|
||||
private String officialSealUri;
|
||||
|
||||
/**
|
||||
* 个人章uri
|
||||
*/
|
||||
private String personalSealUri;
|
||||
|
||||
/**
|
||||
* 合同关键字替换
|
||||
*/
|
||||
private String textReplaceUri;
|
||||
|
||||
/**
|
||||
* 银行卡三要素配置
|
||||
**/
|
||||
private FxqCommonProperties bankCard3;
|
||||
|
||||
/**
|
||||
* 银行卡四要素配置
|
||||
**/
|
||||
private FxqCommonProperties bankCard4;
|
||||
|
||||
/**
|
||||
* 实名认证配置
|
||||
*/
|
||||
private FxqCommonProperties realName;
|
||||
|
||||
/**
|
||||
* 工商信息核验配置
|
||||
*/
|
||||
private FxqCommonProperties government;
|
||||
|
||||
/**
|
||||
* 合同
|
||||
*/
|
||||
private FxqContractProperties contract;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.newyetai.sdk.fangxinqian.constant;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.newyetai.common.AlitaResult;
|
||||
|
||||
/**
|
||||
* 银行三要素验证结果枚举
|
||||
*
|
||||
* @author sr on 2020-04-10
|
||||
*/
|
||||
public enum BankCardFourStateEnum {
|
||||
/** 验证一致 **/
|
||||
SUC("1", "验证一致"),
|
||||
/** 验证不一致 **/
|
||||
FAIL("2", "验证不一致");
|
||||
|
||||
private static Map<String, BankCardFourStateEnum> stateMap;
|
||||
/** 验证结果 **/
|
||||
private String state;
|
||||
/** 说明 **/
|
||||
private String msg;
|
||||
|
||||
|
||||
BankCardFourStateEnum(String state, String msg) {
|
||||
this.state = state;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
static {
|
||||
BankCardFourStateEnum[] array = BankCardFourStateEnum.values();
|
||||
stateMap = Maps.newHashMapWithExpectedSize(array.length);
|
||||
for (BankCardFourStateEnum stateEnum : array) {
|
||||
stateMap.put(stateEnum.getState(), stateEnum);
|
||||
}
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理验证结果
|
||||
*
|
||||
* @param state
|
||||
* @return
|
||||
* @author sr on 2020-04-10
|
||||
*/
|
||||
public static AlitaResult<Boolean> dealState(String state) {
|
||||
BankCardFourStateEnum stateEnum = stateMap.get(state);
|
||||
if (stateEnum == null) {
|
||||
return AlitaResult.success("state not available...", false);
|
||||
}
|
||||
if (stateEnum == SUC) {
|
||||
return AlitaResult.success(true);
|
||||
}
|
||||
return AlitaResult.success(stateEnum.getMsg(), false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.newyetai.sdk.fangxinqian.constant;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.newyetai.common.AlitaResult;
|
||||
|
||||
/**
|
||||
* 银行三要素验证结果枚举
|
||||
*
|
||||
* @author sr on 2020-04-10
|
||||
*/
|
||||
public enum BankCardThreeStateEnum {
|
||||
/** 验证一致 **/
|
||||
SUC("1", "验证一致"),
|
||||
/** 验证不一致 **/
|
||||
FAIL("2", "验证不一致"),
|
||||
/** 异常情况 **/
|
||||
UNKNOWN("3", "异常情况");
|
||||
|
||||
private static Map<String, BankCardThreeStateEnum> stateMap;
|
||||
/** 验证结果 **/
|
||||
private String state;
|
||||
/** 说明 **/
|
||||
private String msg;
|
||||
|
||||
|
||||
BankCardThreeStateEnum(String state, String msg) {
|
||||
this.state = state;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
static {
|
||||
BankCardThreeStateEnum[] array = BankCardThreeStateEnum.values();
|
||||
stateMap = Maps.newHashMapWithExpectedSize(array.length);
|
||||
for (BankCardThreeStateEnum stateEnum : array) {
|
||||
stateMap.put(stateEnum.getState(), stateEnum);
|
||||
}
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理验证结果
|
||||
*
|
||||
* @param state
|
||||
* @return
|
||||
* @author sr on 2020-04-10
|
||||
*/
|
||||
public static AlitaResult<Boolean> dealState(String state) {
|
||||
BankCardThreeStateEnum stateEnum = stateMap.get(state);
|
||||
if (stateEnum == null) {
|
||||
return AlitaResult.success("state not available...", false);
|
||||
}
|
||||
if (stateEnum == SUC) {
|
||||
return AlitaResult.success(true);
|
||||
}
|
||||
return AlitaResult.success(stateEnum.getMsg(), false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.newyetai.sdk.fangxinqian.constant;
|
||||
|
||||
import com.newyetai.sdk.common.constant.SdkConstants;
|
||||
|
||||
/**
|
||||
* @author sr on 2020-04-10
|
||||
*/
|
||||
public interface FxqConstants {
|
||||
|
||||
/** 成功码 **/
|
||||
String SUC_CODE = "10000";
|
||||
|
||||
/** ================ fxq 调起真实服务前异常msg ================= **/
|
||||
String PROPERTIES_NOT_SET = SdkConstants.FXQ_CODE + ":配置文件未配置";
|
||||
String ID_SECRET_NOT_ENOUGH = SdkConstants.FXQ_CODE + ":参数appId或appSecret缺失";
|
||||
/** ================ fxq 调起真实服务前异常msq ================= **/
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.newyetai.sdk.fangxinqian.constant;
|
||||
|
||||
/**
|
||||
* sdk放心签错误码枚举;标识:放心签(01)
|
||||
* @author sr on 2020-05-22
|
||||
*/
|
||||
public enum FxqErrorCodeEnum {
|
||||
|
||||
/** 放心签调用返回错误码 **/
|
||||
INVOKE_RETURN_ERROR("060101", "放心签接口调用失败,返回错误码"),
|
||||
/** 放心签调用成功,但信息不匹配 **/
|
||||
NOT_EQUAL("060102", "不匹配");
|
||||
|
||||
/** 错误码 **/
|
||||
private String code;
|
||||
/** 错误信息 **/
|
||||
private String msg;
|
||||
|
||||
FxqErrorCodeEnum(String code, String msg){
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 银行卡四要素请求
|
||||
*
|
||||
* @author sr on 2020-04-09
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class BankCardFourRequestDTO extends FxqRequestDTO implements Serializable {
|
||||
|
||||
/** **/
|
||||
private static final long serialVersionUID = 3807618123977056991L;
|
||||
|
||||
/** 姓名 **/
|
||||
@NotBlank(message = "姓名不能为空")
|
||||
private String name;
|
||||
/** 身份证号 **/
|
||||
@NotBlank(message = "身份证号不能为空")
|
||||
private String identityCode;
|
||||
/** 银行卡号 **/
|
||||
@NotBlank(message = "银行卡号不能为空")
|
||||
private String bankcardNumber;
|
||||
@NotBlank(message = "手机号码不能为空")
|
||||
private String phoneNumber;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* 银行卡四要素请求
|
||||
*
|
||||
* @author sr on 2020-04-09
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@ToString(callSuper = true)
|
||||
public class BankCardFourResponseDTO extends FxqResponseDTO {
|
||||
|
||||
/** **/
|
||||
private static final long serialVersionUID = 3188936116187424875L;
|
||||
|
||||
/** 结果data **/
|
||||
private StateDataDTO data;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 银行卡三要素请求
|
||||
*
|
||||
* @author sr on 2020-04-09
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class BankCardThreeRequestDTO extends FxqRequestDTO implements Serializable {
|
||||
|
||||
/** **/
|
||||
private static final long serialVersionUID = -6539738426193243916L;
|
||||
|
||||
/** 姓名 **/
|
||||
@NotBlank(message = "姓名不能为空")
|
||||
private String name;
|
||||
/** 身份证号 **/
|
||||
@NotBlank(message = "身份证号不能为空")
|
||||
private String identityCode;
|
||||
/** 银行卡号 **/
|
||||
@NotBlank(message = "银行卡号不能为空")
|
||||
private String bankcardNumber;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* 银行卡三要素请求
|
||||
*
|
||||
* @author sr on 2020-04-09
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@ToString(callSuper = true)
|
||||
public class BankCardThreeResponseDTO extends FxqResponseDTO {
|
||||
|
||||
/** **/
|
||||
private static final long serialVersionUID = 3188936116187424875L;
|
||||
|
||||
/** 结果data **/
|
||||
private StateDataDTO data;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 合同签署请求DTO
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class ContractRequestDTO extends FxqRequestDTO {
|
||||
private static final long serialVersionUID = 7354207669664708465L;
|
||||
|
||||
/**
|
||||
* 合同⽂件(base64/云存储⽂件链接)
|
||||
*/
|
||||
@NotBlank(message = "合同⽂件不能为空")
|
||||
private String contract;
|
||||
|
||||
/**
|
||||
* 合同文件名
|
||||
*/
|
||||
@NotBlank(message = "合同⽂件名不能为空")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 0.返回签署完成的base64 1.返回云存储⽂件链接 不填默认 0
|
||||
*/
|
||||
private String returnType;
|
||||
|
||||
/**
|
||||
* 签署⼈信息
|
||||
*/
|
||||
@Valid
|
||||
@NotNull(message = "签署⼈信息不能为空")
|
||||
private List<CommonSignSigner> signers;
|
||||
|
||||
/**
|
||||
* 签署人信息
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public static class CommonSignSigner {
|
||||
/**
|
||||
* 真实姓名/公司名称
|
||||
*/
|
||||
@NotBlank(message = "签署人名称不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 身份证号码/统⼀信⽤代码
|
||||
*/
|
||||
@NotBlank(message = "签署人证件信息不能为空")
|
||||
private String idcard;
|
||||
|
||||
/**
|
||||
* 签章图⽚⽂件
|
||||
*/
|
||||
@NotBlank(message = "签章图⽚⽂件信息不能为空")
|
||||
private String img;
|
||||
|
||||
/**
|
||||
* 个⼈传⼿机号码,企业传法⼈⼿机号码/公司简称的拼⾳⾸字⺟ 如葫芦娃:hlw
|
||||
*/
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 该值控制骑缝章位置 ⼤于100 表示需要签署骑缝章 双⽅骑缝章 位置间隔建议⼤于100 最⼤不能超过650
|
||||
*/
|
||||
private Integer gapMargin;
|
||||
|
||||
/**
|
||||
* 签署区域 (普通签署方式)
|
||||
*/
|
||||
private List<Area> areas;
|
||||
|
||||
/**
|
||||
* 签署关键字 (关键字签署方式)
|
||||
*/
|
||||
private String key;
|
||||
/**
|
||||
* 签章签署在距离关键字距离 正数(往右)负数(往左) (关键字签署方式)
|
||||
*/
|
||||
private Integer marginLeft;
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public static class Area {
|
||||
@NotNull(message = "签署区域左下⻆点X坐标不能为空")
|
||||
private Integer x1;
|
||||
@NotNull(message = "签署区域左下⻆点Y坐标不能为空")
|
||||
private Integer y1;
|
||||
@NotNull(message = "签署区域右上⻆点X坐标不能为空")
|
||||
private Integer x2;
|
||||
@NotNull(message = "签署区域右上⻆点Y坐标不能为空")
|
||||
private Integer y2;
|
||||
@NotNull(message = "签署⻚数不能为空")
|
||||
private Integer page;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ContractResponseDTO extends FxqResponseDTO<String> {
|
||||
|
||||
/**
|
||||
* 文件base64或云链接
|
||||
*/
|
||||
private String data;
|
||||
|
||||
@Override
|
||||
protected String handleData() {
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 区块链出证请求DTO
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class EvidenceGetRequestDTO extends FxqRequestDTO {
|
||||
private static final long serialVersionUID = 7354207669664708465L;
|
||||
|
||||
/**
|
||||
* 合同区块链存证时的回执
|
||||
*/
|
||||
@NotNull(message = "回执不能为空")
|
||||
private String evidenceID;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class EvidenceGetResponseDTO extends FxqResponseDTO<String> {
|
||||
|
||||
/**
|
||||
* 证据链上地址
|
||||
*/
|
||||
private String data;
|
||||
|
||||
@Override
|
||||
protected String handleData() {
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 区块链存证请求DTO
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class EvidenceSaveRequestDTO extends FxqRequestDTO {
|
||||
private static final long serialVersionUID = 7354207669664708465L;
|
||||
|
||||
/**
|
||||
* 合同⽂件(base64/云存储⽂件链接)
|
||||
*/
|
||||
@NotBlank(message = "合同⽂件不能为空")
|
||||
private String contract;
|
||||
|
||||
/**
|
||||
* 合同名称
|
||||
*/
|
||||
@NotBlank(message = "合同名称不能为空")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* ⾏业类型
|
||||
* 1 政务⺠⽣
|
||||
* 2 保险
|
||||
* 3 银⾏
|
||||
* 4 消费⾦融-资产
|
||||
* 5 消费⾦融-资⾦
|
||||
* 6 持牌⼩贷
|
||||
* 7 医疗
|
||||
* 8 教育
|
||||
* 9 出⾏与交通
|
||||
* 10 ⽣活服务
|
||||
* 11 通信与运营商
|
||||
* 12 旅游与酒店
|
||||
* 13 快递与邮政
|
||||
* 99 其他
|
||||
*/
|
||||
@NotBlank(message = "⾏业类型不能为空")
|
||||
private String industry;
|
||||
|
||||
/**
|
||||
* 签署⼈信息
|
||||
*/
|
||||
@NotNull(message = "签署⼈列表")
|
||||
private List<UserInfo> userInfos;
|
||||
|
||||
/**
|
||||
* 合同签署⼈列表
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public static class UserInfo {
|
||||
/**
|
||||
* 真实姓名/公司名称
|
||||
*/
|
||||
@NotBlank(message = "签署人姓名不能为空")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* ⽤户类型 0.个⼈ 1.企业
|
||||
*/
|
||||
@NotBlank(message = "⽤户类型不能为空")
|
||||
private String customerType;
|
||||
|
||||
/**
|
||||
* 证件类型 具体参考类型列表
|
||||
* 0 居⺠身份证
|
||||
* 1 护照
|
||||
* 3 ⼯商登记证
|
||||
* C 台湾居⺠来往⼤陆通⾏证
|
||||
* P 外国⼈永久居留证
|
||||
* Z 其它
|
||||
*/
|
||||
@NotBlank(message = "证件类型不能为空")
|
||||
private String identificationType;
|
||||
|
||||
/**
|
||||
* 证件号码
|
||||
*/
|
||||
@NotBlank(message = "证件号码不能为空")
|
||||
private String identificationNo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class EvidenceSaveResponseDTO extends FxqResponseDTO<String> {
|
||||
|
||||
/**
|
||||
* 区块链存证业务回执 这个需要⾃⾏保存 出证需要⽤到
|
||||
*/
|
||||
private String data;
|
||||
|
||||
@Override
|
||||
protected String handleData() {
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 放心签请求父类dto
|
||||
*
|
||||
* @author sr on 2020-04-09
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class FxqRequestDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 3960499271644654446L;
|
||||
/**
|
||||
* id
|
||||
**/
|
||||
private String appId;
|
||||
/**
|
||||
* secret
|
||||
**/
|
||||
private String appSecret;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import com.newyetai.common.AlitaResult;
|
||||
import com.newyetai.sdk.fangxinqian.constant.FxqConstants;
|
||||
import com.newyetai.sdk.fangxinqian.constant.FxqErrorCodeEnum;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 放心签返回
|
||||
*
|
||||
* @param <T>
|
||||
* @author sr on 2020-04-09
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class FxqResponseDTO<T> implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
**/
|
||||
private static final long serialVersionUID = -4576000729533850612L;
|
||||
/**
|
||||
* 错误码
|
||||
**/
|
||||
private String code;
|
||||
/**
|
||||
* 序列号(每次调用接口返回的唯一值,seqNo 如有接口问题,请提供此值)
|
||||
**/
|
||||
private String seqNo;
|
||||
/**
|
||||
* 错误信息 1
|
||||
**/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 错误信息 2
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
|
||||
public static FxqResponseDTO buildCommonError() {
|
||||
FxqResponseDTO fxqResponseDTO = new FxqResponseDTO();
|
||||
fxqResponseDTO.setCode("999");
|
||||
return fxqResponseDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回结果处理
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public AlitaResult<T> handleResult() {
|
||||
if (FxqConstants.SUC_CODE.equals(this.getCode())) {
|
||||
return AlitaResult.success(handleData());
|
||||
} else {
|
||||
return AlitaResult.error(FxqErrorCodeEnum.INVOKE_RETURN_ERROR.getCode(),
|
||||
StringUtils.isEmpty(this.getMsg()) ?
|
||||
StringUtils.isEmpty(this.getMessage()) ? FxqErrorCodeEnum.INVOKE_RETURN_ERROR.getMsg() : this.getMessage()
|
||||
: this.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 子类DTO实现 转换为AlitaResult时
|
||||
* 通过 handleData()决定转换为AlitaResult的data返回什么
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected T handleData() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author chenyun
|
||||
* @description [ 放心签 ] 公章生成请求DTO
|
||||
* @date 2020/8/14 11:33
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class GovernmentAuthRequestDTO extends FxqRequestDTO {
|
||||
|
||||
private static final long serialVersionUID = -5777141264861824696L;
|
||||
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
@NotNull(message = "企业名称不能为空")
|
||||
private String companyName;
|
||||
|
||||
/**
|
||||
* 企业类型 0.企业 1.个体⼯商户
|
||||
*/
|
||||
@NotNull(message = "企业类型不能为空")
|
||||
private String companyType;
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Data
|
||||
public class GovernmentAuthResponseDTO extends FxqResponseDTO<GovernmentAuthResponseDTO.GovernmentAuthResponseDataDTO> {
|
||||
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 返回实体
|
||||
*/
|
||||
private Map<String, GovernmentAuthResponseDataDTO> data;
|
||||
|
||||
@Override
|
||||
protected GovernmentAuthResponseDataDTO handleData() {
|
||||
return Optional.ofNullable(this.getData())
|
||||
.map(result -> Optional.ofNullable(result.get("basic")).orElse(null))
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class GovernmentAuthResponseDataDTO implements Serializable {
|
||||
private static final long serialVersionUID = -3235649555399151281L;
|
||||
private String esdate;
|
||||
/**
|
||||
* 原注册号
|
||||
*/
|
||||
private String regno;
|
||||
/**
|
||||
* 统一信用代码
|
||||
*/
|
||||
private String creditcode;
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
private String dom;
|
||||
/**
|
||||
* 经营业务范围
|
||||
*/
|
||||
private String zsopscope;
|
||||
/**
|
||||
* 实收资本
|
||||
*/
|
||||
private String reccap;
|
||||
/**
|
||||
* 原注册号
|
||||
*/
|
||||
private String oriregno;
|
||||
/**
|
||||
* 企业英文名
|
||||
*/
|
||||
private String entnameeng;
|
||||
/**
|
||||
* 企业类型
|
||||
*/
|
||||
private String enttype;
|
||||
/**
|
||||
* 最后年检度
|
||||
*/
|
||||
private String ancheyear;
|
||||
/**
|
||||
* 经营期限至
|
||||
*/
|
||||
private String opto;
|
||||
/**
|
||||
* 经营企业自
|
||||
*/
|
||||
private String opfrom;
|
||||
/**
|
||||
* 注册资本币种
|
||||
*/
|
||||
private String regcapcur;
|
||||
/**
|
||||
* 组织机构代码
|
||||
*/
|
||||
private String orgcodes;
|
||||
/**
|
||||
* 注销日期
|
||||
*/
|
||||
private String candate;
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
private String entname;
|
||||
/**
|
||||
* 实收资本
|
||||
*/
|
||||
private String regcap;
|
||||
/**
|
||||
* 登记机关
|
||||
*/
|
||||
private String regorg;
|
||||
/**
|
||||
* 吊销日期
|
||||
*/
|
||||
private String revdate;
|
||||
/**
|
||||
* 经营状态
|
||||
*/
|
||||
private String entstatus;
|
||||
/**
|
||||
* 许可经营项目
|
||||
*/
|
||||
private String abuitem;
|
||||
/**
|
||||
* 注册地址编码
|
||||
*/
|
||||
private String regorgcode;
|
||||
/**
|
||||
* 法人姓名
|
||||
*/
|
||||
private String frname;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String apprdate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author chenyun
|
||||
* @description [ 放心签 ] 公章生成请求DTO
|
||||
* @date 2020/8/14 11:33
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class OfficialSealGenerateRequestDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4020535227323920801L;
|
||||
|
||||
/**
|
||||
* 系统预留⼿机号
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
@NotNull(message = "公司名称不能为空")
|
||||
private String companyName;
|
||||
|
||||
/**
|
||||
* 公章类型 默认圆形 0:圆形 ,1:椭圆形
|
||||
*/
|
||||
@NotNull(message = "公章类型不能为空")
|
||||
private String serviceType;
|
||||
|
||||
/**
|
||||
* 公章颜⾊ , 默认红⾊ ,0:红⾊ ,1:蓝⾊ ,2:⿊⾊
|
||||
*/
|
||||
private String color;
|
||||
|
||||
/**
|
||||
* 公章字体 , 默认宋体 ,0:宋体 ,1:楷体 ,2:正⽅⿊体
|
||||
*/
|
||||
private String font;
|
||||
|
||||
/**
|
||||
* 公章下弦⽂
|
||||
*/
|
||||
private String serNo;
|
||||
|
||||
/**
|
||||
* 公章副标题
|
||||
*/
|
||||
private String title;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author chenyun
|
||||
* @description [ 放心签 ] 个人章生成请求DTO
|
||||
* @date 2020/8/17 10:41
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PersonalSealGenerateRequestDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4020535227323920801L;
|
||||
|
||||
/**
|
||||
* 系统预留⼿机号
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 个⼈签章名称
|
||||
*/
|
||||
@NotNull(message = "个⼈签章名称不能为空")
|
||||
private String fontText;
|
||||
|
||||
/**
|
||||
* 签章颜⾊ , 默认红⾊ ,1: 红⾊ ,2: ⿊⾊ ,3: 蓝⾊
|
||||
*/
|
||||
private Integer colorTag;
|
||||
|
||||
/**
|
||||
* 签章字体 , 默认⽅正⿊体 ,1: ⽅正⿊体 ,2: 仿宋 ,3: 楷体
|
||||
*/
|
||||
private Integer fontFamilyTag;
|
||||
|
||||
/**
|
||||
* 签章类型 , 默认⻓⽅形 ; 1: ⻓⽅形 , 2 正⽅形
|
||||
*/
|
||||
private Integer shape;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import com.newyetai.common.annotation.Mask;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PersonalSealGenerateResponseDTO extends FxqResponseDTO<String> {
|
||||
|
||||
/**
|
||||
* 公章/个人章 图片 base64
|
||||
*/
|
||||
@Mask
|
||||
private String data;
|
||||
|
||||
@Override
|
||||
protected String handleData() {
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author chenyun
|
||||
* @description [ 放心签 ] 公章生成请求DTO
|
||||
* @date 2020/8/14 11:33
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RealnameAuthRequestDTO extends FxqRequestDTO {
|
||||
|
||||
private static final long serialVersionUID = -5777141264861824696L;
|
||||
|
||||
/**
|
||||
* 系统预留⼿机号
|
||||
*/
|
||||
@NotNull(message = "姓名不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
@NotNull(message = "身份证号码不能为空")
|
||||
private String identityNumber;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import com.newyetai.sdk.fangxinqian.enums.RealnameResultEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Optional;
|
||||
|
||||
@Data
|
||||
public class RealnameAuthResponseDTO extends FxqResponseDTO<Boolean> {
|
||||
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 实名认证结果 1:实名通过 2:实名不通过
|
||||
*/
|
||||
private RealnameAuthResponseDataDTO data;
|
||||
|
||||
@Override
|
||||
protected Boolean handleData() {
|
||||
return Optional.ofNullable(this.getData())
|
||||
.map(result -> Optional.ofNullable(result.getResult()).orElse("").equals(RealnameResultEnum.SUC.getResult()))
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class RealnameAuthResponseDataDTO implements Serializable {
|
||||
private static final long serialVersionUID = -3235649555399151281L;
|
||||
private String result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SealGenerateResponseDTO extends FxqResponseDTO<String> {
|
||||
|
||||
/**
|
||||
* 公章/个人章 图片 base64
|
||||
*/
|
||||
private String baseStr;
|
||||
|
||||
@Override
|
||||
protected String handleData() {
|
||||
return this.baseStr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author sr on 2020-04-09
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class StateDataDTO implements Serializable{
|
||||
|
||||
/** **/
|
||||
private static final long serialVersionUID = -4608569342053995450L;
|
||||
|
||||
/** 状态 **/
|
||||
private String state;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import com.newyetai.common.annotation.Mask;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author chenyun
|
||||
* @description [ 放心签 ] 合同替换关键字请求DTO
|
||||
* @date 2020/8/17 11:15
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TextReplaceRequestDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4020535227323920801L;
|
||||
|
||||
/**
|
||||
* 系统预留⼿机号
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 待替换的 base64 ⽂档
|
||||
*/
|
||||
@Mask
|
||||
@NotNull(message = "个⼈签章名称不能为空")
|
||||
private String fileBase64;
|
||||
|
||||
/**
|
||||
* ⽂件类型暂时只⽀持以下三种
|
||||
* 1:pdf 2:doc 3.docx
|
||||
* 不传默认1
|
||||
*/
|
||||
private String fileType;
|
||||
|
||||
/** 待替换内容集合 **/
|
||||
private List<KeyValueBO> keyValues;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class KeyValueBO {
|
||||
/**
|
||||
* 关键字key
|
||||
*/
|
||||
private String oldText;
|
||||
|
||||
/**
|
||||
* 关键字value
|
||||
*/
|
||||
private String newText;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.newyetai.sdk.fangxinqian.dto;
|
||||
|
||||
import com.newyetai.common.annotation.Mask;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TextReplaceResponseDTO extends FxqResponseDTO<String> {
|
||||
|
||||
/**
|
||||
* 文档 base64
|
||||
*/
|
||||
@Mask
|
||||
private String data;
|
||||
|
||||
@Override
|
||||
protected String handleData() {
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.newyetai.sdk.fangxinqian.enums;
|
||||
|
||||
/**
|
||||
* 实名认证状态枚举类
|
||||
*/
|
||||
public enum RealnameResultEnum {
|
||||
|
||||
SUC("1", "实名通过"),
|
||||
FAIL("2", "实名不通过");
|
||||
|
||||
private String result;
|
||||
private String message;
|
||||
|
||||
RealnameResultEnum(String result, String message) {
|
||||
this.result = result;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.newyetai.sdk.fangxinqian.service;
|
||||
|
||||
import com.newyetai.common.AlitaResult;
|
||||
import com.newyetai.sdk.fangxinqian.dto.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.groups.Default;
|
||||
|
||||
/**
|
||||
* 放心签
|
||||
*
|
||||
* @author sr on 2020-04-09
|
||||
*/
|
||||
@Validated(Default.class)
|
||||
public interface FangXinQianService {
|
||||
|
||||
String BEAN_ID = "sdk.fangXinQianService";
|
||||
String MOCK_BEAN_ID = "mock.fangXinQianService";
|
||||
|
||||
/**
|
||||
* 银行卡三要素
|
||||
*
|
||||
* @param bankCardThreeRequestDto
|
||||
* @return success-false真实调用第三方未成功,未拿到返回值;
|
||||
* success-true获取到第三方返回,data-true校验成功,data-false校验不一致并返回失败原因(msg)
|
||||
* @author sr on 2020-04-10
|
||||
*/
|
||||
AlitaResult<Boolean> checkBankCardThree(@NotNull @Valid BankCardThreeRequestDTO bankCardThreeRequestDto);
|
||||
|
||||
/**
|
||||
* 银行卡四要素
|
||||
*
|
||||
* @param bankCardFourRequestDto
|
||||
* @return success-false真实调用第三方未成功,未拿到返回值;
|
||||
* success-true获取到第三方返回,data-true校验成功,data-false校验不一致并返回失败原因(msg)
|
||||
* @author sr on 2020-05-22
|
||||
*/
|
||||
AlitaResult<Boolean> checkBankCardFour(@NotNull @Valid BankCardFourRequestDTO bankCardFourRequestDto);
|
||||
|
||||
/**
|
||||
* 公章生成
|
||||
*
|
||||
* @param officialSealGenerateRequestDTO
|
||||
* @return base64
|
||||
*/
|
||||
AlitaResult<String> generateOfficialSeal(@NotNull @Valid OfficialSealGenerateRequestDTO officialSealGenerateRequestDTO);
|
||||
|
||||
/**
|
||||
* 个人章生成
|
||||
*
|
||||
* @param personalSealGenerateRequestDTO
|
||||
* @return
|
||||
*/
|
||||
AlitaResult<String> generatePersonalSeal(@NotNull @Valid PersonalSealGenerateRequestDTO personalSealGenerateRequestDTO);
|
||||
|
||||
|
||||
/**
|
||||
* 文档关键字替换
|
||||
*
|
||||
* @param textReplaceRequestDTO
|
||||
* @return
|
||||
*/
|
||||
AlitaResult<String> textReplace(@NotNull @Valid TextReplaceRequestDTO textReplaceRequestDTO);
|
||||
|
||||
/**
|
||||
* 实名认证
|
||||
*
|
||||
* @param realnameAuthRequestDTO
|
||||
* @return
|
||||
*/
|
||||
AlitaResult<Boolean> realnameAuth(@NotNull @Valid RealnameAuthRequestDTO realnameAuthRequestDTO);
|
||||
|
||||
/**
|
||||
* 工商信息核验
|
||||
*
|
||||
* @param governmentAuthRequestDTO
|
||||
* @return
|
||||
*/
|
||||
AlitaResult<GovernmentAuthResponseDTO.GovernmentAuthResponseDataDTO> governmentAuth(@NotNull @Valid GovernmentAuthRequestDTO governmentAuthRequestDTO);
|
||||
|
||||
/**
|
||||
* 合同签署 (普通签署)
|
||||
*
|
||||
* @param contractRequestDTO
|
||||
* @return
|
||||
*/
|
||||
AlitaResult<String> contractCommonSign(@NotNull @Valid ContractRequestDTO contractRequestDTO);
|
||||
|
||||
/**
|
||||
* 合同签署 (关键字签署)
|
||||
*
|
||||
* @param contractRequestDTO
|
||||
* @return
|
||||
*/
|
||||
AlitaResult<String> contractKeySign(@NotNull @Valid ContractRequestDTO contractRequestDTO);
|
||||
|
||||
|
||||
/**
|
||||
* 存证接⼝
|
||||
* 存证成功的合同默认30s以后才能出证,如果太早出证会提示证据不存在
|
||||
*
|
||||
* @param evidenceSaveRequestDTO
|
||||
* @return
|
||||
*/
|
||||
AlitaResult<String> evidenceSave(@NotNull @Valid EvidenceSaveRequestDTO evidenceSaveRequestDTO);
|
||||
|
||||
/**
|
||||
* 出证接口
|
||||
*
|
||||
* @param evidenceGetRequestDTO
|
||||
* @return
|
||||
*/
|
||||
AlitaResult<String> evidenceGet(@NotNull @Valid EvidenceGetRequestDTO evidenceGetRequestDTO);
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
package com.newyetai.sdk.fangxinqian.service.impl;
|
||||
|
||||
import com.newyetai.common.AlitaResult;
|
||||
import com.newyetai.common.annotation.CheckAndMock;
|
||||
import com.newyetai.sdk.common.constant.SdkConstants;
|
||||
import com.newyetai.sdk.fangxinqian.config.FxqCommonProperties;
|
||||
import com.newyetai.sdk.fangxinqian.config.FxqContractProperties;
|
||||
import com.newyetai.sdk.fangxinqian.config.FxqProperties;
|
||||
import com.newyetai.sdk.fangxinqian.constant.BankCardFourStateEnum;
|
||||
import com.newyetai.sdk.fangxinqian.constant.BankCardThreeStateEnum;
|
||||
import com.newyetai.sdk.fangxinqian.constant.FxqConstants;
|
||||
import com.newyetai.sdk.fangxinqian.constant.FxqErrorCodeEnum;
|
||||
import com.newyetai.sdk.fangxinqian.dto.*;
|
||||
import com.newyetai.sdk.fangxinqian.service.FangXinQianService;
|
||||
import com.newyetai.sdk.fangxinqian.util.FxqUtils;
|
||||
import com.newyetai.sdk.fangxinqian.util.HttpUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author sr on 2020-04-09
|
||||
*/
|
||||
@Slf4j
|
||||
@Service(FangXinQianService.BEAN_ID)
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class FangXinQianServiceImpl implements FangXinQianService {
|
||||
|
||||
private final FxqProperties fxqProperties;
|
||||
|
||||
@Override
|
||||
public AlitaResult<String> generateOfficialSeal(OfficialSealGenerateRequestDTO officialSealGenerateRequestDTO) {
|
||||
if (StringUtils.isEmpty(officialSealGenerateRequestDTO.getPhone())) {
|
||||
officialSealGenerateRequestDTO.setPhone(fxqProperties.getPhone());
|
||||
}
|
||||
return HttpUtil
|
||||
.execute(fxqProperties.getDomain().concat(fxqProperties.getOfficialSealUri()),
|
||||
officialSealGenerateRequestDTO, SealGenerateResponseDTO.class)
|
||||
.handleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlitaResult<String> generatePersonalSeal(PersonalSealGenerateRequestDTO personalSealGenerateRequestDTO) {
|
||||
if (StringUtils.isEmpty(personalSealGenerateRequestDTO.getPhone())) {
|
||||
personalSealGenerateRequestDTO.setPhone(fxqProperties.getPhone());
|
||||
}
|
||||
return HttpUtil
|
||||
.execute(fxqProperties.getDomain().concat(fxqProperties.getPersonalSealUri()),
|
||||
personalSealGenerateRequestDTO, PersonalSealGenerateResponseDTO.class)
|
||||
.handleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlitaResult<String> textReplace(TextReplaceRequestDTO textReplaceRequestDTO) {
|
||||
if (StringUtils.isEmpty(textReplaceRequestDTO.getPhone())) {
|
||||
textReplaceRequestDTO.setPhone(fxqProperties.getPhone());
|
||||
}
|
||||
return HttpUtil
|
||||
.execute(fxqProperties.getDomain().concat(fxqProperties.getTextReplaceUri()),
|
||||
textReplaceRequestDTO, TextReplaceResponseDTO.class)
|
||||
.handleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CheckAndMock(mockClass = MockFangXinQianServiceImpl.class,
|
||||
propertyPrefix = FxqProperties.REALNAME_AUTH_PREFIX)
|
||||
public AlitaResult<Boolean> realnameAuth(RealnameAuthRequestDTO realnameAuthRequestDTO) {
|
||||
FxqCommonProperties fxqCommonProperties = fxqProperties.getRealName();
|
||||
// 校验部分
|
||||
if (fxqCommonProperties == null) {
|
||||
return AlitaResult.error(SdkConstants.SDK_INVOKE_NOT_REACH_CODE,
|
||||
FxqConstants.PROPERTIES_NOT_SET);
|
||||
}
|
||||
if (!FxqUtils.dealAppIdAndSecret(fxqCommonProperties, realnameAuthRequestDTO)) {
|
||||
return AlitaResult.error(SdkConstants.SDK_INVOKE_NOT_REACH_CODE,
|
||||
FxqConstants.ID_SECRET_NOT_ENOUGH);
|
||||
}
|
||||
//执行
|
||||
return HttpUtil
|
||||
.execute(fxqProperties.getDomain().concat(fxqCommonProperties.getUrl()),
|
||||
realnameAuthRequestDTO, RealnameAuthResponseDTO.class)
|
||||
.handleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CheckAndMock(mockClass = MockFangXinQianServiceImpl.class,
|
||||
propertyPrefix = FxqProperties.GOVERNMENT_AUTH_PREFIX)
|
||||
public AlitaResult<GovernmentAuthResponseDTO.GovernmentAuthResponseDataDTO> governmentAuth(GovernmentAuthRequestDTO governmentAuthRequestDTO) {
|
||||
FxqCommonProperties fxqCommonProperties = fxqProperties.getGovernment();
|
||||
// 校验部分
|
||||
if (fxqCommonProperties == null) {
|
||||
return AlitaResult.error(SdkConstants.SDK_INVOKE_NOT_REACH_CODE,
|
||||
FxqConstants.PROPERTIES_NOT_SET);
|
||||
}
|
||||
if (!FxqUtils.dealAppIdAndSecret(fxqCommonProperties, governmentAuthRequestDTO)) {
|
||||
return AlitaResult.error(SdkConstants.SDK_INVOKE_NOT_REACH_CODE,
|
||||
FxqConstants.ID_SECRET_NOT_ENOUGH);
|
||||
}
|
||||
//执行
|
||||
return HttpUtil
|
||||
.execute(fxqProperties.getDomain().concat(fxqCommonProperties.getUrl()),
|
||||
governmentAuthRequestDTO, GovernmentAuthResponseDTO.class)
|
||||
.handleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CheckAndMock(mockClass = MockFangXinQianServiceImpl.class,
|
||||
propertyPrefix = FxqProperties.COMMON_SIGN_PREFIX)
|
||||
public AlitaResult<String> contractCommonSign(ContractRequestDTO contractRequestDTO) {
|
||||
FxqContractProperties contract = fxqProperties.getContract();
|
||||
FxqCommonProperties fxqCommonProperties = contract.build(contract.getCommonSign());
|
||||
// 校验部分
|
||||
if (fxqCommonProperties == null) {
|
||||
return AlitaResult.error(
|
||||
SdkConstants.SDK_INVOKE_NOT_REACH_CODE, FxqConstants.PROPERTIES_NOT_SET);
|
||||
}
|
||||
if (!FxqUtils.dealAppIdAndSecret(fxqCommonProperties, contractRequestDTO)) {
|
||||
return AlitaResult.error(
|
||||
SdkConstants.SDK_INVOKE_NOT_REACH_CODE, FxqConstants.ID_SECRET_NOT_ENOUGH);
|
||||
}
|
||||
// 执行
|
||||
return HttpUtil
|
||||
.execute(fxqProperties.getDomain().concat(fxqCommonProperties.getUrl()),
|
||||
contractRequestDTO, ContractResponseDTO.class)
|
||||
.handleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CheckAndMock(mockClass = MockFangXinQianServiceImpl.class,
|
||||
propertyPrefix = FxqProperties.KEY_SIGN_PREFIX)
|
||||
public AlitaResult<String> contractKeySign(ContractRequestDTO contractRequestDTO) {
|
||||
FxqContractProperties contract = fxqProperties.getContract();
|
||||
FxqCommonProperties fxqCommonProperties = contract.build(contract.getKeySign());
|
||||
// 校验部分
|
||||
if (fxqCommonProperties == null) {
|
||||
return AlitaResult.error(
|
||||
SdkConstants.SDK_INVOKE_NOT_REACH_CODE, FxqConstants.PROPERTIES_NOT_SET);
|
||||
}
|
||||
if (!FxqUtils.dealAppIdAndSecret(fxqCommonProperties, contractRequestDTO)) {
|
||||
return AlitaResult.error(
|
||||
SdkConstants.SDK_INVOKE_NOT_REACH_CODE, FxqConstants.ID_SECRET_NOT_ENOUGH);
|
||||
}
|
||||
// 执行
|
||||
return HttpUtil
|
||||
.execute(
|
||||
fxqProperties.getDomain().concat(fxqCommonProperties.getUrl()),
|
||||
contractRequestDTO, ContractResponseDTO.class)
|
||||
.handleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CheckAndMock(mockClass = MockFangXinQianServiceImpl.class,
|
||||
propertyPrefix = FxqProperties.EVIDENCE_SAVE_PREFIX)
|
||||
public AlitaResult<String> evidenceSave(EvidenceSaveRequestDTO evidenceSaveRequestDTO) {
|
||||
FxqContractProperties contract = fxqProperties.getContract();
|
||||
FxqCommonProperties fxqCommonProperties = contract.build(contract.getEvidenceSave());
|
||||
// 校验部分
|
||||
if (fxqCommonProperties == null) {
|
||||
return AlitaResult.error(
|
||||
SdkConstants.SDK_INVOKE_NOT_REACH_CODE, FxqConstants.PROPERTIES_NOT_SET);
|
||||
}
|
||||
if (!FxqUtils.dealAppIdAndSecret(fxqCommonProperties, evidenceSaveRequestDTO)) {
|
||||
return AlitaResult.error(
|
||||
SdkConstants.SDK_INVOKE_NOT_REACH_CODE, FxqConstants.ID_SECRET_NOT_ENOUGH);
|
||||
}
|
||||
// 执行
|
||||
return HttpUtil
|
||||
.execute(
|
||||
fxqProperties.getDomain().concat(fxqCommonProperties.getUrl()),
|
||||
evidenceSaveRequestDTO, ContractResponseDTO.class)
|
||||
.handleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CheckAndMock(mockClass = MockFangXinQianServiceImpl.class,
|
||||
propertyPrefix = FxqProperties.EVIDENCE_GET_PREFIX)
|
||||
public AlitaResult<String> evidenceGet(EvidenceGetRequestDTO evidenceGetRequestDTO) {
|
||||
FxqContractProperties contract = fxqProperties.getContract();
|
||||
FxqCommonProperties fxqCommonProperties = contract.build(contract.getEvidenceGet());
|
||||
// 校验部分
|
||||
if (fxqCommonProperties == null) {
|
||||
return AlitaResult.error(
|
||||
SdkConstants.SDK_INVOKE_NOT_REACH_CODE, FxqConstants.PROPERTIES_NOT_SET);
|
||||
}
|
||||
if (!FxqUtils.dealAppIdAndSecret(fxqCommonProperties, evidenceGetRequestDTO)) {
|
||||
return AlitaResult.error(
|
||||
SdkConstants.SDK_INVOKE_NOT_REACH_CODE, FxqConstants.ID_SECRET_NOT_ENOUGH);
|
||||
}
|
||||
// 执行
|
||||
return HttpUtil
|
||||
.execute(
|
||||
fxqProperties.getDomain().concat(fxqCommonProperties.getUrl()),
|
||||
evidenceGetRequestDTO, ContractResponseDTO.class)
|
||||
.handleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CheckAndMock(mockClass = MockFangXinQianServiceImpl.class,
|
||||
propertyPrefix = FxqProperties.BANK_CARD_THREE_PREFIX)
|
||||
public AlitaResult<Boolean> checkBankCardThree(BankCardThreeRequestDTO bankCardThreeRequestDto) {
|
||||
return this.check(bankCardThreeRequestDto, fxqProperties.getBankCard3(),
|
||||
BankCardThreeResponseDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CheckAndMock(mockClass = MockFangXinQianServiceImpl.class,
|
||||
propertyPrefix = FxqProperties.BANK_CARD_FOUR_PREFIX)
|
||||
public AlitaResult<Boolean> checkBankCardFour(BankCardFourRequestDTO bankCardFourRequestDto) {
|
||||
return this.check(bankCardFourRequestDto, fxqProperties.getBankCard4(),
|
||||
BankCardFourResponseDTO.class);
|
||||
}
|
||||
|
||||
|
||||
private <T extends FxqResponseDTO> AlitaResult<Boolean> check(FxqRequestDTO fxqRequestDto,
|
||||
FxqCommonProperties fxqCommonProperties,
|
||||
Class<T> responseClazz) {
|
||||
// 校验部分
|
||||
if (fxqCommonProperties == null) {
|
||||
return AlitaResult.error(SdkConstants.SDK_INVOKE_NOT_REACH_CODE,
|
||||
FxqConstants.PROPERTIES_NOT_SET);
|
||||
}
|
||||
if (!FxqUtils.dealAppIdAndSecret(fxqCommonProperties, fxqRequestDto)) {
|
||||
return AlitaResult.error(SdkConstants.SDK_INVOKE_NOT_REACH_CODE,
|
||||
FxqConstants.ID_SECRET_NOT_ENOUGH);
|
||||
}
|
||||
// 执行
|
||||
FxqResponseDTO responseDto = HttpUtil.execute(fxqProperties.getDomain().concat(fxqCommonProperties.getUrl()),
|
||||
fxqRequestDto, responseClazz);
|
||||
|
||||
// 返回结果校验
|
||||
if (!FxqConstants.SUC_CODE.equals(responseDto.getCode())) {
|
||||
return AlitaResult.success(StringUtils.join(FxqErrorCodeEnum.INVOKE_RETURN_ERROR.getMsg(),
|
||||
responseDto.getMessage()), false);
|
||||
}
|
||||
if (responseClazz == BankCardThreeResponseDTO.class) {
|
||||
String state = ((BankCardThreeResponseDTO) responseDto).getData().getState();
|
||||
return BankCardThreeStateEnum.dealState(state);
|
||||
}
|
||||
|
||||
// 处理验证结果
|
||||
return BankCardFourStateEnum.dealState(((BankCardFourResponseDTO) responseDto).getData().getState());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.newyetai.sdk.fangxinqian.service.impl;
|
||||
|
||||
import com.newyetai.common.AlitaResult;
|
||||
import com.newyetai.sdk.fangxinqian.dto.*;
|
||||
import com.newyetai.sdk.fangxinqian.service.FangXinQianService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author sr on 2020-04-09
|
||||
*/
|
||||
@Service(FangXinQianService.MOCK_BEAN_ID)
|
||||
@Slf4j
|
||||
public class MockFangXinQianServiceImpl implements FangXinQianService {
|
||||
|
||||
@Override
|
||||
public AlitaResult<Boolean> checkBankCardThree(
|
||||
@NotNull @Valid BankCardThreeRequestDTO bankCardThreeRequestDto) {
|
||||
log.info("fxq checkBankCardThree mock...");
|
||||
return AlitaResult.success(true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AlitaResult<Boolean> checkBankCardFour(@NotNull @Valid BankCardFourRequestDTO bankCardFourRequestDto) {
|
||||
log.info("fxq checkBankCardFour mock...");
|
||||
return AlitaResult.success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlitaResult<String> generateOfficialSeal(@NotNull @Valid OfficialSealGenerateRequestDTO officialSealGenerateRequestDTO) {
|
||||
log.info("fxq generateOfficialSeal mock...");
|
||||
return AlitaResult.success("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlitaResult<String> generatePersonalSeal(@NotNull @Valid PersonalSealGenerateRequestDTO personalSealGenerateRequestDTO) {
|
||||
log.info("fxq generatePersonalSeal mock...");
|
||||
return AlitaResult.success("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlitaResult<String> textReplace(@NotNull @Valid TextReplaceRequestDTO textReplaceRequestDTO) {
|
||||
log.info("fxq textReplace mock...");
|
||||
return AlitaResult.success("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlitaResult<Boolean> realnameAuth(@NotNull @Valid RealnameAuthRequestDTO realnameAuthRequestDTO) {
|
||||
log.info("fxq realnameAuth mock...");
|
||||
return AlitaResult.success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlitaResult<GovernmentAuthResponseDTO.GovernmentAuthResponseDataDTO> governmentAuth(@NotNull @Valid GovernmentAuthRequestDTO governmentAuthRequestDTO) {
|
||||
log.info("fxq governmentAuth mock...");
|
||||
return AlitaResult.success(new GovernmentAuthResponseDTO.GovernmentAuthResponseDataDTO());
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlitaResult<String> contractCommonSign(@NotNull @Valid ContractRequestDTO contractRequestDTO) {
|
||||
log.info("fxq contractCommonSign mock...");
|
||||
return AlitaResult.success("https://huluwa-ec.oss-accelerate.aliyuncs.com/20200825/20200825174051_2913.pdf?Expires=4751948451&OSSAccessKeyId=HLUmOSIDpYentPOt&Signature=RB%2FFQgM7dJyBac4DMSG0YZYz3ao%3D");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlitaResult<String> contractKeySign(@NotNull @Valid ContractRequestDTO contractRequestDTO) {
|
||||
log.info("fxq contractKeySign mock...");
|
||||
return AlitaResult.success("https://huluwa-ec.oss-accelerate.aliyuncs.com/20200825/20200825174051_2913.pdf?Expires=4751948451&OSSAccessKeyId=HLUmOSIDpYentPOt&Signature=RB%2FFQgM7dJyBac4DMSG0YZYz3ao%3D");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlitaResult<String> evidenceSave(@NotNull @Valid EvidenceSaveRequestDTO evidenceSaveRequestDTO) {
|
||||
log.info("fxq evidenceSave mock...");
|
||||
return AlitaResult.success("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlitaResult<String> evidenceGet(@NotNull @Valid EvidenceGetRequestDTO evidenceGetRequestDTO) {
|
||||
log.info("fxq evidenceGet mock...");
|
||||
return AlitaResult.success("");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.newyetai.sdk.fangxinqian.util;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.newyetai.sdk.fangxinqian.config.FxqCommonProperties;
|
||||
import com.newyetai.sdk.fangxinqian.dto.FxqRequestDTO;
|
||||
|
||||
/**
|
||||
* 工具类
|
||||
*
|
||||
* @author sr on 2020-04-09
|
||||
*/
|
||||
public final class FxqUtils {
|
||||
|
||||
/**
|
||||
* 私有
|
||||
*/
|
||||
private FxqUtils() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理appId和appSecret参数
|
||||
*
|
||||
* @param <T>
|
||||
* @param fxqCommonProperties
|
||||
* @param fxqRequestDto
|
||||
* @author sr on 2020-04-09
|
||||
*/
|
||||
public static <T extends FxqRequestDTO> boolean dealAppIdAndSecret(FxqCommonProperties fxqCommonProperties,
|
||||
T fxqRequestDto) {
|
||||
|
||||
String appId = fxqRequestDto.getAppId();
|
||||
String appSecret = fxqRequestDto.getAppSecret();
|
||||
boolean enable = enableFxq(fxqCommonProperties);
|
||||
if (StringUtils.isBlank(appId) && enable) {
|
||||
appId = fxqCommonProperties.getAppId();
|
||||
}
|
||||
if (StringUtils.isBlank(appSecret) && enable) {
|
||||
appSecret = fxqCommonProperties.getAppSecret();
|
||||
}
|
||||
if (StringUtils.isBlank(appId) || StringUtils.isBlank(appSecret)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
fxqRequestDto.setAppId(appId);
|
||||
fxqRequestDto.setAppSecret(appSecret);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否开启放心签接口
|
||||
*
|
||||
* @param fxqCommonProperties
|
||||
* @return
|
||||
* @author sr on 2020-04-21
|
||||
*/
|
||||
public static boolean enableFxq(FxqCommonProperties fxqCommonProperties) {
|
||||
return fxqCommonProperties != null && fxqCommonProperties.getEnable();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.newyetai.sdk.fangxinqian.util;
|
||||
|
||||
import com.newyetai.common.util.JsonUtils;
|
||||
import com.newyetai.sdk.fangxinqian.dto.FxqResponseDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StopWatch;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class HttpUtil<T, R> {
|
||||
|
||||
private static RestTemplate restTemplate;
|
||||
|
||||
@Autowired
|
||||
public HttpUtil(RestTemplate restTemplate) {
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Http 通用请求封装
|
||||
*
|
||||
* @param url 请求地址
|
||||
* @param requestDto 请求实体
|
||||
* @param responseClazz 返回实体Class
|
||||
* @param <T>
|
||||
* @param <R>
|
||||
* @return
|
||||
*/
|
||||
public static <T, R extends FxqResponseDTO> FxqResponseDTO execute(String url, T requestDto, Class<R> responseClazz) {
|
||||
ResponseEntity<R> response;
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
try {
|
||||
log.debug("fangxinqian request url :{}", url);
|
||||
log.info("fangxinqian request requestDto :{}", JsonUtils.toJsonString(requestDto));
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
HttpEntity request = new HttpEntity<>(requestDto, headers);
|
||||
response = restTemplate.postForEntity(url, request, responseClazz);
|
||||
log.info("fangxinqian {}:{}", responseClazz.getName(), JsonUtils.toJsonString(response));
|
||||
} catch (Exception e) {
|
||||
log.error("fangxinqian {} invoke error:{}", requestDto.getClass().getName(),
|
||||
e);
|
||||
stopWatch.stop();
|
||||
return FxqResponseDTO.buildCommonError();
|
||||
}
|
||||
stopWatch.stop();
|
||||
log.info("fangxinqian consuming {} s", stopWatch.getTotalTimeSeconds());
|
||||
return JsonUtils.objToClassObj(response.getBody(), responseClazz);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user