Sfoglia il codice sorgente

🎨 批量格式化部分代码

master
Binary Wang 5 anni fa
parent
commit
d638b20bf5
26 ha cambiato i file con 281 aggiunte e 366 eliminazioni
  1. +57
    -40
      weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenFastMaService.java
  2. +0
    -2
      weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaService.java
  3. +13
    -13
      weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java
  4. +71
    -174
      weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenFastMaServiceImpl.java
  5. +7
    -7
      weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInMemoryConfigStorage.java
  6. +1
    -1
      weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedisConfigStorage.java
  7. +2
    -2
      weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxOpenMaCategory.java
  8. +18
    -18
      weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java
  9. +22
    -22
      weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxFastMaAccountBasicInfoResult.java
  10. +12
    -12
      weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxFastMaBeenSetCategoryResult.java
  11. +19
    -15
      weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxFastMaCanSetCategoryResult.java
  12. +3
    -3
      weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxFastMaCheckNickameResult.java
  13. +6
    -6
      weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxFastMaQueryNicknameStatusResult.java
  14. +3
    -3
      weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxFastMaSetNickameResult.java
  15. +1
    -1
      weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerListResult.java
  16. +2
    -2
      weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaCategoryListResult.java
  17. +2
    -2
      weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaDomainResult.java
  18. +0
    -3
      weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaGrayReleasePlanResult.java
  19. +2
    -2
      weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaPageListResult.java
  20. +1
    -0
      weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaQueryAuditResult.java
  21. +13
    -13
      weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxFastMaAccountBasicInfoGsonAdapter.java
  22. +12
    -11
      weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerListResultGsonAdapter.java
  23. +2
    -2
      weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenGsonBuilder.java
  24. +6
    -6
      weixin-java-open/src/test/java/me/chanjar/weixin/open/bean/result/WxFastMaAccountBasicInfoResultTest.java
  25. +4
    -4
      weixin-java-open/src/test/java/me/chanjar/weixin/open/bean/result/WxFastMaBeenSetCategoryResultTest.java
  26. +2
    -2
      weixin-java-open/src/test/java/me/chanjar/weixin/open/bean/result/WxFastMaCanSetCategoryResultTest.java

+ 57
- 40
weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenFastMaService.java Vedi File

