8 changed files with 563 additions and 0 deletions
@ -0,0 +1,63 @@ |
|||||
|
package com.epmet.wxapi.constant; |
||||
|
|
||||
|
/** |
||||
|
* @author zhaoqifeng |
||||
|
* @dscription |
||||
|
* @date 2020/8/18 13:59 |
||||
|
*/ |
||||
|
public interface WxMaSettingConstant { |
||||
|
/** |
||||
|
* 设置服务器域名 |
||||
|
*/ |
||||
|
String MODIFY_DOMAIN_URL = "https://api.weixin.qq.com/wxa/modify_domain"; |
||||
|
|
||||
|
/** |
||||
|
* 设置业务域名 |
||||
|
*/ |
||||
|
String SET_WEBVIEW_DOMAIN_URL = "https://api.weixin.qq.com/wxa/setwebviewdomain"; |
||||
|
|
||||
|
/** |
||||
|
* 设置名称 |
||||
|
*/ |
||||
|
String SET_NICK_NAME_URL = "https://api.weixin.qq.com/wxa/setnickname"; |
||||
|
|
||||
|
/** |
||||
|
* 获取可以设置的所有类目 |
||||
|
*/ |
||||
|
String GET_ALL_CATEGORIES_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/getallcategories"; |
||||
|
|
||||
|
/** |
||||
|
* 获取已设置的所有类目 |
||||
|
*/ |
||||
|
String GET_CATEGORY_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/getcategory"; |
||||
|
|
||||
|
/** |
||||
|
* 添加类目 |
||||
|
*/ |
||||
|
String ADD_CATEGORY_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/addcategory"; |
||||
|
|
||||
|
/** |
||||
|
* 删除类目 |
||||
|
*/ |
||||
|
String DELETE_CATEGORY_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/deletecategory"; |
||||
|
|
||||
|
/** |
||||
|
* 修改类目资质信息 |
||||
|
*/ |
||||
|
String MODIFY_CATEGORY_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/modifycategory"; |
||||
|
|
||||
|
/** |
||||
|
* 绑定微信用户为体验者 |
||||
|
*/ |
||||
|
String BIND_TESTER_URL = "https://api.weixin.qq.com/wxa/bind_tester"; |
||||
|
|
||||
|
/** |
||||
|
* 解除绑定体验者 |
||||
|
*/ |
||||
|
String UNBIND_TESTER_URL = "https://api.weixin.qq.com/wxa/unbind_tester"; |
||||
|
|
||||
|
/** |
||||
|
* 获取体验者列表 |
||||
|
*/ |
||||
|
String MEMBER_AUTH_URL = "https://api.weixin.qq.com/wxa/memberauth"; |
||||
|
} |
@ -0,0 +1,42 @@ |
|||||
|
package com.epmet.wxapi.param; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author zhaoqifeng |
||||
|
* @dscription |
||||
|
* @date 2020/8/18 15:14 |
||||
|
*/ |
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
public class WxAddCategoryReq implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = -3659216114599054052L; |
||||
|
|
||||
|
private List<CategoriesBean> categories; |
||||
|
|
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
public static class CategoriesBean { |
||||
|
/** |
||||
|
* |
||||
|
*/ |
||||
|
private int first; |
||||
|
private int second; |
||||
|
private List<CerticatesBean> certicates; |
||||
|
|
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
public static class CerticatesBean { |
||||
|
/** |
||||
|
* |
||||
|
*/ |
||||
|
private String key; |
||||
|
private String value; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package com.epmet.wxapi.param; |
||||
|
|
||||
|
import com.google.gson.annotations.SerializedName; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @author zhaoqifeng |
||||
|
* @dscription |
||||
|
* @date 2020/8/18 15:43 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class WxBindTesterReq implements Serializable { |
||||
|
private static final long serialVersionUID = -6509988898376682232L; |
||||
|
@SerializedName("wechatid") |
||||
|
private String weChatId; |
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
package com.epmet.wxapi.param; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @author zhaoqifeng |
||||
|
* @dscription |
||||
|
* @date 2020/8/18 15:22 |
||||
|
*/ |
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
public class WxDelCategoryReq implements Serializable { |
||||
|
private static final long serialVersionUID = 7179297618235954140L; |
||||
|
private Integer first; |
||||
|
private Integer second; |
||||
|
} |
@ -0,0 +1,41 @@ |
|||||
|
package com.epmet.wxapi.param; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author zhaoqifeng |
||||
|
* @dscription |
||||
|
* @date 2020/8/18 15:26 |
||||
|
*/ |
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
public class WxModifyCategoryReq implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = -428387175986769380L; |
||||
|
/** |
||||
|
* 一级类目 ID |
||||
|
*/ |
||||
|
private int first; |
||||
|
/** |
||||
|
* 二级类目 ID |
||||
|
*/ |
||||
|
private int second; |
||||
|
/** |
||||
|
* [资质信息]列表 |
||||
|
*/ |
||||
|
private List<CerticatesBean> certicates; |
||||
|
|
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
public static class CerticatesBean { |
||||
|
/** |
||||
|
* 资质图片 |
||||
|
*/ |
||||
|
private String key; |
||||
|
private String value; |
||||
|
} |
||||
|
} |
@ -0,0 +1,61 @@ |
|||||
|
package com.epmet.wxapi.result; |
||||
|
|
||||
|
import com.google.gson.annotations.SerializedName; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author zhaoqifeng |
||||
|
* @dscription |
||||
|
* @date 2020/8/18 14:53 |
||||
|
*/ |
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
public class WxGetAllCategoriesResult implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 4419968653961864521L; |
||||
|
/** |
||||
|
* errcode : 0 |
||||
|
*/ |
||||
|
@SerializedName("errcode") |
||||
|
private Integer errCode; |
||||
|
@SerializedName("errmsg") |
||||
|
private String errMsg; |
||||
|
@SerializedName("categories_list") |
||||
|
private CategoriesListBean categoriesList; |
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
public static class CategoriesListBean { |
||||
|
private List<CategoriesBean> categories; |
||||
|
|
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
public static class CategoriesBean { |
||||
|
/** |
||||
|
* id : 0 |
||||
|
*/ |
||||
|
private int id; |
||||
|
private QualifyBean qualify; |
||||
|
private String name; |
||||
|
private int level; |
||||
|
private int father; |
||||
|
@SerializedName("sensitive_type") |
||||
|
private int sensitiveType; |
||||
|
private List<Integer> children; |
||||
|
|
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
public static class QualifyBean { |
||||
|
/** |
||||
|
* exter_list : [] |
||||
|
*/ |
||||
|
private String remark; |
||||
|
@SerializedName("exter_list") |
||||
|
private List<?> exterList; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,112 @@ |
|||||
|
package com.epmet.wxapi.service; |
||||
|
|
||||
|
import com.epmet.wxapi.param.WxAddCategoryReq; |
||||
|
import com.epmet.wxapi.param.WxBindTesterReq; |
||||
|
import com.epmet.wxapi.param.WxDelCategoryReq; |
||||
|
import com.epmet.wxapi.param.WxModifyCategoryReq; |
||||
|
import com.epmet.wxapi.result.*; |
||||
|
|
||||
|
/** |
||||
|
* 小程序修改服务器地址、类目管理、成员管理 API(大部分只能是第三方平台调用) |
||||
|
* |
||||
|
* @author zhaoqifeng |
||||
|
* @date 2020/8/18 13:50 |
||||
|
*/ |
||||
|
public interface WxMaSettingService { |
||||
|
/** |
||||
|
* 设置服务器域名 |
||||
|
* |
||||
|
* @param accessToken |
||||
|
* @param action |
||||
|
* @return com.epmet.wxapi.result.WxResult |
||||
|
* @author zhaoqifeng |
||||
|
* @date 2020/7/16 17:21 |
||||
|
*/ |
||||
|
WxResult<WxMaModifyDomainResult> modifyDomain(String accessToken, String action); |
||||
|
|
||||
|
/** |
||||
|
* 设置业务域名 |
||||
|
* |
||||
|
* @param accessToken |
||||
|
* @param action |
||||
|
* @return com.epmet.wxapi.result.WxResult |
||||
|
* @author zhaoqifeng |
||||
|
* @date 2020/7/16 17:22 |
||||
|
*/ |
||||
|
WxResult<WxMaSetWebviewDomainResult> setWebviewDomain(String accessToken, String action); |
||||
|
|
||||
|
/** |
||||
|
* 获取可以设置的所有类目 |
||||
|
* |
||||
|
* @param accessToken |
||||
|
* @return com.epmet.wxapi.result.WxResult<com.epmet.wxapi.result.WxGetAllCategoriesResult> |
||||
|
* @author zhaoqifeng |
||||
|
* @date 2020/8/18 15:06 |
||||
|
*/ |
||||
|
WxResult<WxGetAllCategoriesResult> getAllCategories(String accessToken); |
||||
|
|
||||
|
/** |
||||
|
* 获取已设置的所有类目 |
||||
|
* |
||||
|
* @param accessToken |
||||
|
* @return com.epmet.wxapi.result.WxResult<com.epmet.wxapi.result.WxOpenGetCategoryResult> |
||||
|
* @author zhaoqifeng |
||||
|
* @date 2020/8/6 10:47 |
||||
|
*/ |
||||
|
WxResult<WxOpenGetCategoryResult> getCategory(String accessToken); |
||||
|
|
||||
|
/** |
||||
|
* 添加类目 |
||||
|
* |
||||
|
* @param accessToken |
||||
|
* @param request |
||||
|
* @return com.epmet.wxapi.result.WxResult |
||||
|
* @author zhaoqifeng |
||||
|
* @date 2020/8/18 15:20 |
||||
|
*/ |
||||
|
WxResult addCategory(String accessToken, WxAddCategoryReq request); |
||||
|
|
||||
|
/** |
||||
|
* 删除类目 |
||||
|
* |
||||
|
* @param accessToken |
||||
|
* @param request |
||||
|
* @return com.epmet.wxapi.result.WxResult |
||||
|
* @author zhaoqifeng |
||||
|
* @date 2020/8/18 15:20 |
||||
|
*/ |
||||
|
WxResult delCategory(String accessToken, WxDelCategoryReq request); |
||||
|
|
||||
|
/** |
||||
|
* 修改类目资质信息 |
||||
|
* |
||||
|
* @param accessToken |
||||
|
* @param request |
||||
|
* @return com.epmet.wxapi.result.WxResult |
||||
|
* @author zhaoqifeng |
||||
|
* @date 2020/8/18 15:20 |
||||
|
*/ |
||||
|
WxResult modifyCategory(String accessToken, WxModifyCategoryReq request); |
||||
|
|
||||
|
/** |
||||
|
* 绑定微信用户为体验者 |
||||
|
* |
||||
|
* @param accessToken |
||||
|
* @param request |
||||
|
* @return com.epmet.wxapi.result.WxResult<java.lang.String> |
||||
|
* @author zhaoqifeng |
||||
|
* @date 2020/8/18 15:45 |
||||
|
*/ |
||||
|
WxResult<String> bindTester(String accessToken, WxBindTesterReq request); |
||||
|
|
||||
|
/** |
||||
|
* 解除绑定体验者 |
||||
|
* |
||||
|
* @param accessToken |
||||
|
* @param request |
||||
|
* @return com.epmet.wxapi.result.WxResult<java.lang.String> |
||||
|
* @author zhaoqifeng |
||||
|
* @date 2020/8/18 15:45 |
||||
|
*/ |
||||
|
WxResult unBindTester(String accessToken, WxBindTesterReq request); |
||||
|
} |
@ -0,0 +1,207 @@ |
|||||
|
package com.epmet.wxapi.service.impl; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.epmet.commons.tools.constant.NumConstant; |
||||
|
import com.epmet.commons.tools.utils.HttpClientManager; |
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.wxapi.constant.WxMaSettingConstant; |
||||
|
import com.epmet.wxapi.enums.WxMaErrorMsgEnum; |
||||
|
import com.epmet.wxapi.param.*; |
||||
|
import com.epmet.wxapi.result.*; |
||||
|
import com.epmet.wxapi.service.WxMaSettingService; |
||||
|
import com.google.gson.Gson; |
||||
|
import com.google.gson.GsonBuilder; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
/** |
||||
|
* @author zhaoqifeng |
||||
|
* @dscription |
||||
|
* @date 2020/8/18 13:57 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class WxMaSettingServiceImpl implements WxMaSettingService { |
||||
|
private static final String ERR_CODE = "errcode"; |
||||
|
private static final String ERR_MSG = "errmsg"; |
||||
|
|
||||
|
@Autowired |
||||
|
private WxMaDomainDTO wxMaDomainDTO; |
||||
|
|
||||
|
@Override |
||||
|
public WxResult<WxMaModifyDomainResult> modifyDomain(String accessToken, String action) { |
||||
|
WxResult<WxMaModifyDomainResult> result = new WxResult<>(); |
||||
|
String url = WxMaSettingConstant.MODIFY_DOMAIN_URL + "?" + "access_token=" + accessToken; |
||||
|
WxMaModifyDomainReq request = new WxMaModifyDomainReq(); |
||||
|
request.setAction(action); |
||||
|
request.setRequestDomain(wxMaDomainDTO.getRequestDomain()); |
||||
|
request.setUploadDomain(wxMaDomainDTO.getUploadDomain()); |
||||
|
request.setWsRequestDomain(wxMaDomainDTO.getWsRequestDomain()); |
||||
|
request.setDownloadDomain(wxMaDomainDTO.getDownloadDomain()); |
||||
|
Result<String> modifyResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); |
||||
|
if (!modifyResult.success()) { |
||||
|
result.setErrorCode(modifyResult.getCode()); |
||||
|
result.setErrorMsg(modifyResult.getMsg()); |
||||
|
return result; |
||||
|
} |
||||
|
Gson gson = new Gson(); |
||||
|
WxMaModifyDomainResult domainResult = gson.fromJson(modifyResult.getData(), WxMaModifyDomainResult.class); |
||||
|
result.setErrorCode(domainResult.getErrcode()); |
||||
|
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(domainResult.getErrcode())); |
||||
|
result.setData(domainResult); |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public WxResult<WxMaSetWebviewDomainResult> setWebviewDomain(String accessToken, String action) { |
||||
|
WxResult<WxMaSetWebviewDomainResult> result = new WxResult<>(); |
||||
|
String url = WxMaSettingConstant.SET_WEBVIEW_DOMAIN_URL + "?" + "access_token=" + accessToken; |
||||
|
WxMaSetWebviewDomainReq request = new WxMaSetWebviewDomainReq(); |
||||
|
request.setAction(action); |
||||
|
request.setWebViewDomain(wxMaDomainDTO.getWebviewDomain()); |
||||
|
Result<String> modifyResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); |
||||
|
if (!modifyResult.success()) { |
||||
|
result.setErrorCode(modifyResult.getCode()); |
||||
|
result.setErrorMsg(modifyResult.getMsg()); |
||||
|
return result; |
||||
|
} |
||||
|
Gson gson = new Gson(); |
||||
|
WxMaSetWebviewDomainResult domainResult = gson.fromJson(modifyResult.getData(), WxMaSetWebviewDomainResult.class); |
||||
|
result.setErrorCode(domainResult.getErrcode()); |
||||
|
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(domainResult.getErrcode())); |
||||
|
result.setData(domainResult); |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public WxResult<WxGetAllCategoriesResult> getAllCategories(String accessToken) { |
||||
|
WxResult<WxGetAllCategoriesResult> result = new WxResult<>(); |
||||
|
String url = WxMaSettingConstant.GET_ALL_CATEGORIES_URL + "?" + "access_token=" + accessToken; |
||||
|
Result<String> modifyResult = HttpClientManager.getInstance().sendGet(url, null); |
||||
|
if (!modifyResult.success()) { |
||||
|
result.setErrorCode(modifyResult.getCode()); |
||||
|
result.setErrorMsg(modifyResult.getMsg()); |
||||
|
return result; |
||||
|
} |
||||
|
Gson gson = new Gson(); |
||||
|
WxGetAllCategoriesResult categoryResult = gson.fromJson(modifyResult.getData(), WxGetAllCategoriesResult.class); |
||||
|
if (categoryResult.getErrCode() != NumConstant.ZERO) { |
||||
|
result.setErrorCode(categoryResult.getErrCode()); |
||||
|
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(categoryResult.getErrCode())); |
||||
|
return result; |
||||
|
} |
||||
|
result.setErrorCode(categoryResult.getErrCode()); |
||||
|
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(categoryResult.getErrCode())); |
||||
|
result.setData(categoryResult); |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public WxResult<WxOpenGetCategoryResult> getCategory(String accessToken) { |
||||
|
WxResult<WxOpenGetCategoryResult> result = new WxResult<>(); |
||||
|
String url = WxMaSettingConstant.GET_CATEGORY_URL + "?" + "access_token=" + accessToken; |
||||
|
Result<String> statusResult = HttpClientManager.getInstance().sendGet(url, null); |
||||
|
if (!statusResult.success()) { |
||||
|
result.setErrorCode(statusResult.getCode()); |
||||
|
result.setErrorMsg(statusResult.getMsg()); |
||||
|
return result; |
||||
|
} |
||||
|
Gson gson = new Gson(); |
||||
|
WxOpenGetCategoryResult categoryResult = gson.fromJson(statusResult.getData(), WxOpenGetCategoryResult.class); |
||||
|
if (categoryResult.getErrcode() != NumConstant.ZERO) { |
||||
|
result.setErrorCode(categoryResult.getErrcode()); |
||||
|
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(categoryResult.getErrcode())); |
||||
|
return result; |
||||
|
} |
||||
|
result.ok(categoryResult); |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public WxResult addCategory(String accessToken, WxAddCategoryReq request) { |
||||
|
WxResult result = new WxResult(); |
||||
|
String url = WxMaSettingConstant.ADD_CATEGORY_URL + "?" + "access_token=" + accessToken; |
||||
|
Result<String> categoryResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); |
||||
|
if (!categoryResult.success()) { |
||||
|
result.setErrorCode(categoryResult.getCode()); |
||||
|
result.setErrorMsg(categoryResult.getMsg()); |
||||
|
return result; |
||||
|
} |
||||
|
JSONObject jsonObject = JSONObject.parseObject(categoryResult.getData()); |
||||
|
result.setErrorCode(jsonObject.getInteger(ERR_CODE)); |
||||
|
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE))); |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public WxResult delCategory(String accessToken, WxDelCategoryReq request) { |
||||
|
WxResult result = new WxResult(); |
||||
|
String url = WxMaSettingConstant.DELETE_CATEGORY_URL + "?" + "access_token=" + accessToken; |
||||
|
Result<String> categoryResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); |
||||
|
if (!categoryResult.success()) { |
||||
|
result.setErrorCode(categoryResult.getCode()); |
||||
|
result.setErrorMsg(categoryResult.getMsg()); |
||||
|
return result; |
||||
|
} |
||||
|
JSONObject jsonObject = JSONObject.parseObject(categoryResult.getData()); |
||||
|
result.setErrorCode(jsonObject.getInteger(ERR_CODE)); |
||||
|
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE))); |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public WxResult modifyCategory(String accessToken, WxModifyCategoryReq request) { |
||||
|
WxResult result = new WxResult(); |
||||
|
String url = WxMaSettingConstant.MODIFY_CATEGORY_URL + "?" + "access_token=" + accessToken; |
||||
|
Result<String> categoryResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); |
||||
|
if (!categoryResult.success()) { |
||||
|
result.setErrorCode(categoryResult.getCode()); |
||||
|
result.setErrorMsg(categoryResult.getMsg()); |
||||
|
return result; |
||||
|
} |
||||
|
JSONObject jsonObject = JSONObject.parseObject(categoryResult.getData()); |
||||
|
result.setErrorCode(jsonObject.getInteger(ERR_CODE)); |
||||
|
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE))); |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public WxResult<String> bindTester(String accessToken, WxBindTesterReq request) { |
||||
|
WxResult<String> result = new WxResult<>(); |
||||
|
String url = WxMaSettingConstant.BIND_TESTER_URL + "?" + "access_token=" + accessToken; |
||||
|
Result<String> testerResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); |
||||
|
if (!testerResult.success()) { |
||||
|
result.setErrorCode(testerResult.getCode()); |
||||
|
result.setErrorMsg(testerResult.getMsg()); |
||||
|
return result; |
||||
|
} |
||||
|
JSONObject jsonObject = JSONObject.parseObject(testerResult.getData()); |
||||
|
result.setErrorCode(jsonObject.getInteger(ERR_CODE)); |
||||
|
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE))); |
||||
|
result.setData(jsonObject.getString("userstr")); |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public WxResult unBindTester(String accessToken, WxBindTesterReq request) { |
||||
|
WxResult result = new WxResult(); |
||||
|
String url = WxMaSettingConstant.UNBIND_TESTER_URL + "?" + "access_token=" + accessToken; |
||||
|
Result<String> testerResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); |
||||
|
if (!testerResult.success()) { |
||||
|
result.setErrorCode(testerResult.getCode()); |
||||
|
result.setErrorMsg(testerResult.getMsg()); |
||||
|
return result; |
||||
|
} |
||||
|
JSONObject jsonObject = JSONObject.parseObject(testerResult.getData()); |
||||
|
result.setErrorCode(jsonObject.getInteger(ERR_CODE)); |
||||
|
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE))); |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
private String toJson(Object object) { |
||||
|
GsonBuilder gsonBuilder = new GsonBuilder(); |
||||
|
gsonBuilder.setPrettyPrinting(); |
||||
|
Gson gson = gsonBuilder.create(); |
||||
|
return gson.toJson(object); |
||||
|
} |
||||
|
|
||||
|
} |
Loading…
Reference in new issue