mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-21 11:07:37 +08:00
🎨 统一抽取errcode常量,同步优化规范部分代码
This commit is contained in:
@@ -3,6 +3,7 @@ package me.chanjar.weixin.cp.api.impl;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
@@ -46,7 +47,7 @@ public class WxCpAgentServiceImpl implements WxCpAgentService {
|
||||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(AGENT_SET);
|
||||
String responseContent = this.mainService.post(url, agentInfo.toJson());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get("errcode").getAsInt() != 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.CP));
|
||||
}
|
||||
}
|
||||
@@ -56,7 +57,7 @@ public class WxCpAgentServiceImpl implements WxCpAgentService {
|
||||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(AGENT_LIST);
|
||||
String responseContent = this.mainService.get(url, null);
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get("errcode").getAsInt() != 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.CP));
|
||||
}
|
||||
|
||||
|
@@ -5,6 +5,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.bean.WxAccessToken;
|
||||
import me.chanjar.weixin.common.bean.WxJsapiSignature;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
@@ -163,7 +164,7 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ
|
||||
"type=agent_config&access_token=" + this.configStorage.getAccessToken(authCorpId), true);
|
||||
|
||||
JsonObject jsonObject = GsonParser.parse(resp);
|
||||
if (jsonObject.get("errcode").getAsInt() == 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() == 0) {
|
||||
String jsApiTicket = jsonObject.get("ticket").getAsString();
|
||||
int expiredInSeconds = jsonObject.get("expires_in").getAsInt();
|
||||
synchronized (globalJsApiTicketRefreshLock) {
|
||||
@@ -193,7 +194,7 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ
|
||||
"access_token=" + this.configStorage.getAccessToken(authCorpId), true);
|
||||
|
||||
JsonObject jsonObject = GsonParser.parse(resp);
|
||||
if (jsonObject.get("errcode").getAsInt() == 0) {
|
||||
if (jsonObject.get(WxConsts.ERR_CODE).getAsInt() == 0) {
|
||||
String jsApiTicket = jsonObject.get("ticket").getAsString();
|
||||
int expiredInSeconds = jsonObject.get("expires_in").getAsInt();
|
||||
|
||||
|
Reference in New Issue
Block a user