Compare commits
No commits in common. '2.0' and 'master' have entirely different histories.
@ -0,0 +1,13 @@
|
|||||||
|
package com.docus.soap.api;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class DocusSoapApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(DocusSoapApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,31 +0,0 @@
|
|||||||
package com.docus.soap.api;
|
|
||||||
|
|
||||||
import org.springframework.context.ApplicationContextInitializer;
|
|
||||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
|
||||||
import org.springframework.core.env.PropertiesPropertySource;
|
|
||||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
|
||||||
import org.springframework.web.context.ConfigurableWebApplicationContext;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
public class SoapAppContextInitializer implements ApplicationContextInitializer<ConfigurableWebApplicationContext> {
|
|
||||||
@Override
|
|
||||||
public void initialize(ConfigurableWebApplicationContext context) {
|
|
||||||
PropertyLoader propertyLoader = new PropertyLoader();
|
|
||||||
try {
|
|
||||||
propertyLoader.setLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:*.properties"));
|
|
||||||
|
|
||||||
context.getEnvironment().setIgnoreUnresolvableNestedPlaceholders(true);
|
|
||||||
context.getEnvironment().getPropertySources().addLast(new PropertiesPropertySource("properties", propertyLoader.loadProperties()));
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static class PropertyLoader extends PropertySourcesPlaceholderConfigurer {
|
|
||||||
Properties loadProperties() throws IOException {
|
|
||||||
return mergeProperties();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,53 @@
|
|||||||
|
package com.docus.soap.api.request.complain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public enum ComplaintProcessStatus {
|
||||||
|
|
||||||
|
/*受理中*/
|
||||||
|
RECEIVED(0),
|
||||||
|
/*网友已给出方案*/
|
||||||
|
BUYER_GIVE_SOLUTION(1),
|
||||||
|
/*商家已给出方案*/
|
||||||
|
SELLER_GIVE_SOLUTION(2),
|
||||||
|
/*安排监理上门*/
|
||||||
|
SUPERVISOR_CALL(3),
|
||||||
|
/*双方达成协议*/
|
||||||
|
REACH_AGREEMENT(4),
|
||||||
|
/*协调未果*/
|
||||||
|
CONSULTATION_NO_RESULT(5),
|
||||||
|
/*无理投诉*/
|
||||||
|
UNJUSTIFIABLE_COMPLAINT(6),
|
||||||
|
/*处理完成*/
|
||||||
|
FINISH(7),
|
||||||
|
/*节后处理*/
|
||||||
|
PROCESS_AFTER_HOLIDAY(8);
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(ComplaintProcessStatus.class);
|
||||||
|
|
||||||
|
private int value;
|
||||||
|
|
||||||
|
ComplaintProcessStatus(int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public int getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonCreator
|
||||||
|
public static ComplaintProcessStatus fromValue(int code) {
|
||||||
|
for (ComplaintProcessStatus status : ComplaintProcessStatus.values()) {
|
||||||
|
if (status.value == code) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOGGER.warn(ComplaintProcessStatus.class.getName() + " can not find value :" + code);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
package com.docus.soap.api.request.complain;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "GetTableByIdDateDataRequest")
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class GetTableByIdDateDataRequest {
|
||||||
|
|
||||||
|
@XmlElement(name = "store_id")
|
||||||
|
private int storeId;
|
||||||
|
@XmlElement(name = "startDate")
|
||||||
|
private String startDate;
|
||||||
|
@XmlElement(name = "endDate")
|
||||||
|
private String endDate;
|
||||||
|
@XmlElement(name = "complaintGrade")
|
||||||
|
private Integer complaintGrade;
|
||||||
|
@XmlElement(name = "currentpage")
|
||||||
|
private int currentpage;
|
||||||
|
@XmlElement(name = "pagesize")
|
||||||
|
private int pagesize;
|
||||||
|
|
||||||
|
public int getStoreId() {
|
||||||
|
return storeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStoreId(int storeId) {
|
||||||
|
this.storeId = storeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStartDate() {
|
||||||
|
return startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartDate(String startDate) {
|
||||||
|
this.startDate = startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEndDate() {
|
||||||
|
return endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndDate(String endDate) {
|
||||||
|
this.endDate = endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getComplaintGrade() {
|
||||||
|
return complaintGrade;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComplaintGrade(Integer complaintGrade) {
|
||||||
|
this.complaintGrade = complaintGrade;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCurrentpage() {
|
||||||
|
return currentpage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentpage(int currentpage) {
|
||||||
|
this.currentpage = currentpage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPagesize() {
|
||||||
|
return pagesize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPagesize(int pagesize) {
|
||||||
|
this.pagesize = pagesize;
|
||||||
|
}
|
||||||
|
}
|
@ -1,28 +0,0 @@
|
|||||||
package com.docus.soap.api.request.zsyy;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@XmlRootElement(name = "SOF_LoginWithAccountInfo", namespace = "http://webservice.platform.jhsec.com.cn/")
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
|
||||||
public class GetLoginInfoRequest {
|
|
||||||
|
|
||||||
@XmlElement(name = "sys")
|
|
||||||
private String sys;
|
|
||||||
|
|
||||||
@XmlElement(name = "accountType")
|
|
||||||
private String accountType;
|
|
||||||
|
|
||||||
@XmlElement(name = "account")
|
|
||||||
private String account;
|
|
||||||
|
|
||||||
@XmlElement(name = "password")
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package com.docus.soap.api.request.zsyy;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
|
||||||
|
|
||||||
@XmlRootElement(name = "SOF_QueryQRCode", namespace = "http://webservice.qrcode.pki.jhsec.com.cn/")
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
|
||||||
public class GetQueryQRCodeRequest {
|
|
||||||
|
|
||||||
@XmlElement(name = "qrCode")
|
|
||||||
private String qrCode;
|
|
||||||
|
|
||||||
public String getQrCode() {
|
|
||||||
return qrCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setQrCode(String qrCode) {
|
|
||||||
this.qrCode = qrCode;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.docus.soap.api.response.zsyy;
|
package com.docus.soap.api.response.complain;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.docus.soap.api.response.zsyy;
|
package com.docus.soap.api.response.complain;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.*;
|
import javax.xml.bind.annotation.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.docus.soap.api.response.complain;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "GetComplaintListResponse")
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class GetComplaintListResponse {
|
||||||
|
|
||||||
|
@XmlElement(name = "GetComplaintListResult")
|
||||||
|
private String complaintListResult;
|
||||||
|
|
||||||
|
public String getComplaintListResult() {
|
||||||
|
return complaintListResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComplaintListResult(String complaintListResult) {
|
||||||
|
this.complaintListResult = complaintListResult;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
@XmlSchema(namespace = "http://webservice.qrcode.pki.jhsec.com.cn/", elementFormDefault = XmlNsForm.QUALIFIED)
|
@XmlSchema(namespace = "http://webservice.qrcode.pki.jhsec.com.cn/", elementFormDefault = XmlNsForm.QUALIFIED)
|
||||||
package com.docus.soap.api.response.zsyy;
|
package com.docus.soap.api.response.complain;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlNsForm;
|
import javax.xml.bind.annotation.XmlNsForm;
|
||||||
import javax.xml.bind.annotation.XmlSchema;
|
import javax.xml.bind.annotation.XmlSchema;
|
@ -1,42 +0,0 @@
|
|||||||
package com.docus.soap.api.response.zsyy;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
|
||||||
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
|
||||||
public class GetLoginInfoResponse {
|
|
||||||
|
|
||||||
@XmlElement(name = "data")
|
|
||||||
private String data;
|
|
||||||
|
|
||||||
@XmlElement(name = "code")
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
@XmlElement(name = "msg")
|
|
||||||
private String msg;
|
|
||||||
|
|
||||||
public String getMsg() {
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMsg(String msg) {
|
|
||||||
this.msg = msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCode(String code) {
|
|
||||||
this.code = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
package com.docus.soap.api.response.zsyy;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.*;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@XmlRootElement(name = "SOF_LoginWithAccountInfoResponse" ,namespace = "http://webservice.platform.jhsec.com.cn/")
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
|
||||||
public class GetLoginInfoResultResponse {
|
|
||||||
@XmlAnyElement
|
|
||||||
public List<Object> results;
|
|
||||||
|
|
||||||
|
|
||||||
public List<Object> getResults() {
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setResults(List<Object> results) {
|
|
||||||
this.results = results;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package com.docus.soap.api.response.zsyy;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
|
||||||
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
|
||||||
public class GetQueryQRCodeResponse {
|
|
||||||
|
|
||||||
@XmlElement(name = "data")
|
|
||||||
private QueryQRCodeData data;
|
|
||||||
|
|
||||||
@XmlElement(name = "code")
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
@XmlElement(name = "msg")
|
|
||||||
private String msg;
|
|
||||||
|
|
||||||
public String getMsg() {
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMsg(String msg) {
|
|
||||||
this.msg = msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCode(String code) {
|
|
||||||
this.code = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package com.docus.soap.api.response.zsyy;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
|
||||||
import javax.xml.bind.annotation.XmlAnyElement;
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@XmlRootElement(name = "SOF_QueryQRCodeResponse")
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
|
||||||
public class GetQueryQRCodeResultResponse {
|
|
||||||
@XmlAnyElement
|
|
||||||
public List<Object> results;
|
|
||||||
|
|
||||||
|
|
||||||
public List<Object> getResults() {
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setResults(List<Object> results) {
|
|
||||||
this.results = results;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
package com.docus.soap.api.response.zsyy;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
|
||||||
public class QueryQRCodeData implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 2657976429770220410L;
|
|
||||||
@XmlElement(name = "resultCode")
|
|
||||||
private String resultCode;
|
|
||||||
|
|
||||||
@XmlElement(name = "qrCodeStatus")
|
|
||||||
private String qrCodeStatus;
|
|
||||||
|
|
||||||
@XmlElement(name = "userName")
|
|
||||||
private String userName;
|
|
||||||
|
|
||||||
@XmlElement(name = "userIdCardNum")
|
|
||||||
private String userIdCardNum;
|
|
||||||
|
|
||||||
@XmlElement(name = "userPhoneNum")
|
|
||||||
private String userPhoneNum;
|
|
||||||
|
|
||||||
@XmlElement(name = "resultMsg")
|
|
||||||
private String resultMsg;
|
|
||||||
|
|
||||||
@XmlElement(name = "userJobNum")
|
|
||||||
private String userJobNum;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.docus.soap.api.service;
|
||||||
|
|
||||||
|
import com.docus.core.util.json.JSON;
|
||||||
|
import com.docus.soap.api.SoapAPIClient;
|
||||||
|
import com.docus.soap.api.SoapAPISettings;
|
||||||
|
import com.docus.soap.api.request.complain.GetTableByIdDateRequest;
|
||||||
|
import com.docus.soap.api.response.complain.ComplaintListResult;
|
||||||
|
import com.docus.soap.api.response.complain.GetTableByIdDateResponse;
|
||||||
|
import com.sun.org.apache.xerces.internal.dom.ElementNSImpl;
|
||||||
|
|
||||||
|
public class ComplaintAPIService {
|
||||||
|
private SoapAPIClient soapAPIClient;
|
||||||
|
|
||||||
|
public ComplaintListResult getTableByIdDate(GetTableByIdDateRequest targetRequest, SoapAPISettings soapAPISettings) {
|
||||||
|
GetTableByIdDateResponse response = (GetTableByIdDateResponse) soapAPIClient.soapCall(targetRequest, soapAPISettings.getAction(), soapAPISettings.getUri());
|
||||||
|
ComplaintListResult complaintListResult = JSON.fromJSON((((ElementNSImpl) response.getResults().get(0)).getFirstChild().getTextContent()), ComplaintListResult.class);
|
||||||
|
return complaintListResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWebServiceClient(SoapAPIClient webServiceClient) {
|
||||||
|
this.soapAPIClient = webServiceClient;
|
||||||
|
}
|
||||||
|
}
|
@ -1,45 +0,0 @@
|
|||||||
package com.docus.soap.api.service;
|
|
||||||
|
|
||||||
import com.docus.soap.api.SoapAPIClient;
|
|
||||||
import com.docus.soap.api.SoapAPISettings;
|
|
||||||
import com.docus.soap.api.request.zsyy.GetLoginInfoRequest;
|
|
||||||
import com.docus.soap.api.request.zsyy.GetQRCodeBySysRequest;
|
|
||||||
import com.docus.soap.api.request.zsyy.GetQueryQRCodeRequest;
|
|
||||||
import com.docus.soap.api.response.zsyy.*;
|
|
||||||
import com.docus.soap.api.util.JSON;
|
|
||||||
import com.sun.org.apache.xerces.internal.dom.ElementNSImpl;
|
|
||||||
|
|
||||||
public class XMZSYYQRCodeAPIService {
|
|
||||||
private SoapAPIClient soapAPIClient;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 中山医院获取二维码
|
|
||||||
*/
|
|
||||||
public GetQRCodeBySysResponse getQRCodeBySys(GetQRCodeBySysRequest targetRequest, SoapAPISettings soapAPISettings) {
|
|
||||||
GetQRCodeBySysResultResponse response = (GetQRCodeBySysResultResponse) soapAPIClient.soapCall(targetRequest, soapAPISettings.getAction(), soapAPISettings.getUri());
|
|
||||||
return JSON.fromJSON((((ElementNSImpl) response.getResults().get(0)).getFirstChild().getTextContent()), GetQRCodeBySysResponse.class);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @description: 中山医院获取扫码状态
|
|
||||||
* @author linjj
|
|
||||||
* @date: 2023/5/24 11:46
|
|
||||||
*/
|
|
||||||
public GetQueryQRCodeResponse getQueryQRCode(GetQueryQRCodeRequest queryQRCodeRequest, SoapAPISettings soapAPISettings){
|
|
||||||
GetQueryQRCodeResultResponse response = (GetQueryQRCodeResultResponse) soapAPIClient.soapCall(queryQRCodeRequest, soapAPISettings.getAction(), soapAPISettings.getUri());
|
|
||||||
return JSON.fromJSON((((ElementNSImpl) response.getResults().get(0)).getFirstChild().getTextContent()), GetQueryQRCodeResponse.class);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @description: 厦门中山医院单点登录
|
|
||||||
* @author linjj
|
|
||||||
* @date: 2023/5/25 11:33
|
|
||||||
*/
|
|
||||||
public GetLoginInfoResponse getLoginInfo(GetLoginInfoRequest getLoginInfoRequest, SoapAPISettings soapAPISettings){
|
|
||||||
GetLoginInfoResultResponse response = (GetLoginInfoResultResponse) soapAPIClient.soapCall(getLoginInfoRequest, soapAPISettings.getAction(), soapAPISettings.getUri());
|
|
||||||
return JSON.fromJSON((((ElementNSImpl) response.getResults().get(0)).getFirstChild().getTextContent()), GetLoginInfoResponse.class);
|
|
||||||
}
|
|
||||||
public void setWebServiceClient(SoapAPIClient webServiceClient) {
|
|
||||||
this.soapAPIClient = webServiceClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,126 +0,0 @@
|
|||||||
package com.docus.soap.api.util;
|
|
||||||
|
|
||||||
import javax.xml.datatype.DatatypeConfigurationException;
|
|
||||||
import javax.xml.datatype.DatatypeFactory;
|
|
||||||
import javax.xml.datatype.XMLGregorianCalendar;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
|
|
||||||
public final class Convert {
|
|
||||||
public static final String DATE_FORMAT_DATE = "MM/dd/yyyy";
|
|
||||||
public static final String DATE_FORMAT_DATETIME = "MM/dd/yyyy'T'HH:mm:ss";
|
|
||||||
public static final String DATA_FORMAT_DATETIME_SLASH = "yyyy-MM-dd HH:mm:ss";
|
|
||||||
public static final String DATE_FORMAT_ISO_WITH_TIMEZONE = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
|
|
||||||
|
|
||||||
public static Integer toInt(String text, Integer defaultValue) {
|
|
||||||
if (!StringUtils.hasText(text)) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return Integer.parseInt(text);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Long toLong(String text, Long defaultValue) {
|
|
||||||
if (!StringUtils.hasText(text)) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return Long.parseLong(text);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Double toDouble(String text, Double defaultValue) {
|
|
||||||
if (!StringUtils.hasText(text)) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return Double.parseDouble(text);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// since DateFormat is not thread safe, we create for each parsing
|
|
||||||
public static Date toDate(String date, String formatPattern, Date defaultValue) {
|
|
||||||
if (!StringUtils.hasText(date)) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
SimpleDateFormat format = new SimpleDateFormat(formatPattern);
|
|
||||||
return format.parse(date);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Date toDate(String date, String formatPattern) {
|
|
||||||
try {
|
|
||||||
SimpleDateFormat format = new SimpleDateFormat(formatPattern);
|
|
||||||
return format.parse(date);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new IllegalArgumentException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Date toDate(String date, Date defaultValue) {
|
|
||||||
return toDate(date, DATE_FORMAT_DATE, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Date toDateTime(String date, Date defaultValue) {
|
|
||||||
return toDate(date, DATE_FORMAT_DATETIME, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Date toISODateTime(String date, Date defaultValue) {
|
|
||||||
return toDate(date, DATE_FORMAT_ISO_WITH_TIMEZONE, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toString(Date date, String format) {
|
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
|
|
||||||
return dateFormat.format(date);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toString(Date date, String format, TimeZone timeZone) {
|
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
|
|
||||||
dateFormat.setTimeZone(timeZone);
|
|
||||||
return dateFormat.format(date);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static XMLGregorianCalendar toXMLGregorianCalendar(Date date) {
|
|
||||||
DatatypeFactory factory;
|
|
||||||
try {
|
|
||||||
factory = DatatypeFactory.newInstance();
|
|
||||||
} catch (DatatypeConfigurationException e) {
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
XMLGregorianCalendar result = factory.newXMLGregorianCalendar();
|
|
||||||
Calendar calendar = DateUtils.calendar(date);
|
|
||||||
result.setYear(calendar.get(Calendar.YEAR));
|
|
||||||
result.setMonth(calendar.get(Calendar.MONTH) + 1);
|
|
||||||
result.setDay(calendar.get(Calendar.DAY_OF_MONTH));
|
|
||||||
result.setTime(calendar.get(Calendar.HOUR), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T extends Enum<T>> T toEnum(String value, Class<T> enumClass, T defaultValue) {
|
|
||||||
if (!StringUtils.hasText(value)) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return Enum.valueOf(enumClass, value);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Convert() {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,117 +0,0 @@
|
|||||||
package com.docus.soap.api.util;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Date should be considered as immutable object (e.g. String), all methods in
|
|
||||||
* this util return new instance
|
|
||||||
*/
|
|
||||||
public final class DateUtils {
|
|
||||||
public static Date date(int year, int month, int day) {
|
|
||||||
return date(year, month, day, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Date date(int year, int month, int day, int hour, int minute, int second) {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setLenient(false);
|
|
||||||
calendar.set(year, month, day, hour, minute, second);
|
|
||||||
calendar.set(Calendar.MILLISECOND, 0);
|
|
||||||
return calendar.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Calendar calendar(Date date) {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTime(date);
|
|
||||||
return calendar;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Date add(Date date, int field, int value) {
|
|
||||||
Calendar calendar = calendar(date);
|
|
||||||
calendar.add(field, value);
|
|
||||||
return calendar.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int get(Date date, int field) {
|
|
||||||
Calendar calendar = calendar(date);
|
|
||||||
return calendar.get(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Date withField(Date date, int field, int value) {
|
|
||||||
Calendar calendar = calendar(date);
|
|
||||||
calendar.set(field, value);
|
|
||||||
return calendar.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getYear(Date date) {
|
|
||||||
return get(date, Calendar.YEAR);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getMonth(Date date) {
|
|
||||||
return get(date, Calendar.MONTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getDay(Date date) {
|
|
||||||
return get(date, Calendar.DATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getHour(Date date) {
|
|
||||||
return get(date, Calendar.HOUR_OF_DAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getMinute(Date date) {
|
|
||||||
return get(date, Calendar.MINUTE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Date withHour(Date date, int value) {
|
|
||||||
return withField(date, Calendar.HOUR_OF_DAY, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Date withMinute(Date date, int value) {
|
|
||||||
return withField(date, Calendar.MINUTE, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Date toCurrentTimeZone(Date targetDate, TimeZone targetTimeZone) {
|
|
||||||
Calendar target = calendar(targetDate);
|
|
||||||
|
|
||||||
Calendar result = Calendar.getInstance(targetTimeZone);
|
|
||||||
result.set(Calendar.YEAR, target.get(Calendar.YEAR));
|
|
||||||
result.set(Calendar.MONTH, target.get(Calendar.MONTH));
|
|
||||||
result.set(Calendar.DATE, target.get(Calendar.DATE));
|
|
||||||
result.set(Calendar.HOUR_OF_DAY, target.get(Calendar.HOUR_OF_DAY));
|
|
||||||
result.set(Calendar.MINUTE, target.get(Calendar.MINUTE));
|
|
||||||
result.set(Calendar.SECOND, target.get(Calendar.SECOND));
|
|
||||||
result.set(Calendar.MILLISECOND, target.get(Calendar.MILLISECOND));
|
|
||||||
|
|
||||||
return result.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isWeekDay(Date targetDate) {
|
|
||||||
Calendar calendar = calendar(targetDate);
|
|
||||||
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
|
|
||||||
return dayOfWeek != Calendar.SATURDAY && dayOfWeek != Calendar.SUNDAY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isDateValid(int year, int month, int day) {
|
|
||||||
try {
|
|
||||||
date(year, month, day);
|
|
||||||
return true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Date truncateTime(Date date) {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTime(date);
|
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
||||||
calendar.set(Calendar.MINUTE, 0);
|
|
||||||
calendar.set(Calendar.SECOND, 0);
|
|
||||||
calendar.set(Calendar.MILLISECOND, 0);
|
|
||||||
return calendar.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
private DateUtils() {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
package com.docus.soap.api.util;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public final class JSONBinder<T> {
|
|
||||||
static final ObjectMapper DEFAULT_OBJECT_MAPPER;
|
|
||||||
|
|
||||||
static {
|
|
||||||
DEFAULT_OBJECT_MAPPER = ObjectMapperBuilder.defaultObjectMapper().get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> JSONBinder<T> binder(Class<T> beanClass) {
|
|
||||||
return new JSONBinder<>(beanClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ObjectMapper getObjectMapper() {
|
|
||||||
return DEFAULT_OBJECT_MAPPER;
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectMapper objectMapper;
|
|
||||||
private final Class<T> beanClass;
|
|
||||||
|
|
||||||
private JSONBinder(Class<T> beanClass) {
|
|
||||||
this.beanClass = beanClass;
|
|
||||||
this.objectMapper = DEFAULT_OBJECT_MAPPER;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T fromJSON(String json) {
|
|
||||||
try {
|
|
||||||
return objectMapper.readValue(json, beanClass);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toJSON(T object) {
|
|
||||||
try {
|
|
||||||
return objectMapper.writeValueAsString(object);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public JSONBinder<T> indentOutput() {
|
|
||||||
if (DEFAULT_OBJECT_MAPPER.equals(objectMapper)) {
|
|
||||||
objectMapper = ObjectMapperBuilder.defaultObjectMapper().rebirth().get();
|
|
||||||
}
|
|
||||||
objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,82 +0,0 @@
|
|||||||
package com.docus.soap.api.util;
|
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.FieldPosition;
|
|
||||||
import java.text.ParsePosition;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class JSONDateFormat extends DateFormat {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
|
|
||||||
toAppendTo.append(Convert.toString(date, Convert.DATE_FORMAT_ISO_WITH_TIMEZONE));
|
|
||||||
return toAppendTo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Date parse(String source, ParsePosition pos) {
|
|
||||||
pos.setIndex(source.length());
|
|
||||||
|
|
||||||
if (isContainChar(source, '-')) {
|
|
||||||
if (Convert.DATA_FORMAT_DATETIME_SLASH.length() == source.length()) {
|
|
||||||
return Convert.toDate(source, Convert.DATA_FORMAT_DATETIME_SLASH);
|
|
||||||
} else {
|
|
||||||
return Convert.toDate(source, getISOPattern(source));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ("MM/dd/yyyyTHH:mm:ss".length() == source.length()) {
|
|
||||||
//TODO: remove legacy format
|
|
||||||
return Convert.toDate(source, Convert.DATE_FORMAT_DATETIME);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Convert.toDate(source, Convert.DATE_FORMAT_DATE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isContainChar(String source, char character) {
|
|
||||||
if (!StringUtils.hasText(source)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (char c : source.toCharArray()) {
|
|
||||||
if (character == c) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getISOPattern(String source) {
|
|
||||||
StringBuilder b = new StringBuilder("yyyy-MM-dd'T'HH:mm:ss");
|
|
||||||
int precision = 0;
|
|
||||||
int state = 0;
|
|
||||||
|
|
||||||
for (int i = "yyyy-MM-ddTHH:mm:ss".length(); i < source.length(); i++) {
|
|
||||||
char c = source.charAt(i);
|
|
||||||
|
|
||||||
if (c == '.' && state == 0) {
|
|
||||||
state = 1;
|
|
||||||
} else if (c == '-' || c == '+' || c == 'Z') {
|
|
||||||
if (state > 0) {
|
|
||||||
b.append('.');
|
|
||||||
//support million seconds
|
|
||||||
for (int j = 0; j < precision; j++) {
|
|
||||||
b.append('S');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
b.append("XXX");
|
|
||||||
break;
|
|
||||||
} else if (state == 1) {
|
|
||||||
precision++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return b.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object clone() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
package com.docus.soap.api.util;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
|
||||||
import com.fasterxml.jackson.databind.AnnotationIntrospector;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.MapperFeature;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
|
|
||||||
import com.fasterxml.jackson.databind.type.TypeFactory;
|
|
||||||
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
|
|
||||||
|
|
||||||
public class ObjectMapperBuilder {
|
|
||||||
static final ObjectMapper DEFAULT_OBJECT_MAPPER;
|
|
||||||
|
|
||||||
static {
|
|
||||||
DEFAULT_OBJECT_MAPPER = createMapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ObjectMapper getObjectMapper() {
|
|
||||||
return DEFAULT_OBJECT_MAPPER;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ObjectMapper createMapper() {
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
mapper.setDateFormat(new JSONDateFormat());
|
|
||||||
AnnotationIntrospector primary = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
|
|
||||||
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
|
|
||||||
mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(primary, secondary));
|
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
||||||
mapper.configure(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME, true);
|
|
||||||
mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
|
|
||||||
return mapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean changed = false;
|
|
||||||
private ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
public ObjectMapperBuilder() {
|
|
||||||
this.objectMapper = DEFAULT_OBJECT_MAPPER;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ObjectMapper get() {
|
|
||||||
return objectMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ObjectMapperBuilder defaultObjectMapper() {
|
|
||||||
return new ObjectMapperBuilder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ObjectMapperBuilder rebirth() {
|
|
||||||
if (!changed && DEFAULT_OBJECT_MAPPER.equals(objectMapper)) {
|
|
||||||
objectMapper = createMapper();
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ObjectMapperBuilder indent() {
|
|
||||||
objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
|
|
||||||
changed = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
package com.docus.soap.api.util;
|
|
||||||
|
|
||||||
|
|
||||||
public final class RuntimeIOException extends RuntimeException {
|
|
||||||
public RuntimeIOException(Throwable cause) {
|
|
||||||
super(cause);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
package com.docus.soap.api.util;
|
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
|
|
||||||
public final class StringUtils {
|
|
||||||
private static final Pattern PATTERN_GUID = Pattern.compile("^[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}$");
|
|
||||||
private static final Pattern PATTERN_SAFE_STRING = Pattern.compile("^[.\\-,#&\\p{Alnum}\\p{Space}]*$");
|
|
||||||
|
|
||||||
public static boolean isGUID(String input) {
|
|
||||||
if (!StringUtils.hasText(input)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return PATTERN_GUID.matcher(input).matches();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int compare(String text1, String text2) {
|
|
||||||
if (text1 == null && text2 == null)
|
|
||||||
return 0;
|
|
||||||
if (text1 != null && text2 == null) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (text1 == null) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return text1.compareTo(text2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasText(String text) {
|
|
||||||
if (text == null)
|
|
||||||
return false;
|
|
||||||
for (int i = 0; i < text.length(); i++) {
|
|
||||||
if (!Character.isWhitespace(text.charAt(i)))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean equals(String text1, String text2) {
|
|
||||||
if (text1 == null)
|
|
||||||
return text2 == null;
|
|
||||||
|
|
||||||
return text1.equals(text2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String truncate(String text, int maxLength) {
|
|
||||||
if (text == null)
|
|
||||||
return null;
|
|
||||||
if (text.length() <= maxLength)
|
|
||||||
return text;
|
|
||||||
return text.substring(0, maxLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String trim(String text) {
|
|
||||||
if (text == null)
|
|
||||||
return null;
|
|
||||||
return text.trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isSafeString(String value) {
|
|
||||||
if (!StringUtils.hasText(value)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return PATTERN_SAFE_STRING.matcher(value).matches();
|
|
||||||
}
|
|
||||||
|
|
||||||
private StringUtils() {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
soap.complaint.api.url=http://101.132.67.155:8087/PKIQRCode/services/v1?wsdl
|
|
||||||
soap.complaint.api.action=SOF_GetQRCodeBySys
|
|
@ -0,0 +1,3 @@
|
|||||||
|
soap:
|
||||||
|
complaint.api.url: http://101.132.67.155:8087/PKIQRCode/services/v1?wsdl
|
||||||
|
complaint.api.action: SOF_GetQRCodeBySys
|
@ -1,85 +1,46 @@
|
|||||||
package com.docus.soap.api;
|
package com.docus.soap.api;
|
||||||
|
|
||||||
import com.docus.soap.api.request.zsyy.GetLoginInfoRequest;
|
import com.docus.core.util.AssertUtils;
|
||||||
import com.docus.soap.api.request.zsyy.GetQRCodeBySysRequest;
|
import com.docus.soap.api.request.complain.GetTableByIdDateRequest;
|
||||||
import com.docus.soap.api.request.zsyy.GetQueryQRCodeRequest;
|
import com.docus.soap.api.response.complain.ComplaintListResult;
|
||||||
import com.docus.soap.api.response.zsyy.GetLoginInfoResponse;
|
import com.docus.soap.api.service.ComplaintAPIService;
|
||||||
import com.docus.soap.api.response.zsyy.GetQRCodeBySysResponse;
|
|
||||||
import com.docus.soap.api.response.zsyy.GetQueryQRCodeResponse;
|
|
||||||
import com.docus.soap.api.service.XMZSYYQRCodeAPIService;
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
public class ComplaintAPIServiceTest extends SpringTest {
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest(classes = DocusSoapApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
|
public class ComplaintAPIServiceTest {
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(ComplaintAPIServiceTest.class);
|
private final Logger logger = LoggerFactory.getLogger(ComplaintAPIServiceTest.class);
|
||||||
|
|
||||||
@Inject
|
@Value("${soap.complaint.api.url}")
|
||||||
private Environment env;
|
public String soapComplaintUrl;
|
||||||
|
@Value("${soap.complaint.api.action}")
|
||||||
|
public String soapComplaintAction;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private XMZSYYQRCodeAPIService complaintAPIService;
|
private ComplaintAPIService complaintAPIService;
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void getTableByIdDateTest() {
|
public void getTableByIdDateTest() {
|
||||||
GetQRCodeBySysRequest request = new GetQRCodeBySysRequest();
|
GetTableByIdDateRequest request = new GetTableByIdDateRequest();
|
||||||
request.setSys("JSScan");
|
request.setSys("JSScan");
|
||||||
GetQRCodeBySysResponse result = complaintAPIService.getQRCodeBySys(request, getTableByIdDateSettings());
|
ComplaintListResult result = complaintAPIService.getTableByIdDate(request, getTableByIdDateSettings());
|
||||||
Assert.assertNotNull("not null", result);
|
AssertUtils.assertNotNull(result, "not null");
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Ignore
|
|
||||||
public void getQueryQRCode() {
|
|
||||||
GetQueryQRCodeRequest request = new GetQueryQRCodeRequest();
|
|
||||||
request.setQrCode("二维码状态查询字符串");
|
|
||||||
GetQueryQRCodeResponse queryQRCode = complaintAPIService.getQueryQRCode(request, queryQRCodeUrlAndName());
|
|
||||||
Assert.assertNotNull("not null", queryQRCode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getLoginInfo() {
|
|
||||||
GetLoginInfoRequest request = new GetLoginInfoRequest();
|
|
||||||
request.setSys("JSScan");
|
|
||||||
request.setAccountType("IdCardNumber");
|
|
||||||
request.setAccount("350301200008100057");
|
|
||||||
request.setPassword("lin123456");
|
|
||||||
GetLoginInfoResponse loginInfo = complaintAPIService.getLoginInfo(request, getLoginUserInfo());
|
|
||||||
Assert.assertNotNull("not null", loginInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private SoapAPISettings getTableByIdDateSettings() {
|
private SoapAPISettings getTableByIdDateSettings() {
|
||||||
SoapAPISettings soapAPISettings = new SoapAPISettings();
|
SoapAPISettings soapAPISettings = new SoapAPISettings();
|
||||||
soapAPISettings.setAction(env.getProperty("soap.complaint.api.action"));
|
soapAPISettings.setAction(soapComplaintAction);
|
||||||
soapAPISettings.setUri(env.getProperty("soap.complaint.api.url"));
|
soapAPISettings.setUri(soapComplaintUrl);
|
||||||
return soapAPISettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private SoapAPISettings queryQRCodeUrlAndName() {
|
|
||||||
SoapAPISettings soapAPISettings = new SoapAPISettings();
|
|
||||||
soapAPISettings.setAction("SOF_QueryQRCode");
|
|
||||||
soapAPISettings.setUri("http://101.132.67.155:8087/PKIQRCode/services/v1?wsdl");
|
|
||||||
return soapAPISettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private SoapAPISettings getLoginUserInfo() {
|
|
||||||
SoapAPISettings soapAPISettings = new SoapAPISettings();
|
|
||||||
soapAPISettings.setAction("SOF_LoginWithAccountInfo");
|
|
||||||
soapAPISettings.setUri("http://101.132.67.155:8087/pkis/services/v1?wsdl");
|
|
||||||
return soapAPISettings;
|
return soapAPISettings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
package com.docus.soap.api;
|
|
||||||
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
|
||||||
@ContextConfiguration(classes = {TestEnvironmentConfig.class}, initializers = SoapAppContextInitializer.class)
|
|
||||||
@ActiveProfiles("test")
|
|
||||||
@WebAppConfiguration
|
|
||||||
public abstract class SpringTest {
|
|
||||||
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
package com.docus.soap.api;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.context.annotation.Import;
|
|
||||||
import org.springframework.context.annotation.Profile;
|
|
||||||
|
|
||||||
@Profile("test")
|
|
||||||
@Configuration
|
|
||||||
@Import(SoapAPIConfig.class)
|
|
||||||
public class TestEnvironmentConfig {
|
|
||||||
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
soap.complaint.api.url=http://101.132.67.155:8087/PKIQRCode/services/v1?wsdl
|
|
||||||
soap.complaint.api.action=SOF_GetQRCodeBySys
|
|
@ -0,0 +1,3 @@
|
|||||||
|
soap:
|
||||||
|
complaint.api.url: http://101.132.67.155:8087/PKIQRCode/services/v1?wsdl
|
||||||
|
complaint.api.action: SOF_GetQRCodeBySys
|
Loading…
Reference in New Issue