@@ -18,39 +18,38 @@ import java.util.List;
* @date 2019/01/23
*/
public interface WxOpenFastMaService extends WxMaService {

/**
* 1 获取帐号基本信息
* 1 获取帐号基本信息.
*/
String OPEN_GET_ACCOUNT_BASIC_INFO = "https://api.weixin.qq.com/cgi-bin/account/getaccountbasicinfo";

/**
* 2 小程序名称设置及改名
* 2 小程序名称设置及改名.
*/
String OPEN_SET_NICKNAME = "https://api.weixin.qq.com/wxa/setnickname";

/**
* 3 小程序改名审核状态查询
* 3 小程序改名审核状态查询.
*/
String OPEN_API_WXA_QUERYNICKNAME = "https://api.weixin.qq.com/wxa/api_wxa_querynickname";

/**
* 4 微信认证名称检测
* 4 微信认证名称检测.
*/
String OPEN_CHECK_WX_VERIFY_NICKNAME = "https://api.weixin.qq.com/cgi-bin/wxverify/checkwxverifynickname";

/**
* 5 修改头像
* 5 修改头像.
*/
String OPEN_MODIFY_HEADIMAGE = "https://api.weixin.qq.com/cgi-bin/account/modifyheadimage";

/**
* 6修改功能介绍
* 6修改功能介绍.
*/
String OPEN_MODIFY_SIGNATURE = "https://api.weixin.qq.com/cgi-bin/account/modifysignature";

/**
* 7 换绑小程序管理员接口
* 7 换绑小程序管理员接口.
*/
String OPEN_COMPONENT_REBIND_ADMIN = "https://api.weixin.qq.com/cgi-bin/account/componentrebindadmin";

@@ -79,37 +78,43 @@ public interface WxOpenFastMaService extends WxMaService {
/**
* 1.获取小程序的信息
*
* @return
* @throws WxErrorException
* @return .
* @throws WxErrorException .
*/
WxFastMaAccountBasicInfoResult getAccountBasicInfo() throws WxErrorException;

/**
* 2.小程序名称设置及改名
* <pre>
* <pre>
* 若接口未返回audit_id,说明名称已直接设置成功,无需审核;若返回audit_id则名称正在审核中。
* </pre>
* @param nickname 昵称
* @param idCard 身份证照片–临时素材mediaid(个人号必填)
* @param license 组织机构代码证或营业执照–临时素材mediaid(组织号必填)
*
* @param nickname 昵称
* @param idCard 身份证照片–临时素材mediaid(个人号必填)
* @param license 组织机构代码证或营业执照–临时素材mediaid(组织号必填)
* @param namingOtherStuff1 其他证明材料---临时素材 mediaid
* @param namingOtherStuff2 其他证明材料---临时素材 mediaid
* @throws WxErrorException
* @return .
* @throws WxErrorException .
*/
WxFastMaSetNickameResult setNickname(String nickname, String idCard, String license, String namingOtherStuff1, String namingOtherStuff2) throws WxErrorException;
WxFastMaSetNickameResult setNickname(String nickname, String idCard, String license, String namingOtherStuff1,
String namingOtherStuff2) throws WxErrorException;

/**
* 3 小程序改名审核状态查询
*
* @param auditId 审核单id
* @return
* @throws WxErrorException
* @return .
* @throws WxErrorException .
*/
WxFastMaQueryNicknameStatusResult querySetNicknameStatus(String auditId) throws WxErrorException;

/**
* 4. 微信认证名称检测
*
* @param nickname 名称
* @throws WxErrorException
* @return .
* @throws WxErrorException .
*/
WxFastMaCheckNickameResult checkWxVerifyNickname(String nickname) throws WxErrorException;

@@ -119,29 +124,34 @@ public interface WxOpenFastMaService extends WxMaService {
* 图片格式只支持:BMP、JPEG、JPG、GIF、PNG,大小不超过2M
* 注:实际头像始终为正方形
* </pre>
*
* @param headImgMediaId 头像素材media_id
* @param x1 裁剪框左上角x坐标(取值范围:[0, 1])
* @param y1 裁剪框左上角y坐标(取值范围:[0, 1])
* @param x2 裁剪框右下角x坐标(取值范围:[0, 1])
* @param y2 裁剪框右下角y坐标(取值范围:[0, 1])
* @throws WxErrorException
* @param x1 裁剪框左上角x坐标(取值范围:[0, 1])
* @param y1 裁剪框左上角y坐标(取值范围:[0, 1])
* @param x2 裁剪框右下角x坐标(取值范围:[0, 1])
* @param y2 裁剪框右下角y坐标(取值范围:[0, 1])
* @return .
* @throws WxErrorException .
*/
WxOpenResult modifyHeadImage(String headImgMediaId, float x1, float y1, float x2, float y2) throws WxErrorException;

/**
* 6.修改功能介绍
*
* @param signature 简介:4-120字
* @throws WxErrorException
* @return .
* @throws WxErrorException .
*/
WxOpenResult modifySignature(String signature) throws WxErrorException;

/**
* 7.3 管理员换绑
* @param taskid 换绑管理员任务序列号(公众平台最终点击提交回跳到第三方平台时携带)
* @return
* @throws WxErrorException
*
* @param taskId 换绑管理员任务序列号(公众平台最终点击提交回跳到第三方平台时携带)
* @return .
* @throws WxErrorException .
*/
WxOpenResult componentRebindAdmin(String taskid) throws WxErrorException;
WxOpenResult componentRebindAdmin(String taskId) throws WxErrorException;

/**
* 8.1 获取账号可以设置的所有类目
@@ -150,38 +160,45 @@ public interface WxOpenFastMaService extends WxMaService {
* 目前没有完整的类目信息数据
* 为保证兼容性,放弃将response转换为实体
* </pre>
* @return
*
* @return .
* @throws WxErrorException .
*/
String getAllCategories() throws WxErrorException;

/**
*8.2添加类目
* @return
* @throws WxErrorException
* 8.2添加类目
*
* @param categoryList 类目列表
* @return .
* @throws WxErrorException .
*/
WxOpenResult addCategory(List<WxFastMaCategory> categoryList) throws WxErrorException;

/**
* 8.3删除类目
* @param first 一级类目ID
*
* @param first 一级类目ID
* @param second 二级类目ID
* @return
* @throws WxErrorException
* @return .
* @throws WxErrorException .
*/
WxOpenResult deleteCategory(int first, int second) throws WxErrorException;

/**
* 8.4获取账号已经设置的所有类目
* @return
* @throws WxErrorException
*
* @return .
* @throws WxErrorException .
*/
WxFastMaBeenSetCategoryResult getCategory() throws WxErrorException;

/**
* 8.5修改类目
*
* @param category 实体
* @return
* @throws WxErrorException
* @return .
* @throws WxErrorException .
*/
WxOpenResult modifyCategory(WxFastMaCategory category) throws WxErrorException;
}

+ 0
- 2
weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaService.java Vedi File

@@ -98,7 +98,6 @@ public interface WxOpenMaService extends WxMaService {
String API_UPDATE_SHOW_WXA_ITEM = "https://api.weixin.qq.com/wxa/updateshowwxaitem";



/**
* 以下接口为三方平台代小程序实现的代码管理功能
* <p>
@@ -268,7 +267,6 @@ public interface WxOpenMaService extends WxMaService {
WxOpenMaTesterListResult getTesterList() throws WxErrorException;



/**
* 设置小程序隐私设置(是否可被搜索)
*


+ 13
- 13
weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java Vedi File

@@ -265,8 +265,8 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
return "success";
}
//快速创建小程序
if (StringUtils.equalsIgnoreCase(wxMessage.getInfoType(), "notify_third_fasteregister") && wxMessage.getStatus () == 0) {
WxOpenQueryAuthResult queryAuth = wxOpenService.getWxOpenComponentService().getQueryAuth(wxMessage.getAuthCode ());
if (StringUtils.equalsIgnoreCase(wxMessage.getInfoType(), "notify_third_fasteregister") && wxMessage.getStatus() == 0) {
WxOpenQueryAuthResult queryAuth = wxOpenService.getWxOpenComponentService().getQueryAuth(wxMessage.getAuthCode());
if (queryAuth == null || queryAuth.getAuthorizationInfo() == null || queryAuth.getAuthorizationInfo().getAuthorizerAppid() == null) {
throw new NullPointerException("getQueryAuth");
}
@@ -318,11 +318,11 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
jsonObject.addProperty("count", len);
String responseContent = post(url, jsonObject.toString());
WxOpenAuthorizerListResult ret = WxOpenGsonBuilder.create().fromJson(responseContent, WxOpenAuthorizerListResult.class);
if(ret != null && ret.getList() != null){
for(Map<String, String> data : ret.getList()){
if (ret != null && ret.getList() != null) {
for (Map<String, String> data : ret.getList()) {
String authorizerAppid = data.get("authorizer_appid");
String refreshToken = data.get("refresh_token");
if(authorizerAppid != null && refreshToken != null){
if (authorizerAppid != null && refreshToken != null) {
this.getWxOpenConfigStorage().setAuthorizerRefreshToken(authorizerAppid, refreshToken);
}
}
@@ -451,25 +451,25 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
}

@Override
public WxOpenResult fastRegisterWeapp(String name, String code, String codeType, String legalPersonaWechat, String legalPersonaName, String componentPhone) throws WxErrorException{
public WxOpenResult fastRegisterWeapp(String name, String code, String codeType, String legalPersonaWechat, String legalPersonaName, String componentPhone) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("name",name);
jsonObject.addProperty("name", name);
jsonObject.addProperty("code", code);
jsonObject.addProperty("code_type", codeType);
jsonObject.addProperty("legal_persona_wechat", legalPersonaWechat);
jsonObject.addProperty("legal_persona_name", legalPersonaName);
jsonObject.addProperty("component_phone", componentPhone);
String response = post(FAST_REGISTER_WEAPP_URL, jsonObject.toString (), "component_access_token");
return WxOpenGsonBuilder.create ().fromJson (response, WxOpenResult.class);
String response = post(FAST_REGISTER_WEAPP_URL, jsonObject.toString(), "component_access_token");
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}

@Override
public WxOpenResult fastRegisterWeappSearch(String name, String legalPersonaWechat, String legalPersonaName) throws WxErrorException{
public WxOpenResult fastRegisterWeappSearch(String name, String legalPersonaWechat, String legalPersonaName) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("name",name);
jsonObject.addProperty("name", name);
jsonObject.addProperty("legal_persona_wechat", legalPersonaWechat);
jsonObject.addProperty("legal_persona_name", legalPersonaName);
String response = post(FAST_REGISTER_WEAPP_SEARCH_URL, jsonObject.toString (), "component_access_token");
return WxOpenGsonBuilder.create ().fromJson (response, WxOpenResult.class);
String response = post(FAST_REGISTER_WEAPP_SEARCH_URL, jsonObject.toString(), "component_access_token");
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
}

+ 71
- 174
weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenFastMaServiceImpl.java Vedi File

@@ -18,237 +18,134 @@ import java.util.List;
import java.util.Map;

/**
* .
*
* @author Hipple
* @description
* @since 2019/1/23 15:27
*/
public class WxOpenFastMaServiceImpl extends WxMaServiceImpl implements WxOpenFastMaService {

protected final Logger log = LoggerFactory.getLogger (this.getClass ());

private WxOpenComponentService wxOpenComponentService;
private WxMaConfig wxMaConfig;
private String appId;

public WxOpenFastMaServiceImpl (WxOpenComponentService wxOpenComponentService, String appId, WxMaConfig wxMaConfig) {
public WxOpenFastMaServiceImpl(WxOpenComponentService wxOpenComponentService, String appId, WxMaConfig wxMaConfig) {
this.wxOpenComponentService = wxOpenComponentService;
this.appId = appId;
this.wxMaConfig = wxMaConfig;
initHttp ();
initHttp();
}

@Override
public WxMaConfig getWxMaConfig () {
public WxMaConfig getWxMaConfig() {
return wxMaConfig;
}

@Override
public String getAccessToken (boolean forceRefresh) throws WxErrorException {
return wxOpenComponentService.getAuthorizerAccessToken (appId, forceRefresh);
public String getAccessToken(boolean forceRefresh) throws WxErrorException {
return wxOpenComponentService.getAuthorizerAccessToken(appId, forceRefresh);
}

/**
* 1.获取小程序的信息,GET请求
* <pre>
* 注意:这里不能直接用小程序的access_token
* </pre>
*
* @return
* @throws WxErrorException
*/
@Override
public WxFastMaAccountBasicInfoResult getAccountBasicInfo () throws WxErrorException {
String response = get (OPEN_GET_ACCOUNT_BASIC_INFO, "");
return WxOpenGsonBuilder.create ().fromJson (response, WxFastMaAccountBasicInfoResult.class);
public WxFastMaAccountBasicInfoResult getAccountBasicInfo() throws WxErrorException {
String response = get(OPEN_GET_ACCOUNT_BASIC_INFO, "");
return WxOpenGsonBuilder.create().fromJson(response, WxFastMaAccountBasicInfoResult.class);
}

/**
* 2.小程序名称设置及改名
*
* @param nickname 昵称
* @param idCard 身份证照片–临时素材mediaid(个人号必填)
* @param license 组织机构代码证或营业执照–临时素材mediaid(组织号必填)
* @param namingOtherStuff1 其他证明材料---临时素材 mediaid
* @param namingOtherStuff2 其他证明材料---临时素材 mediaid
* @throws WxErrorException
*/
@Override
public WxFastMaSetNickameResult setNickname (String nickname, String idCard, String license, String namingOtherStuff1, String namingOtherStuff2) throws WxErrorException {
JsonObject params = new JsonObject ();
params.addProperty ("nick_name", nickname);
params.addProperty ("id_card", idCard);
params.addProperty ("license", license);
params.addProperty ("naming_other_stuff_1", namingOtherStuff1);
params.addProperty ("naming_other_stuff_2", namingOtherStuff2);
String response = post (OPEN_SET_NICKNAME, GSON.toJson (params));
return WxOpenGsonBuilder.create ().fromJson (response, WxFastMaSetNickameResult.class);
public WxFastMaSetNickameResult setNickname(String nickname, String idCard, String license, String namingOtherStuff1, String namingOtherStuff2) throws WxErrorException {
JsonObject params = new JsonObject();
params.addProperty("nick_name", nickname);
params.addProperty("id_card", idCard);
params.addProperty("license", license);
params.addProperty("naming_other_stuff_1", namingOtherStuff1);
params.addProperty("naming_other_stuff_2", namingOtherStuff2);
String response = post(OPEN_SET_NICKNAME, GSON.toJson(params));
return WxOpenGsonBuilder.create().fromJson(response, WxFastMaSetNickameResult.class);
}

/**
* 3 小程序改名审核状态查询
*
* @param auditId 审核单id
* @return
* @throws WxErrorException
*/
@Override
public WxFastMaQueryNicknameStatusResult querySetNicknameStatus (String auditId) throws WxErrorException {
JsonObject params = new JsonObject ();
params.addProperty ("audit_id", auditId);
String response = post (OPEN_API_WXA_QUERYNICKNAME, GSON.toJson (params));
return WxOpenGsonBuilder.create ().fromJson (response, WxFastMaQueryNicknameStatusResult.class);
public WxFastMaQueryNicknameStatusResult querySetNicknameStatus(String auditId) throws WxErrorException {
JsonObject params = new JsonObject();
params.addProperty("audit_id", auditId);
String response = post(OPEN_API_WXA_QUERYNICKNAME, GSON.toJson(params));
return WxOpenGsonBuilder.create().fromJson(response, WxFastMaQueryNicknameStatusResult.class);
}

/**
* 4. 微信认证名称检测
* <pre>
* 命中关键字策略时返回命中关键字的说明描述
* </pre>
*
* @param nickname 名称
* @throws WxErrorException
*/
@Override
public WxFastMaCheckNickameResult checkWxVerifyNickname (String nickname) throws WxErrorException {
JsonObject params = new JsonObject ();
params.addProperty ("nick_name", nickname);
String response = post (OPEN_CHECK_WX_VERIFY_NICKNAME, GSON.toJson (params));
return WxOpenGsonBuilder.create ().fromJson (response, WxFastMaCheckNickameResult.class);
public WxFastMaCheckNickameResult checkWxVerifyNickname(String nickname) throws WxErrorException {
JsonObject params = new JsonObject();
params.addProperty("nick_name", nickname);
String response = post(OPEN_CHECK_WX_VERIFY_NICKNAME, GSON.toJson(params));
return WxOpenGsonBuilder.create().fromJson(response, WxFastMaCheckNickameResult.class);
}

/**
* 5.修改头像
* <pre>
* 图片格式只支持:BMP、JPEG、JPG、GIF、PNG,大小不超过2M
* 注:实际头像始终为正方形
* </pre>
*
* @param headImgMediaId 头像素材media_id
* @param x1 裁剪框左上角x坐标(取值范围:[0, 1])
* @param y1 裁剪框左上角y坐标(取值范围:[0, 1])
* @param x2 裁剪框右下角x坐标(取值范围:[0, 1])
* @param y2 裁剪框右下角y坐标(取值范围:[0, 1])
* @throws WxErrorException
*/
@Override
public WxOpenResult modifyHeadImage (String headImgMediaId, float x1, float y1, float x2, float y2) throws WxErrorException {
JsonObject params = new JsonObject ();
params.addProperty ("head_img_media_id", headImgMediaId);
params.addProperty ("x1", x1);
params.addProperty ("y1", y1);
params.addProperty ("x2", x2);
params.addProperty ("y2", y2);
String response = post (OPEN_MODIFY_HEADIMAGE, GSON.toJson (params));
return WxOpenGsonBuilder.create ().fromJson (response, WxOpenResult.class);
public WxOpenResult modifyHeadImage(String headImgMediaId, float x1, float y1, float x2, float y2) throws WxErrorException {
JsonObject params = new JsonObject();
params.addProperty("head_img_media_id", headImgMediaId);
params.addProperty("x1", x1);
params.addProperty("y1", y1);
params.addProperty("x2", x2);
params.addProperty("y2", y2);
String response = post(OPEN_MODIFY_HEADIMAGE, GSON.toJson(params));
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}

/**
* 6.修改功能介绍
*
* @param signature 简介:4-120字
* @throws WxErrorException
*/
@Override
public WxOpenResult modifySignature (String signature) throws WxErrorException {
JsonObject params = new JsonObject ();
params.addProperty ("signature", signature);
String response = post (OPEN_MODIFY_SIGNATURE, GSON.toJson (params));
return WxOpenGsonBuilder.create ().fromJson (response, WxOpenResult.class);
public WxOpenResult modifySignature(String signature) throws WxErrorException {
JsonObject params = new JsonObject();
params.addProperty("signature", signature);
String response = post(OPEN_MODIFY_SIGNATURE, GSON.toJson(params));
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}

/**
* 7.3 管理员换绑
*
* @param taskid 换绑管理员任务序列号(公众平台最终点击提交回跳到第三方平台时携带)
* @return
* @throws WxErrorException
*/
@Override
public WxOpenResult componentRebindAdmin (String taskid) throws WxErrorException {
JsonObject params = new JsonObject ();
params.addProperty ("taskid", taskid);
String response = post (OPEN_COMPONENT_REBIND_ADMIN, GSON.toJson (params));
return WxOpenGsonBuilder.create ().fromJson (response, WxOpenResult.class);
public WxOpenResult componentRebindAdmin(String taskid) throws WxErrorException {
JsonObject params = new JsonObject();
params.addProperty("taskid", taskid);
String response = post(OPEN_COMPONENT_REBIND_ADMIN, GSON.toJson(params));
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}

/**
* 8.1 获取账号可以设置的所有类目
*
* @return
*/
@Override
public String getAllCategories () throws WxErrorException {
return get (OPEN_GET_ALL_CATEGORIES, "");
public String getAllCategories() throws WxErrorException {
return get(OPEN_GET_ALL_CATEGORIES, "");
}

/**
* 8.2添加类目
*
* @param categoryList
* @return
* @throws WxErrorException
*/
@Override
public WxOpenResult addCategory (List<WxFastMaCategory> categoryList) throws WxErrorException {
Map<String, Object> map = new HashMap<> ();
map.put ("categories", categoryList);
String response = post (OPEN_ADD_CATEGORY, WxOpenGsonBuilder.create ().toJson (map));
return WxOpenGsonBuilder.create ().fromJson (response, WxOpenResult.class);
public WxOpenResult addCategory(List<WxFastMaCategory> categoryList) throws WxErrorException {
Map<String, Object> map = new HashMap<>();
map.put("categories", categoryList);
String response = post(OPEN_ADD_CATEGORY, WxOpenGsonBuilder.create().toJson(map));
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}

/**
* 8.3删除类目
*
* @param first 一级类目ID
* @param second 二级类目ID
* @return
* @throws WxErrorException
*/
@Override
public WxOpenResult deleteCategory (int first, int second) throws WxErrorException {
JsonObject params = new JsonObject ();
params.addProperty ("first", first);
params.addProperty ("second", second);
String response = post (OPEN_DELETE_CATEGORY, GSON.toJson (params));
return WxOpenGsonBuilder.create ().fromJson (response, WxOpenResult.class);
public WxOpenResult deleteCategory(int first, int second) throws WxErrorException {
JsonObject params = new JsonObject();
params.addProperty("first", first);
params.addProperty("second", second);
String response = post(OPEN_DELETE_CATEGORY, GSON.toJson(params));
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}

/**
* 8.4获取账号已经设置的所有类目
*
* @return
* @throws WxErrorException
*/
@Override
public WxFastMaBeenSetCategoryResult getCategory () throws WxErrorException {
String response = get (OPEN_GET_CATEGORY, "");
return WxOpenGsonBuilder.create ().fromJson (response, WxFastMaBeenSetCategoryResult.class);
public WxFastMaBeenSetCategoryResult getCategory() throws WxErrorException {
String response = get(OPEN_GET_CATEGORY, "");
return WxOpenGsonBuilder.create().fromJson(response, WxFastMaBeenSetCategoryResult.class);
}

/**
* 8.5修改类目
*
* @param category 实体
* @return
* @throws WxErrorException
*/
@Override
public WxOpenResult modifyCategory (WxFastMaCategory category) throws WxErrorException {
String response = post (OPEN_MODIFY_CATEGORY, GSON.toJson (category));
return WxOpenGsonBuilder.create ().fromJson (response, WxOpenResult.class);
public WxOpenResult modifyCategory(WxFastMaCategory category) throws WxErrorException {
String response = post(OPEN_MODIFY_CATEGORY, GSON.toJson(category));
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}

/**
* 将字符串对象转化为GsonArray对象
*
* @param strList
* @return
*/
private JsonArray toJsonArray (List<String> strList) {
JsonArray jsonArray = new JsonArray ();
if (strList != null && ! strList.isEmpty ()) {
private JsonArray toJsonArray(List<String> strList) {
JsonArray jsonArray = new JsonArray();
if (strList != null && !strList.isEmpty()) {
for (String str : strList) {
jsonArray.add (str);
jsonArray.add(str);
}
}
return jsonArray;


+ 7
- 7
weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInMemoryConfigStorage.java Vedi File

@@ -1,23 +1,23 @@
package me.chanjar.weixin.open.api.impl;


import java.io.File;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import cn.binarywang.wx.miniapp.config.WxMaConfig;
import me.chanjar.weixin.common.bean.WxAccessToken;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.bean.WxMpHostConfig;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.enums.TicketType;
import me.chanjar.weixin.open.api.WxOpenConfigStorage;
import me.chanjar.weixin.open.bean.WxOpenAuthorizerAccessToken;
import me.chanjar.weixin.open.bean.WxOpenComponentAccessToken;
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;

import java.io.File;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
* 基于内存的微信配置provider,在实际生产环境中应该将这些配置持久化
*


+ 1
- 1
weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedisConfigStorage.java Vedi File

@@ -84,7 +84,7 @@ public class WxOpenInRedisConfigStorage extends WxOpenInMemoryConfigStorage {
}

@Override
public void expireComponentAccessToken(){
public void expireComponentAccessToken() {
try (Jedis jedis = this.jedisPool.getResource()) {
jedis.expire(this.componentAccessTokenKey, 0);
}


+ 2
- 2
weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxOpenMaCategory.java Vedi File

@@ -1,11 +1,11 @@
package me.chanjar.weixin.open.bean.ma;

import java.io.Serializable;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;

import java.io.Serializable;

/**
* 微信小程序分类目录.
*


+ 18
- 18
weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java Vedi File

@@ -58,48 +58,48 @@ public class WxOpenXmlMessage implements Serializable {

// 以下为快速创建小程序接口推送的的信息

@XStreamAlias ("appid")
@XStreamAlias("appid")
private String registAppId;

@XStreamAlias ("status")
@XStreamAlias("status")
private int status;

@XStreamAlias ("auth_code")
@XStreamAlias("auth_code")
private String authCode;

@XStreamAlias ("msg")
@XStreamConverter (value = XStreamCDataConverter.class)
@XStreamAlias("msg")
@XStreamConverter(value = XStreamCDataConverter.class)
private String msg;

@XStreamAlias ("info")
@XStreamAlias("info")
private Info info = new Info();

@XStreamAlias ("info")
@XStreamAlias("info")
@Data
public static class Info implements Serializable {
private static final long serialVersionUID = 7706235740094081194L;

@XStreamAlias ("name")
@XStreamConverter (value = XStreamCDataConverter.class)
@XStreamAlias("name")
@XStreamConverter(value = XStreamCDataConverter.class)
private String name;

@XStreamAlias ("code")
@XStreamConverter (value = XStreamCDataConverter.class)
@XStreamAlias("code")
@XStreamConverter(value = XStreamCDataConverter.class)
private String code;

@XStreamAlias ("code_type")
@XStreamAlias("code_type")
private int codeType;

@XStreamAlias ("legal_persona_wechat")
@XStreamConverter (value = XStreamCDataConverter.class)
@XStreamAlias("legal_persona_wechat")
@XStreamConverter(value = XStreamCDataConverter.class)
private String legalPersonaWechat;

@XStreamAlias ("legal_persona_name")
@XStreamConverter (value = XStreamCDataConverter.class)
@XStreamAlias("legal_persona_name")
@XStreamConverter(value = XStreamCDataConverter.class)
private String legalPersonaName;

@XStreamAlias ("component_phone")
@XStreamConverter (value = XStreamCDataConverter.class)
@XStreamAlias("component_phone")
@XStreamConverter(value = XStreamCDataConverter.class)
private String componentPhone;
}



+ 22
- 22
weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxFastMaAccountBasicInfoResult.java Vedi File

@@ -10,55 +10,55 @@ import lombok.EqualsAndHashCode;
* @since 2019/1/23 14:39
*/
@Data
@EqualsAndHashCode (callSuper = true)
public class WxFastMaAccountBasicInfoResult extends WxOpenResult{
private static final long serialVersionUID = - 8713680081353954208L;
@EqualsAndHashCode(callSuper = true)
public class WxFastMaAccountBasicInfoResult extends WxOpenResult {
private static final long serialVersionUID = -8713680081353954208L;

/**
* 小程序ID
*/
@SerializedName ("appid")
@SerializedName("appid")
private String appId;

/**
* 帐号类型(1:订阅号,2:服务号,3:小程序)
*/
@SerializedName ("account_type")
@SerializedName("account_type")
private Integer accountType;

/**
* 主体类型(1:企业)
*/
@SerializedName ("principal_type")
@SerializedName("principal_type")
private Integer principalType;

/**
* 主体名称
*/
@SerializedName ("principal_name")
@SerializedName("principal_name")
private String principalName;

/**
* 实名验证状态(1:实名验证成功,2:实名验证中,3:实名验证失败)调用接口1.1创建帐号时,realname_status会初始化为2对于注册方式为微信认证的帐号,资质认证成功时,realname_status会更新为1 注意!!!当realname_status不为1时,帐号只允许调用本文档内的以下API:(即无权限调用其他API) 微信认证相关接口(参考2.x) 帐号设置相关接口(参考3.x)
*/
@SerializedName ("realname_status")
@SerializedName("realname_status")
private Integer realnameStatus;


/**
* 微信认证信息
*/
@SerializedName ("wx_verify_info")
@SerializedName("wx_verify_info")
private WxVerifyInfo wxVerifyInfo;
/**
* 功能介绍信息
*/
@SerializedName ("signature_info")
@SerializedName("signature_info")
private SignatureInfo signatureInfo;
/**
* 头像信息
*/
@SerializedName ("head_image_info")
@SerializedName("head_image_info")
private HeadImageInfo headImageInfo;

@Data
@@ -66,29 +66,29 @@ public class WxFastMaAccountBasicInfoResult extends WxOpenResult{
/**
* 是否资质认证(true:是,false:否)若是,拥有微信认证相关的权限
*/
@SerializedName ("qualification_verify")
@SerializedName("qualification_verify")
private Boolean qualificationVerify;
/**
* 是否名称认证(true:是,false:否)对于公众号(订阅号、服务号),是名称认证,微信客户端才会有微信认证打勾的标识。
*/
@SerializedName ("naming_verify")
@SerializedName("naming_verify")
private Boolean namingVerify;
/**
* 是否需要年审(true:是,false:否)(qualification_verify = true时才有该字段)
*/
@SerializedName ("annual_review")
@SerializedName("annual_review")
private Boolean annualReview;

/**
* 年审开始时间,时间戳(qualification_verify = true时才有该字段)
*/
@SerializedName ("annual_review_begin_time")
@SerializedName("annual_review_begin_time")
private String annualReviewBeginTime;

/**
* 年审截止时间,时间戳(qualification_verify = true时才有该字段)
*/
@SerializedName ("annual_review_end_time")
@SerializedName("annual_review_end_time")
private String annualReviewEndTime;
}

@@ -98,17 +98,17 @@ public class WxFastMaAccountBasicInfoResult extends WxOpenResult{
/**
* 功能介绍
*/
@SerializedName ("signature")
@SerializedName("signature")
private String signature;
/**
* 头像已使用修改次数(本月)
*/
@SerializedName ("modify_used_count")
@SerializedName("modify_used_count")
private Integer modifyUsedCount;
/**
* 头像修改次数总额度(本月)
*/
@SerializedName ("modify_quota")
@SerializedName("modify_quota")
private Integer modifyQuota;
}

@@ -118,18 +118,18 @@ public class WxFastMaAccountBasicInfoResult extends WxOpenResult{
/**
* 头像url
*/
@SerializedName ("head_image_url")
@SerializedName("head_image_url")
private String headImageUrl;
/**
* 头像已使用修改次数(本月)
*/
@SerializedName ("modify_used_count")
@SerializedName("modify_used_count")
private Integer modifyUsedCount;

/**
* 头像修改次数总额度(本月)
*/
@SerializedName ("modify_quota")
@SerializedName("modify_quota")
private Integer modifyQuota;
}
}

+ 12
- 12
weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxFastMaBeenSetCategoryResult.java Vedi File

@@ -12,29 +12,29 @@ import java.util.List;
* @since 2019/1/26 18:27
*/
@Data
@EqualsAndHashCode (callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class WxFastMaBeenSetCategoryResult extends WxOpenResult {
private static final long serialVersionUID = - 7662344448437700644L;
private static final long serialVersionUID = -7662344448437700644L;

/**
* 一个更改周期内可以设置类目的次数
*/
@SerializedName ("limit")
@SerializedName("limit")
private int limit;
/**
* 本更改周期内还可以设置类目的次数
*/
@SerializedName ("quota")
@SerializedName("quota")
private int quota;
/**
* 最多可以设置的类目数量
*/
@SerializedName ("category_limit")
@SerializedName("category_limit")
private int categoryLimit;
/**
* 类目
*/
@SerializedName ("categories")
@SerializedName("categories")
private List<CategoriesBean> categories;

@Data
@@ -42,32 +42,32 @@ public class WxFastMaBeenSetCategoryResult extends WxOpenResult {
/**
* 一级类目ID
*/
@SerializedName ("first")
@SerializedName("first")
private int first;
/**
* 一级类目名称
*/
@SerializedName ("first_name")
@SerializedName("first_name")
private String firstName;
/**
* 二级类目ID
*/
@SerializedName ("second")
@SerializedName("second")
private int second;
/**
* 二级类目名称
*/
@SerializedName ("second_name")
@SerializedName("second_name")
private String secondName;
/**
* 审核状态(1审核中 2审核不通过 3审核通过)
*/
@SerializedName ("audit_status")
@SerializedName("audit_status")
private int auditStatus;
/**
* 审核不通过原因
*/
@SerializedName ("audit_reason")
@SerializedName("audit_reason")
private String auditReason;
}
}

+ 19
- 15
weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxFastMaCanSetCategoryResult.java Vedi File

@@ -2,25 +2,29 @@ package me.chanjar.weixin.open.bean.result;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
* 获取账号所有可以设置的类目.
*
* @author Hipple
* @description 获取账号所有可以设置的类目
* @since 2019/1/26 18:43
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class WxFastMaCanSetCategoryResult extends WxOpenResult {
private static final long serialVersionUID = - 2469386233538980102L;
@SerializedName ("errcode")
private int errcodeX;
@SerializedName ("categories_list")
private static final long serialVersionUID = -2469386233538980102L;
@SerializedName("errcode")
private int errCode;
@SerializedName("categories_list")
private CategoriesListBean categoriesList;

@Data
public static class CategoriesListBean {
private List<CategoriesBean> categories;

@Data
public static class CategoriesBean {
private int id;
@@ -28,29 +32,29 @@ public class WxFastMaCanSetCategoryResult extends WxOpenResult {
private String name;
private int level;
private int father;
@SerializedName ("sensitive_type")
@SerializedName("sensitive_type")
private int sensitiveType;
@SerializedName ("available_for_plugin")
@SerializedName("available_for_plugin")
private boolean availableForPlugin;
@SerializedName ("is_hidden")
@SerializedName("is_hidden")
private boolean isHidden;
private String type;
@SerializedName ("need_report")
@SerializedName("need_report")
private int needReport;
@SerializedName ("can_use_cityserivce")
private int canUseCityserivce;
@SerializedName("can_use_cityserivce")
private int canUseCityService;
private List<Integer> children;
@SerializedName ("type_list")
@SerializedName("type_list")
private List<?> typeList;
@SerializedName ("available_api_list")
@SerializedName("available_api_list")
private List<?> availableApiList;
private List<?> apis;

@Data
public static class QualifyBean {
private String remark;
@SerializedName ("exter_list")
private List<?> exterList;
@SerializedName("exter_list")
private List<?> externalList;
}

}


+ 3
- 3
weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxFastMaCheckNickameResult.java Vedi File

@@ -10,20 +10,20 @@ import lombok.EqualsAndHashCode;
* @since 2019/1/26 17:39
*/
@Data
@EqualsAndHashCode (callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class WxFastMaCheckNickameResult extends WxOpenResult {
private static final long serialVersionUID = 8022192589710319473L;

/**
* 审核编号.
*/
@SerializedName ("hit_condition")
@SerializedName("hit_condition")
boolean hitCondition;

/**
* 材料说明
*/
@SerializedName ("wording")
@SerializedName("wording")
String wording;

}

+ 6
- 6
weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxFastMaQueryNicknameStatusResult.java Vedi File

@@ -9,7 +9,7 @@ import lombok.EqualsAndHashCode;
* @description 查询改名状态实体类
* @since 2019/1/26 17:52
*/
@EqualsAndHashCode (callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Data
public class WxFastMaQueryNicknameStatusResult extends WxOpenResult {

@@ -18,26 +18,26 @@ public class WxFastMaQueryNicknameStatusResult extends WxOpenResult {
/**
* 审核昵称
*/
@SerializedName ("nickname")
@SerializedName("nickname")
private String nickname;
/**
* 审核状态,1:审核中,2:审核失败,3:审核成功
*/
@SerializedName ("audit_stat")
@SerializedName("audit_stat")
private int auditStat;
/**
* 失败原因
*/
@SerializedName ("fail_reason")
@SerializedName("fail_reason")
private String failReason;
/**
* 审核提交时间
*/
@SerializedName ("create_time")
@SerializedName("create_time")
private String createTime;
/**
* 审核提交时间
*/
@SerializedName ("audit_time")
@SerializedName("audit_time")
private String auditTime;
}

+ 3
- 3
weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxFastMaSetNickameResult.java Vedi File

@@ -10,20 +10,20 @@ import lombok.EqualsAndHashCode;
* @since 2019/1/26 17:39
*/
@Data
@EqualsAndHashCode (callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class WxFastMaSetNickameResult extends WxOpenResult {
private static final long serialVersionUID = 8022192589710319473L;

/**
* 审核编号.
*/
@SerializedName ("audit_id")
@SerializedName("audit_id")
Long auditId;

/**
* 材料说明
*/
@SerializedName ("wording")
@SerializedName("wording")
String wording;

}

+ 1
- 1
weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerListResult.java Vedi File

@@ -11,5 +11,5 @@ import java.util.Map;
@Data
public class WxOpenAuthorizerListResult {
private int totalCount;
private List<Map<String,String>> list;
private List<Map<String, String>> list;
}

+ 2
- 2
weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaCategoryListResult.java Vedi File

@@ -1,13 +1,13 @@
package me.chanjar.weixin.open.bean.result;

import java.util.List;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import me.chanjar.weixin.open.bean.ma.WxOpenMaCategory;
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;

import java.util.List;

/**
* 微信开放平台小程序分类目录列表返回
*


+ 2
- 2
weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaDomainResult.java Vedi File

@@ -1,11 +1,11 @@
package me.chanjar.weixin.open.bean.result;

import java.util.List;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
* 微信开放平台小程序域名设置返回对象.
*


+ 0
- 3
weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaGrayReleasePlanResult.java Vedi File

@@ -5,9 +5,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;

import java.io.Serializable;
import java.util.List;

/**
* 微信开放平台小程序当前分阶段发布详情
*/


+ 2
- 2
weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaPageListResult.java Vedi File

@@ -1,12 +1,12 @@
package me.chanjar.weixin.open.bean.result;

import java.util.List;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;

import java.util.List;

/**
* 微信开放平台小程序第三方提交代码的页面配置列表.
*


+ 1
- 0
weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenMaQueryAuditResult.java Vedi File

@@ -6,6 +6,7 @@ import lombok.EqualsAndHashCode;

/**
* .
*
* @author yqx
* @date 2018/10/3
*/


+ 13
- 13
weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxFastMaAccountBasicInfoGsonAdapter.java Vedi File

@@ -14,30 +14,30 @@ import java.lang.reflect.Type;
*/
public class WxFastMaAccountBasicInfoGsonAdapter implements JsonDeserializer<WxFastMaAccountBasicInfoResult> {
@Override
public WxFastMaAccountBasicInfoResult deserialize (JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
WxFastMaAccountBasicInfoResult accountBasicInfo = new WxFastMaAccountBasicInfoResult ();
public WxFastMaAccountBasicInfoResult deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
WxFastMaAccountBasicInfoResult accountBasicInfo = new WxFastMaAccountBasicInfoResult();
JsonObject jsonObject = jsonElement.getAsJsonObject();

accountBasicInfo.setAppId (GsonHelper.getString(jsonObject, "appid"));
accountBasicInfo.setAccountType (GsonHelper.getInteger (jsonObject, "account_type"));
accountBasicInfo.setPrincipalType (GsonHelper.getInteger (jsonObject, "principal_type"));
accountBasicInfo.setPrincipalName (GsonHelper.getString(jsonObject, "principal_name"));
accountBasicInfo.setRealnameStatus (GsonHelper.getInteger (jsonObject, "realname_status"));
accountBasicInfo.setAppId(GsonHelper.getString(jsonObject, "appid"));
accountBasicInfo.setAccountType(GsonHelper.getInteger(jsonObject, "account_type"));
accountBasicInfo.setPrincipalType(GsonHelper.getInteger(jsonObject, "principal_type"));
accountBasicInfo.setPrincipalName(GsonHelper.getString(jsonObject, "principal_name"));
accountBasicInfo.setRealnameStatus(GsonHelper.getInteger(jsonObject, "realname_status"));

WxFastMaAccountBasicInfoResult.WxVerifyInfo verifyInfo = WxOpenGsonBuilder.create().fromJson(jsonObject.get("wx_verify_info"),
new TypeToken<WxFastMaAccountBasicInfoResult.WxVerifyInfo> () {
new TypeToken<WxFastMaAccountBasicInfoResult.WxVerifyInfo>() {
}.getType());
accountBasicInfo.setWxVerifyInfo (verifyInfo);
accountBasicInfo.setWxVerifyInfo(verifyInfo);

WxFastMaAccountBasicInfoResult.SignatureInfo signatureInfo = WxOpenGsonBuilder.create().fromJson(jsonObject.get("signature_info"),
new TypeToken<WxFastMaAccountBasicInfoResult.SignatureInfo> () {
new TypeToken<WxFastMaAccountBasicInfoResult.SignatureInfo>() {
}.getType());
accountBasicInfo.setSignatureInfo (signatureInfo);
accountBasicInfo.setSignatureInfo(signatureInfo);

WxFastMaAccountBasicInfoResult.HeadImageInfo headImageInfo = WxOpenGsonBuilder.create().fromJson(jsonObject.get("head_image_info"),
new TypeToken<WxFastMaAccountBasicInfoResult.HeadImageInfo> () {
new TypeToken<WxFastMaAccountBasicInfoResult.HeadImageInfo>() {
}.getType());
accountBasicInfo.setHeadImageInfo (headImageInfo);
accountBasicInfo.setHeadImageInfo(headImageInfo);

return accountBasicInfo;
}


+ 12
- 11
weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerListResultGsonAdapter.java Vedi File

@@ -11,28 +11,29 @@ import java.util.*;
* @author robgao
* @Email 315789501@qq.com
*/
public class WxOpenAuthorizerListResultGsonAdapter implements JsonDeserializer<WxOpenAuthorizerListResult> {
public class WxOpenAuthorizerListResultGsonAdapter implements JsonDeserializer<WxOpenAuthorizerListResult> {

private static final String AUTHORIZER_APPID = "authorizer_appid";
private static final String REFRESH_TOKEN = "refresh_token";
private static final String AUTH_TIME = "auth_time";

private static final String AUTHORIZER_APPID="authorizer_appid";
private static final String REFRESH_TOKEN="refresh_token";
private static final String AUTH_TIME="auth_time";
@Override
public WxOpenAuthorizerListResult deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
JsonObject jsonObject = jsonElement.getAsJsonObject();

WxOpenAuthorizerListResult wxOpenAuthorizerListResult= new WxOpenAuthorizerListResult();
WxOpenAuthorizerListResult wxOpenAuthorizerListResult = new WxOpenAuthorizerListResult();
wxOpenAuthorizerListResult.setTotalCount(GsonHelper.getInteger(jsonObject, "total_count").intValue());

List<Map<String,String>> list = new ArrayList<>();
List<Map<String, String>> list = new ArrayList<>();
Iterator<JsonElement> jsonElementIterator = jsonObject.getAsJsonArray("list").iterator();

while(jsonElementIterator.hasNext()){
while (jsonElementIterator.hasNext()) {
JsonObject authorizer = jsonElementIterator.next().getAsJsonObject();
Map<String,String> authorizerMap = new HashMap<>(10);
Map<String, String> authorizerMap = new HashMap<>(10);

authorizerMap.put(AUTHORIZER_APPID, GsonHelper.getString(authorizer,AUTHORIZER_APPID));
authorizerMap.put(REFRESH_TOKEN, GsonHelper.getString(authorizer,REFRESH_TOKEN));
authorizerMap.put(AUTH_TIME, GsonHelper.getString(authorizer,AUTH_TIME));
authorizerMap.put(AUTHORIZER_APPID, GsonHelper.getString(authorizer, AUTHORIZER_APPID));
authorizerMap.put(REFRESH_TOKEN, GsonHelper.getString(authorizer, REFRESH_TOKEN));
authorizerMap.put(AUTH_TIME, GsonHelper.getString(authorizer, AUTH_TIME));
list.add(authorizerMap);
}
wxOpenAuthorizerListResult.setList(list);


+ 2
- 2
weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenGsonBuilder.java Vedi File

@@ -24,8 +24,8 @@ public class WxOpenGsonBuilder {
INSTANCE.registerTypeAdapter(WxOpenQueryAuthResult.class, new WxOpenQueryAuthResultGsonAdapter());
INSTANCE.registerTypeAdapter(WxOpenAuthorizerInfoResult.class, new WxOpenAuthorizerInfoResultGsonAdapter());
INSTANCE.registerTypeAdapter(WxOpenAuthorizerOptionResult.class, new WxOpenAuthorizerOptionResultGsonAdapter());
INSTANCE.registerTypeAdapter(WxFastMaAccountBasicInfoResult.class, new WxFastMaAccountBasicInfoGsonAdapter ());
INSTANCE.registerTypeAdapter(WxOpenAuthorizerListResult.class, new WxOpenAuthorizerListResultGsonAdapter ());
INSTANCE.registerTypeAdapter(WxFastMaAccountBasicInfoResult.class, new WxFastMaAccountBasicInfoGsonAdapter());
INSTANCE.registerTypeAdapter(WxOpenAuthorizerListResult.class, new WxOpenAuthorizerListResultGsonAdapter());

}



+ 6
- 6
weixin-java-open/src/test/java/me/chanjar/weixin/open/bean/result/WxFastMaAccountBasicInfoResultTest.java Vedi File

@@ -37,14 +37,14 @@ public class WxFastMaAccountBasicInfoResultTest {
" }\n" +
"}";

WxFastMaAccountBasicInfoResult res = WxOpenGsonBuilder.create ().fromJson (json, WxFastMaAccountBasicInfoResult.class);
WxFastMaAccountBasicInfoResult res = WxOpenGsonBuilder.create().fromJson(json, WxFastMaAccountBasicInfoResult.class);

assertNotNull(res);
assertNotNull(res.getAppId ());
assertNotNull(res.getSignatureInfo ().getModifyQuota ());
assertNotNull(res.getHeadImageInfo ().getHeadImageUrl ());
assertNotNull(res.getWxVerifyInfo ().getNamingVerify ());
assertTrue(res.getWxVerifyInfo ().getNamingVerify ());
assertNotNull(res.getAppId());
assertNotNull(res.getSignatureInfo().getModifyQuota());
assertNotNull(res.getHeadImageInfo().getHeadImageUrl());
assertNotNull(res.getWxVerifyInfo().getNamingVerify());
assertTrue(res.getWxVerifyInfo().getNamingVerify());
System.out.println(res);
}



+ 4
- 4
weixin-java-open/src/test/java/me/chanjar/weixin/open/bean/result/WxFastMaBeenSetCategoryResultTest.java Vedi File

@@ -28,12 +28,12 @@ public class WxFastMaBeenSetCategoryResultTest {
" \"category_limit\": 20\n" +
"}";

WxFastMaBeenSetCategoryResult res = WxOpenGsonBuilder.create ().fromJson (json, WxFastMaBeenSetCategoryResult.class);
WxFastMaBeenSetCategoryResult res = WxOpenGsonBuilder.create().fromJson(json, WxFastMaBeenSetCategoryResult.class);

assertNotNull(res);
assertTrue(res.getCategories ().size ()> 0);
assertNotNull(res.getCategories ().get (0));
assertNotNull(res.getCategories ().get (0).getFirstName ());
assertTrue(res.getCategories().size() > 0);
assertNotNull(res.getCategories().get(0));
assertNotNull(res.getCategories().get(0).getFirstName());
System.out.println(res);
}



+ 2
- 2
weixin-java-open/src/test/java/me/chanjar/weixin/open/bean/result/WxFastMaCanSetCategoryResultTest.java Vedi File

@@ -69,10 +69,10 @@ public class WxFastMaCanSetCategoryResultTest {
" ]\n" +
" }\n" +
"}";
WxFastMaCanSetCategoryResult res = WxOpenGsonBuilder.create ().fromJson (json, WxFastMaCanSetCategoryResult.class);
WxFastMaCanSetCategoryResult res = WxOpenGsonBuilder.create().fromJson(json, WxFastMaCanSetCategoryResult.class);

assertNotNull(res);
assertNotNull(res.getCategoriesList ());
assertNotNull(res.getCategoriesList());
System.out.println(res);
}



Caricamento…
Annulla
Salva