You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
2.6 KiB
98 lines
2.6 KiB
package com.ynxbd.wx.wxfactory;
|
|
|
|
import com.ynxbd.common.result.JsonResult;
|
|
import lombok.*;
|
|
|
|
import java.io.Serializable;
|
|
|
|
public class WxFactory {
|
|
private static final String SUCCESS = "SUCCESS";
|
|
private static final String FAIL = "FAIL";
|
|
|
|
|
|
@NoArgsConstructor
|
|
public static class Base {
|
|
|
|
public static com.ynxbd.wx.wxfactory.base.auth.Client OAuth() {
|
|
return new com.ynxbd.wx.wxfactory.base.auth.Client();
|
|
}
|
|
}
|
|
|
|
// public static class Payment {
|
|
// public Payment() {
|
|
// }
|
|
//
|
|
// public static com.alipay.easysdk.payment.common.Client Common() throws Exception {
|
|
// return new com.alipay.easysdk.payment.common.Client(new Client(Factory.context));
|
|
// }
|
|
// }
|
|
|
|
// 医保
|
|
@NoArgsConstructor
|
|
public static class Medical {
|
|
public static com.ynxbd.wx.wxfactory.medical.Client Common() {
|
|
return new com.ynxbd.wx.wxfactory.medical.Client();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 响应数据
|
|
*/
|
|
@NoArgsConstructor
|
|
public static class ResponseCheck {
|
|
@Getter
|
|
@Setter
|
|
@ToString
|
|
@NoArgsConstructor
|
|
public static class ResultBase {
|
|
private String err_code;
|
|
|
|
private String err_code_des;
|
|
|
|
private String result_code;
|
|
|
|
public boolean isOk() {
|
|
return SUCCESS.equals(this.result_code);
|
|
}
|
|
|
|
public String getMessage() {
|
|
return this.err_code_des;
|
|
}
|
|
|
|
public <T extends ResultBase> T createResult(JsonResult jsonResult) {
|
|
if (jsonResult == null) {
|
|
return null;
|
|
}
|
|
return createResult(jsonResult.getMessage());
|
|
}
|
|
|
|
@SuppressWarnings({"unchecked"})
|
|
public <T extends ResultBase> T createResult(String message) {
|
|
try {
|
|
this.err_code_des = "[调用错误]" + message;
|
|
this.result_code = FAIL;
|
|
return (T) this;
|
|
} catch (Exception e) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
@Getter
|
|
@Setter
|
|
@ToString
|
|
@NoArgsConstructor
|
|
public static class ResultNoCode implements Serializable { // 自己修改值进行判断
|
|
private boolean success;
|
|
}
|
|
|
|
public static boolean success(ResultNoCode response) {
|
|
if (response == null) {
|
|
return false;
|
|
}
|
|
return response.isSuccess();
|
|
}
|
|
}
|
|
|
|
}
|
|
|