@@ -15,10 +15,6 @@ import java.util.List; | |||
* @author <a href="https://github.com/huansinho">huansinho</a> | |||
*/ | |||
public interface WxCpAgentService { | |||
String GET_AGENT = "/cgi-bin/agent/get?agentid=%d"; | |||
String AGENT_SET = "/cgi-bin/agent/set"; | |||
String AGENT_LIST = "/cgi-bin/agent/list"; | |||
/** | |||
* <pre> | |||
* 获取企业号应用信息 | |||
@@ -12,10 +12,6 @@ import java.util.List; | |||
* @author gaigeshen | |||
*/ | |||
public interface WxCpChatService { | |||
String APPCHAT_CREATE = "/cgi-bin/appchat/create"; | |||
String APPCHAT_UPDATE = "/cgi-bin/appchat/update"; | |||
String APPCHAT_GET_CHATID = "/cgi-bin/appchat/get?chatid="; | |||
String APPCHAT_SEND = "/cgi-bin/appchat/send"; | |||
@Deprecated | |||
String chatCreate(String name, String owner, List<String> users, String chatId) throws WxErrorException; | |||
@@ -14,10 +14,6 @@ import java.util.List; | |||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | |||
*/ | |||
public interface WxCpDepartmentService { | |||
String DEPARTMENT_CREATE = "/cgi-bin/department/create"; | |||
String DEPARTMENT_UPDATE = "/cgi-bin/department/update"; | |||
String DEPARTMENT_DELETE = "/cgi-bin/department/delete?id=%d"; | |||
String DEPARTMENT_LIST = "/cgi-bin/department/list"; | |||
/** | |||
* <pre> | |||
@@ -16,10 +16,6 @@ import java.io.InputStream; | |||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | |||
*/ | |||
public interface WxCpMediaService { | |||
String MEDIA_GET_URL = "/cgi-bin/media/get"; | |||
String MEDIA_UPLOAD_URL = "/cgi-bin/media/upload?type="; | |||
String IMG_UPLOAD_URL = "/cgi-bin/media/uploadimg"; | |||
String JSSDK_MEDIA_GET_URL = "/cgi-bin/media/get/jssdk"; | |||
/** | |||
* <pre> | |||
@@ -12,9 +12,6 @@ import me.chanjar.weixin.common.error.WxErrorException; | |||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | |||
*/ | |||
public interface WxCpMenuService { | |||
String MENU_CREATE = "/cgi-bin/menu/create?agentid=%d"; | |||
String MENU_DELETE = "/cgi-bin/menu/delete?agentid=%d"; | |||
String MENU_GET = "/cgi-bin/menu/get?agentid=%d"; | |||
/** | |||
* <pre> | |||
@@ -13,9 +13,6 @@ import me.chanjar.weixin.cp.bean.WxCpUserDetail; | |||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | |||
*/ | |||
public interface WxCpOAuth2Service { | |||
String URL_GET_USER_INFO = "/cgi-bin/user/getuserinfo?code=%s&agentid=%d"; | |||
String URL_GET_USER_DETAIL = "/cgi-bin/user/getuserdetail"; | |||
String URL_OAUTH_2_AUTHORIZE = "https://open.weixin.qq.com/connect/oauth2/authorize"; | |||
/** | |||
* <pre> | |||
@@ -16,10 +16,6 @@ import java.util.List; | |||
* @date 2019-04-06 10:52 | |||
*/ | |||
public interface WxCpOaService { | |||
String GET_CHECKIN_DATA = "/cgi-bin/checkin/getcheckindata"; | |||
String GET_CHECKIN_OPTION = "/cgi-bin/checkin/getcheckinoption"; | |||
String GET_APPROVAL_DATA = "/cgi-bin/corp/getapprovaldata"; | |||
String GET_DIAL_RECORD = "/cgi-bin/dial/get_dial_record"; | |||
/** | |||
* <pre> | |||
@@ -17,16 +17,6 @@ import me.chanjar.weixin.cp.config.WxCpConfigStorage; | |||
* @author chanjaster | |||
*/ | |||
public interface WxCpService { | |||
String GET_JSAPI_TICKET = "/cgi-bin/get_jsapi_ticket"; | |||
String GET_AGENT_CONFIG_TICKET = "/cgi-bin/ticket/get?&type=agent_config"; | |||
String MESSAGE_SEND = "/cgi-bin/message/send"; | |||
String GET_CALLBACK_IP = "/cgi-bin/getcallbackip"; | |||
String BATCH_REPLACE_PARTY = "/cgi-bin/batch/replaceparty"; | |||
String BATCH_REPLACE_USER = "/cgi-bin/batch/replaceuser"; | |||
String BATCH_GET_RESULT = "/cgi-bin/batch/getresult?jobid="; | |||
String JSCODE_TO_SESSION_URL = "/cgi-bin/miniprogram/jscode2session"; | |||
String GET_TOKEN = "/cgi-bin/gettoken?&corpid=%s&corpsecret=%s"; | |||
/** | |||
* <pre> | |||
* 验证推送过来的消息的正确性 | |||
@@ -17,13 +17,6 @@ import java.util.List; | |||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | |||
*/ | |||
public interface WxCpTagService { | |||
String TAG_CREATE = "/cgi-bin/tag/create"; | |||
String TAG_UPDATE = "/cgi-bin/tag/update"; | |||
String TAG_DELETE = "/cgi-bin/tag/delete?tagid=%s"; | |||
String TAG_LIST = "/cgi-bin/tag/list"; | |||
String TAG_GET = "/cgi-bin/tag/get?tagid=%s"; | |||
String TAG_ADDTAGUSERS = "/cgi-bin/tag/addtagusers"; | |||
String TAG_DELTAGUSERS = "/cgi-bin/tag/deltagusers"; | |||
/** | |||
* 创建标签. | |||
@@ -14,7 +14,6 @@ import java.util.List; | |||
* @date 2019-05-16 | |||
*/ | |||
public interface WxCpTaskCardService { | |||
String MESSAGE_UPDATE_TASKCARD = "/cgi-bin/message/update_taskcard"; | |||
/** | |||
* <pre> | |||
@@ -15,10 +15,6 @@ import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; | |||
* @author zhenjun cai | |||
*/ | |||
public interface WxCpTpService { | |||
String JSCODE_TO_SESSION_URL = "/cgi-bin/service/miniprogram/jscode2session"; | |||
String GET_CORP_TOKEN = "/cgi-bin/service/get_corp_token"; | |||
String GET_PERMANENT_CODE = "/cgi-bin/service/get_permanent_code"; | |||
String GET_SUITE_TOKEN = "/cgi-bin/service/get_suite_token"; | |||
/** | |||
* <pre> | |||
@@ -17,18 +17,6 @@ import java.util.Map; | |||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | |||
*/ | |||
public interface WxCpUserService { | |||
String URL_AUTHENTICATE = "/cgi-bin/user/authsucc?userid="; | |||
String URL_USER_CREATE = "/cgi-bin/user/create"; | |||
String URL_USER_UPDATE = "/cgi-bin/user/update"; | |||
String URL_USER_DELETE = "/cgi-bin/user/delete?userid="; | |||
String URL_USER_BATCH_DELETE = "/cgi-bin/user/batchdelete"; | |||
String URL_USER_GET = "/cgi-bin/user/get?userid="; | |||
String URL_USER_LIST = "/cgi-bin/user/list?department_id="; | |||
String URL_USER_SIMPLE_LIST = "/cgi-bin/user/simplelist?department_id="; | |||
String URL_BATCH_INVITE = "/cgi-bin/batch/invite"; | |||
String URL_CONVERT_TO_OPENID = "/cgi-bin/user/convert_to_openid"; | |||
String URL_CONVERT_TO_USERID = "/cgi-bin/user/convert_to_userid"; | |||
String URL_GET_EXTERNAL_CONTACT = "/cgi-bin/crm/get_external_contact?external_userid="; | |||
/** | |||
* <pre> | |||
@@ -5,6 +5,7 @@ import com.google.gson.JsonArray; | |||
import com.google.gson.JsonElement; | |||
import com.google.gson.JsonObject; | |||
import com.google.gson.JsonParser; | |||
import lombok.extern.slf4j.Slf4j; | |||
import me.chanjar.weixin.common.bean.WxJsapiSignature; | |||
import me.chanjar.weixin.common.error.WxError; | |||
import me.chanjar.weixin.common.error.WxErrorException; | |||
@@ -33,6 +34,7 @@ import me.chanjar.weixin.cp.bean.WxCpMaJsCode2SessionResult; | |||
import me.chanjar.weixin.cp.bean.WxCpMessage; | |||
import me.chanjar.weixin.cp.bean.WxCpMessageSendResult; | |||
import me.chanjar.weixin.cp.config.WxCpConfigStorage; | |||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
@@ -41,12 +43,13 @@ import java.io.IOException; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.*; | |||
/** | |||
* @author chanjarster | |||
*/ | |||
@Slf4j | |||
public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestHttp<H, P> { | |||
protected final Logger log = LoggerFactory.getLogger(this.getClass()); | |||
private WxCpUserService userService = new WxCpUserServiceImpl(this); | |||
private WxCpChatService chatService = new WxCpChatServiceImpl(this); | |||
private WxCpDepartmentService departmentService = new WxCpDepartmentServiceImpl(this); | |||
@@ -90,7 +93,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | |||
return SHA1.gen(this.configStorage.getToken(), timestamp, nonce, data) | |||
.equals(msgSignature); | |||
} catch (Exception e) { | |||
this.log.error("Checking signature failed, and the reason is :" + e.getMessage()); | |||
log.error("Checking signature failed, and the reason is :" + e.getMessage()); | |||
return false; | |||
} | |||
} | |||
@@ -114,7 +117,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | |||
if (this.configStorage.isAgentJsapiTicketExpired()) { | |||
synchronized (this.globalAgentJsapiTicketRefreshLock) { | |||
if (this.configStorage.isAgentJsapiTicketExpired()) { | |||
String responseContent = this.get(this.configStorage.getApiUrl(WxCpService.GET_AGENT_CONFIG_TICKET), null); | |||
String responseContent = this.get(this.configStorage.getApiUrl(GET_AGENT_CONFIG_TICKET), null); | |||
JsonObject jsonObject = new JsonParser().parse(responseContent).getAsJsonObject(); | |||
this.configStorage.updateAgentJsapiTicket(jsonObject.get("ticket").getAsString(), | |||
jsonObject.get("expires_in").getAsInt()); | |||
@@ -139,7 +142,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | |||
if (this.configStorage.isJsapiTicketExpired()) { | |||
synchronized (this.globalJsapiTicketRefreshLock) { | |||
if (this.configStorage.isJsapiTicketExpired()) { | |||
String responseContent = this.get(this.configStorage.getApiUrl(WxCpService.GET_JSAPI_TICKET), null); | |||
String responseContent = this.get(this.configStorage.getApiUrl(GET_JSAPI_TICKET), null); | |||
JsonObject tmpJsonObject = new JsonParser().parse(responseContent).getAsJsonObject(); | |||
this.configStorage.updateJsapiTicket(tmpJsonObject.get("ticket").getAsString(), | |||
tmpJsonObject.get("expires_in").getAsInt()); | |||
@@ -180,7 +183,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | |||
message.setAgentId(this.getWxCpConfigStorage().getAgentId()); | |||
} | |||
return WxCpMessageSendResult.fromJson(this.post(this.configStorage.getApiUrl(WxCpService.MESSAGE_SEND), message.toJson())); | |||
return WxCpMessageSendResult.fromJson(this.post(this.configStorage.getApiUrl(MESSAGE_SEND), message.toJson())); | |||
} | |||
@Override | |||
@@ -189,13 +192,13 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | |||
params.put("js_code", jsCode); | |||
params.put("grant_type", "authorization_code"); | |||
String result = this.get(this.configStorage.getApiUrl(JSCODE_TO_SESSION_URL), Joiner.on("&").withKeyValueSeparator("=").join(params)); | |||
String result = this.get(this.configStorage.getApiUrl(JSCODE_TO_SESSION), Joiner.on("&").withKeyValueSeparator("=").join(params)); | |||
return WxCpMaJsCode2SessionResult.fromJson(result); | |||
} | |||
@Override | |||
public String[] getCallbackIp() throws WxErrorException { | |||
String responseContent = get(this.configStorage.getApiUrl(WxCpService.GET_CALLBACK_IP), null); | |||
String responseContent = get(this.configStorage.getApiUrl(GET_CALLBACK_IP), null); | |||
JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | |||
JsonArray jsonArray = tmpJsonElement.getAsJsonObject().get("ip_list").getAsJsonArray(); | |||
String[] ips = new String[jsonArray.size()]; | |||
@@ -226,7 +229,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | |||
return this.executeInternal(executor, uri, data); | |||
} catch (WxErrorException e) { | |||
if (retryTimes + 1 > this.maxRetryTimes) { | |||
this.log.warn("重试达到最大次数【{}】", this.maxRetryTimes); | |||
log.warn("重试达到最大次数【{}】", this.maxRetryTimes); | |||
//最后一次重试失败后,直接抛出异常,不再等待 | |||
throw new RuntimeException("微信服务端异常,超出重试次数"); | |||
} | |||
@@ -238,7 +241,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | |||
if (error.getErrorCode() == -1) { | |||
int sleepMillis = this.retrySleepMillis * (1 << retryTimes); | |||
try { | |||
this.log.debug("微信系统繁忙,{} ms 后重试(第{}次)", sleepMillis, retryTimes + 1); | |||
log.debug("微信系统繁忙,{} ms 后重试(第{}次)", sleepMillis, retryTimes + 1); | |||
Thread.sleep(sleepMillis); | |||
} catch (InterruptedException e1) { | |||
Thread.currentThread().interrupt(); | |||
@@ -249,7 +252,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | |||
} | |||
} while (retryTimes++ < this.maxRetryTimes); | |||
this.log.warn("重试达到最大次数【{}】", this.maxRetryTimes); | |||
log.warn("重试达到最大次数【{}】", this.maxRetryTimes); | |||
throw new RuntimeException("微信服务端异常,超出重试次数"); | |||
} | |||
@@ -265,7 +268,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | |||
try { | |||
T result = executor.execute(uriWithAccessToken, data); | |||
this.log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uriWithAccessToken, dataForLog, result); | |||
log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uriWithAccessToken, dataForLog, result); | |||
return result; | |||
} catch (WxErrorException e) { | |||
WxError error = e.getError(); | |||
@@ -282,12 +285,12 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | |||
} | |||
if (error.getErrorCode() != 0) { | |||
this.log.error("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uriWithAccessToken, dataForLog, error); | |||
log.error("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uriWithAccessToken, dataForLog, error); | |||
throw new WxErrorException(error, e); | |||
} | |||
return null; | |||
} catch (IOException e) { | |||
this.log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, dataForLog, e.getMessage()); | |||
log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, dataForLog, e.getMessage()); | |||
throw new RuntimeException(e); | |||
} | |||
} | |||
@@ -339,19 +342,19 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | |||
public String replaceParty(String mediaId) throws WxErrorException { | |||
JsonObject jsonObject = new JsonObject(); | |||
jsonObject.addProperty("media_id", mediaId); | |||
return post(this.configStorage.getApiUrl(WxCpService.BATCH_REPLACE_PARTY), jsonObject.toString()); | |||
return post(this.configStorage.getApiUrl(BATCH_REPLACE_PARTY), jsonObject.toString()); | |||
} | |||
@Override | |||
public String replaceUser(String mediaId) throws WxErrorException { | |||
JsonObject jsonObject = new JsonObject(); | |||
jsonObject.addProperty("media_id", mediaId); | |||
return post(this.configStorage.getApiUrl(WxCpService.BATCH_REPLACE_USER), jsonObject.toString()); | |||
return post(this.configStorage.getApiUrl(BATCH_REPLACE_USER), jsonObject.toString()); | |||
} | |||
@Override | |||
public String getTaskResult(String joinId) throws WxErrorException { | |||
String url = this.configStorage.getApiUrl(WxCpService.BATCH_GET_RESULT + joinId); | |||
String url = this.configStorage.getApiUrl(BATCH_GET_RESULT + joinId); | |||
return get(url, null); | |||
} | |||
@@ -1,17 +1,9 @@ | |||
package me.chanjar.weixin.cp.api.impl; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import com.google.common.base.Joiner; | |||
import com.google.gson.JsonObject; | |||
import com.google.gson.JsonParser; | |||
import lombok.extern.slf4j.Slf4j; | |||
import me.chanjar.weixin.common.WxType; | |||
import me.chanjar.weixin.common.bean.WxAccessToken; | |||
import me.chanjar.weixin.common.error.WxError; | |||
@@ -22,34 +14,37 @@ import me.chanjar.weixin.common.util.http.RequestExecutor; | |||
import me.chanjar.weixin.common.util.http.RequestHttp; | |||
import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; | |||
import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor; | |||
import me.chanjar.weixin.cp.api.WxCpService; | |||
import me.chanjar.weixin.cp.api.WxCpTpService; | |||
import me.chanjar.weixin.cp.bean.WxCpMaJsCode2SessionResult; | |||
import me.chanjar.weixin.cp.bean.WxCpTpCorp; | |||
import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; | |||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
/** | |||
* @author zhenjun cai | |||
*/ | |||
@Slf4j | |||
public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, RequestHttp<H, P> { | |||
protected final Logger log = LoggerFactory.getLogger(this.getClass()); | |||
/** | |||
* 全局的是否正在刷新access token的锁 | |||
* 全局的是否正在刷新access token的锁. | |||
*/ | |||
protected final Object globalSuiteAccessTokenRefreshLock = new Object(); | |||
/** | |||
* 全局的是否正在刷新jsapi_ticket的锁 | |||
* 全局的是否正在刷新jsapi_ticket的锁. | |||
*/ | |||
protected final Object globalSuiteTicketRefreshLock = new Object(); | |||
protected WxCpTpConfigStorage configStorage; | |||
/** | |||
* 临时文件目录 | |||
* 临时文件目录. | |||
*/ | |||
private File tmpDirFile; | |||
private int retrySleepMillis = 1000; | |||
@@ -61,7 +56,7 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ | |||
return SHA1.gen(this.configStorage.getToken(), timestamp, nonce, data) | |||
.equals(msgSignature); | |||
} catch (Exception e) { | |||
this.log.error("Checking signature failed, and the reason is :" + e.getMessage()); | |||
log.error("Checking signature failed, and the reason is :" + e.getMessage()); | |||
return false; | |||
} | |||
} | |||
@@ -83,11 +78,11 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ | |||
// this.configStorage.expireSuiteTicket(); | |||
// } | |||
if (this.configStorage.isSuiteTicketExpired()) { | |||
// 本地suite ticket 不存在或者过期 | |||
WxError wxError = WxError.fromJson("{\"errcode\":40085, \"errmsg\":\"invaild suite ticket\"}", WxType.CP); | |||
throw new WxErrorException(wxError); | |||
} | |||
if (this.configStorage.isSuiteTicketExpired()) { | |||
// 本地suite ticket 不存在或者过期 | |||
WxError wxError = WxError.fromJson("{\"errcode\":40085, \"errmsg\":\"invaild suite ticket\"}", WxType.CP); | |||
throw new WxErrorException(wxError); | |||
} | |||
return this.configStorage.getSuiteTicket(); | |||
} | |||
@@ -98,28 +93,28 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ | |||
params.put("js_code", jsCode); | |||
params.put("grant_type", "authorization_code"); | |||
String result = this.get(configStorage.getApiUrl(JSCODE_TO_SESSION_URL), Joiner.on("&").withKeyValueSeparator("=").join(params)); | |||
String result = this.get(configStorage.getApiUrl(WxCpApiPathConsts.Tp.JSCODE_TO_SESSION), Joiner.on("&").withKeyValueSeparator("=").join(params)); | |||
return WxCpMaJsCode2SessionResult.fromJson(result); | |||
} | |||
@Override | |||
public WxAccessToken getCorpToken(String authCorpid, String permanentCode) throws WxErrorException { | |||
JsonObject jsonObject = new JsonObject(); | |||
jsonObject.addProperty("auth_corpid", authCorpid); | |||
jsonObject.addProperty("permanent_code", permanentCode); | |||
String result = post(configStorage.getApiUrl(GET_CORP_TOKEN), jsonObject.toString()); | |||
return WxAccessToken.fromJson(result); | |||
JsonObject jsonObject = new JsonObject(); | |||
jsonObject.addProperty("auth_corpid", authCorpid); | |||
jsonObject.addProperty("permanent_code", permanentCode); | |||
String result = post(configStorage.getApiUrl(WxCpApiPathConsts.Tp.GET_CORP_TOKEN), jsonObject.toString()); | |||
return WxAccessToken.fromJson(result); | |||
} | |||
@Override | |||
public WxCpTpCorp getPermanentCode(String authCode) throws WxErrorException { | |||
JsonObject jsonObject = new JsonObject(); | |||
jsonObject.addProperty("auth_code", authCode); | |||
String result = post(configStorage.getApiUrl(GET_PERMANENT_CODE), jsonObject.toString()); | |||
String result = post(configStorage.getApiUrl(WxCpApiPathConsts.Tp.GET_PERMANENT_CODE), jsonObject.toString()); | |||
jsonObject = new JsonParser().parse(result).getAsJsonObject(); | |||
WxCpTpCorp wxCpTpCorp = WxCpTpCorp.fromJson(jsonObject.get("auth_corp_info").getAsString()); | |||
wxCpTpCorp.setPermanentCode(jsonObject.get("permanent_code").getAsString()); | |||
@@ -147,7 +142,7 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ | |||
return this.executeInternal(executor, uri, data); | |||
} catch (WxErrorException e) { | |||
if (retryTimes + 1 > this.maxRetryTimes) { | |||
this.log.warn("重试达到最大次数【{}】", this.maxRetryTimes); | |||
log.warn("重试达到最大次数【{}】", this.maxRetryTimes); | |||
//最后一次重试失败后,直接抛出异常,不再等待 | |||
throw new RuntimeException("微信服务端异常,超出重试次数"); | |||
} | |||
@@ -159,7 +154,7 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ | |||
if (error.getErrorCode() == -1) { | |||
int sleepMillis = this.retrySleepMillis * (1 << retryTimes); | |||
try { | |||
this.log.debug("微信系统繁忙,{} ms 后重试(第{}次)", sleepMillis, retryTimes + 1); | |||
log.debug("微信系统繁忙,{} ms 后重试(第{}次)", sleepMillis, retryTimes + 1); | |||
Thread.sleep(sleepMillis); | |||
} catch (InterruptedException e1) { | |||
Thread.currentThread().interrupt(); | |||
@@ -170,7 +165,7 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ | |||
} | |||
} while (retryTimes++ < this.maxRetryTimes); | |||
this.log.warn("重试达到最大次数【{}】", this.maxRetryTimes); | |||
log.warn("重试达到最大次数【{}】", this.maxRetryTimes); | |||
throw new RuntimeException("微信服务端异常,超出重试次数"); | |||
} | |||
@@ -186,7 +181,7 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ | |||
try { | |||
T result = executor.execute(uriWithAccessToken, data); | |||
this.log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uriWithAccessToken, dataForLog, result); | |||
log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uriWithAccessToken, dataForLog, result); | |||
return result; | |||
} catch (WxErrorException e) { | |||
WxError error = e.getError(); | |||
@@ -201,12 +196,12 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ | |||
} | |||
if (error.getErrorCode() != 0) { | |||
this.log.error("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uriWithAccessToken, dataForLog, error); | |||
log.error("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uriWithAccessToken, dataForLog, error); | |||
throw new WxErrorException(error, e); | |||
} | |||
return null; | |||
} catch (IOException e) { | |||
this.log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, dataForLog, e.getMessage()); | |||
log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, dataForLog, e.getMessage()); | |||
throw new RuntimeException(e); | |||
} | |||
} | |||
@@ -3,6 +3,7 @@ package me.chanjar.weixin.cp.api.impl; | |||
import com.google.gson.JsonObject; | |||
import com.google.gson.JsonParser; | |||
import com.google.gson.reflect.TypeToken; | |||
import lombok.RequiredArgsConstructor; | |||
import me.chanjar.weixin.common.error.WxError; | |||
import me.chanjar.weixin.common.error.WxErrorException; | |||
import me.chanjar.weixin.cp.api.WxCpAgentService; | |||
@@ -12,6 +13,8 @@ import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | |||
import java.util.List; | |||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Agent.*; | |||
/** | |||
* <pre> | |||
@@ -21,14 +24,11 @@ import java.util.List; | |||
* | |||
* @author <a href="https://github.com/huansinho">huansinho</a> | |||
*/ | |||
@RequiredArgsConstructor | |||
public class WxCpAgentServiceImpl implements WxCpAgentService { | |||
private static final JsonParser JSON_PARSER = new JsonParser(); | |||
private WxCpService mainService; | |||
public WxCpAgentServiceImpl(WxCpService mainService) { | |||
this.mainService = mainService; | |||
} | |||
private final WxCpService mainService; | |||
@Override | |||
public WxCpAgent get(Integer agentId) throws WxErrorException { | |||
@@ -36,13 +36,13 @@ public class WxCpAgentServiceImpl implements WxCpAgentService { | |||
throw new IllegalArgumentException("缺少agentid参数"); | |||
} | |||
String responseContent = this.mainService.get(String.format(this.mainService.getWxCpConfigStorage().getApiUrl(WxCpAgentService.GET_AGENT), agentId), null); | |||
String responseContent = this.mainService.get(String.format(this.mainService.getWxCpConfigStorage().getApiUrl(AGENT_GET), agentId), null); | |||
return WxCpAgent.fromJson(responseContent); | |||
} | |||
@Override | |||
public void set(WxCpAgent agentInfo) throws WxErrorException { | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpAgentService.AGENT_SET); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(AGENT_SET); | |||
String responseContent = this.mainService.post(url, agentInfo.toJson()); | |||
JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); | |||
if (jsonObject.get("errcode").getAsInt() != 0) { | |||
@@ -52,7 +52,7 @@ public class WxCpAgentServiceImpl implements WxCpAgentService { | |||
@Override | |||
public List<WxCpAgent> list() throws WxErrorException { | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpAgentService.AGENT_LIST); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(AGENT_LIST); | |||
String responseContent = this.mainService.get(url, null); | |||
JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); | |||
if (jsonObject.get("errcode").getAsInt() != 0) { | |||
@@ -1,12 +1,14 @@ | |||
package me.chanjar.weixin.cp.api.impl; | |||
import com.google.gson.JsonParser; | |||
import lombok.RequiredArgsConstructor; | |||
import me.chanjar.weixin.common.error.WxErrorException; | |||
import me.chanjar.weixin.common.util.json.WxGsonBuilder; | |||
import me.chanjar.weixin.cp.api.WxCpChatService; | |||
import me.chanjar.weixin.cp.api.WxCpService; | |||
import me.chanjar.weixin.cp.bean.WxCpAppChatMessage; | |||
import me.chanjar.weixin.cp.bean.WxCpChat; | |||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | |||
import org.apache.commons.lang3.StringUtils; | |||
@@ -14,24 +16,18 @@ import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Chat.*; | |||
/** | |||
* 群聊服务实现. | |||
* | |||
* @author gaigeshen | |||
*/ | |||
@RequiredArgsConstructor | |||
public class WxCpChatServiceImpl implements WxCpChatService { | |||
private static final JsonParser JSON_PARSER = new JsonParser(); | |||
private final WxCpService cpService; | |||
/** | |||
* 创建群聊服务实现的实例. | |||
* | |||
* @param cpService 企业微信的服务 | |||
*/ | |||
WxCpChatServiceImpl(WxCpService cpService) { | |||
this.cpService = cpService; | |||
} | |||
@Override | |||
public String chatCreate(String name, String owner, List<String> users, String chatId) throws WxErrorException { | |||
Map<String, Object> data = new HashMap<>(4); | |||
@@ -98,7 +94,7 @@ public class WxCpChatServiceImpl implements WxCpChatService { | |||
@Override | |||
public void sendMsg(WxCpAppChatMessage message) throws WxErrorException { | |||
this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(WxCpChatService.APPCHAT_SEND), message.toJson()); | |||
this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(APPCHAT_SEND), message.toJson()); | |||
} | |||
} |
@@ -3,15 +3,19 @@ package me.chanjar.weixin.cp.api.impl; | |||
import com.google.gson.JsonElement; | |||
import com.google.gson.JsonParser; | |||
import com.google.gson.reflect.TypeToken; | |||
import lombok.RequiredArgsConstructor; | |||
import me.chanjar.weixin.common.error.WxErrorException; | |||
import me.chanjar.weixin.common.util.json.GsonHelper; | |||
import me.chanjar.weixin.cp.api.WxCpDepartmentService; | |||
import me.chanjar.weixin.cp.api.WxCpService; | |||
import me.chanjar.weixin.cp.bean.WxCpDepart; | |||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | |||
import java.util.List; | |||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Department.*; | |||
/** | |||
* <pre> | |||
* 部门管理接口 | |||
@@ -20,16 +24,13 @@ import java.util.List; | |||
* | |||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | |||
*/ | |||
@RequiredArgsConstructor | |||
public class WxCpDepartmentServiceImpl implements WxCpDepartmentService { | |||
private WxCpService mainService; | |||
public WxCpDepartmentServiceImpl(WxCpService mainService) { | |||
this.mainService = mainService; | |||
} | |||
private final WxCpService mainService; | |||
@Override | |||
public Long create(WxCpDepart depart) throws WxErrorException { | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpDepartmentService.DEPARTMENT_CREATE); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_CREATE); | |||
String responseContent = this.mainService.post(url, depart.toJson()); | |||
JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | |||
return GsonHelper.getAsLong(tmpJsonElement.getAsJsonObject().get("id")); | |||
@@ -37,19 +38,19 @@ public class WxCpDepartmentServiceImpl implements WxCpDepartmentService { | |||
@Override | |||
public void update(WxCpDepart group) throws WxErrorException { | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpDepartmentService.DEPARTMENT_UPDATE); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_UPDATE); | |||
this.mainService.post(url, group.toJson()); | |||
} | |||
@Override | |||
public void delete(Long departId) throws WxErrorException { | |||
String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(WxCpDepartmentService.DEPARTMENT_DELETE), departId); | |||
String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_DELETE), departId); | |||
this.mainService.get(url, null); | |||
} | |||
@Override | |||
public List<WxCpDepart> list(Long id) throws WxErrorException { | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpDepartmentService.DEPARTMENT_LIST); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_LIST); | |||
if (id != null) { | |||
url += "?id=" + id; | |||
} | |||
@@ -1,19 +1,22 @@ | |||
package me.chanjar.weixin.cp.api.impl; | |||
import lombok.RequiredArgsConstructor; | |||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | |||
import me.chanjar.weixin.common.error.WxErrorException; | |||
import me.chanjar.weixin.common.util.fs.FileUtils; | |||
import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; | |||
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; | |||
import me.chanjar.weixin.cp.WxCpConsts; | |||
import me.chanjar.weixin.cp.api.WxCpMediaService; | |||
import me.chanjar.weixin.cp.api.WxCpService; | |||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.util.UUID; | |||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Media.*; | |||
/** | |||
* <pre> | |||
* 媒体管理接口. | |||
@@ -22,12 +25,9 @@ import java.util.UUID; | |||
* | |||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | |||
*/ | |||
@RequiredArgsConstructor | |||
public class WxCpMediaServiceImpl implements WxCpMediaService { | |||
private WxCpService mainService; | |||
public WxCpMediaServiceImpl(WxCpService mainService) { | |||
this.mainService = mainService; | |||
} | |||
private final WxCpService mainService; | |||
@Override | |||
public WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputStream) | |||
@@ -38,7 +38,7 @@ public class WxCpMediaServiceImpl implements WxCpMediaService { | |||
@Override | |||
public WxMediaUploadResult upload(String mediaType, File file) throws WxErrorException { | |||
return this.mainService.execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), | |||
this.mainService.getWxCpConfigStorage().getApiUrl(MEDIA_UPLOAD_URL + mediaType), file); | |||
this.mainService.getWxCpConfigStorage().getApiUrl(MEDIA_UPLOAD + mediaType), file); | |||
} | |||
@Override | |||
@@ -46,7 +46,7 @@ public class WxCpMediaServiceImpl implements WxCpMediaService { | |||
return this.mainService.execute( | |||
BaseMediaDownloadRequestExecutor.create(this.mainService.getRequestHttp(), | |||
this.mainService.getWxCpConfigStorage().getTmpDirFile()), | |||
this.mainService.getWxCpConfigStorage().getApiUrl(MEDIA_GET_URL), "media_id=" + mediaId); | |||
this.mainService.getWxCpConfigStorage().getApiUrl(MEDIA_GET), "media_id=" + mediaId); | |||
} | |||
@Override | |||
@@ -54,13 +54,13 @@ public class WxCpMediaServiceImpl implements WxCpMediaService { | |||
return this.mainService.execute( | |||
BaseMediaDownloadRequestExecutor.create(this.mainService.getRequestHttp(), | |||
this.mainService.getWxCpConfigStorage().getTmpDirFile()), | |||
this.mainService.getWxCpConfigStorage().getApiUrl(JSSDK_MEDIA_GET_URL), "media_id=" + mediaId); | |||
this.mainService.getWxCpConfigStorage().getApiUrl(JSSDK_MEDIA_GET), "media_id=" + mediaId); | |||
} | |||
@Override | |||
public String uploadImg(File file) throws WxErrorException { | |||
final WxMediaUploadResult result = this.mainService | |||
.execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), this.mainService.getWxCpConfigStorage().getApiUrl(IMG_UPLOAD_URL), file); | |||
.execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), this.mainService.getWxCpConfigStorage().getApiUrl(IMG_UPLOAD), file); | |||
return result.getUrl(); | |||
} | |||
} |
@@ -1,12 +1,15 @@ | |||
package me.chanjar.weixin.cp.api.impl; | |||
import lombok.RequiredArgsConstructor; | |||
import me.chanjar.weixin.common.bean.menu.WxMenu; | |||
import me.chanjar.weixin.common.error.WxErrorException; | |||
import me.chanjar.weixin.cp.WxCpConsts; | |||
import me.chanjar.weixin.cp.api.WxCpMenuService; | |||
import me.chanjar.weixin.cp.api.WxCpService; | |||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | |||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Menu.*; | |||
/** | |||
* <pre> | |||
* 菜单管理相关接口. | |||
@@ -15,12 +18,9 @@ import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | |||
* | |||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | |||
*/ | |||
@RequiredArgsConstructor | |||
public class WxCpMenuServiceImpl implements WxCpMenuService { | |||
private WxCpService mainService; | |||
public WxCpMenuServiceImpl(WxCpService mainService) { | |||
this.mainService = mainService; | |||
} | |||
private final WxCpService mainService; | |||
@Override | |||
public void create(WxMenu menu) throws WxErrorException { | |||
@@ -29,7 +29,7 @@ public class WxCpMenuServiceImpl implements WxCpMenuService { | |||
@Override | |||
public void create(Integer agentId, WxMenu menu) throws WxErrorException { | |||
String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(WxCpMenuService.MENU_CREATE), agentId); | |||
String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(MENU_CREATE), agentId); | |||
this.mainService.post(url, menu.toJson()); | |||
} | |||
@@ -40,7 +40,7 @@ public class WxCpMenuServiceImpl implements WxCpMenuService { | |||
@Override | |||
public void delete(Integer agentId) throws WxErrorException { | |||
String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(WxCpMenuService.MENU_DELETE), agentId); | |||
String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(MENU_DELETE), agentId); | |||
this.mainService.get(url, null); | |||
} | |||
@@ -51,7 +51,7 @@ public class WxCpMenuServiceImpl implements WxCpMenuService { | |||
@Override | |||
public WxMenu get(Integer agentId) throws WxErrorException { | |||
String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(WxCpMenuService.MENU_GET), agentId); | |||
String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(MENU_GET), agentId); | |||
try { | |||
String resultContent = this.mainService.get(url, null); | |||
return WxCpGsonBuilder.create().fromJson(resultContent, WxMenu.class); | |||
@@ -4,6 +4,7 @@ import com.google.gson.JsonElement; | |||
import com.google.gson.JsonObject; | |||
import com.google.gson.JsonParser; | |||
import lombok.AllArgsConstructor; | |||
import lombok.RequiredArgsConstructor; | |||
import me.chanjar.weixin.common.api.WxConsts; | |||
import me.chanjar.weixin.common.error.WxErrorException; | |||
import me.chanjar.weixin.common.util.http.URIUtil; | |||
@@ -12,10 +13,13 @@ import me.chanjar.weixin.cp.api.WxCpOAuth2Service; | |||
import me.chanjar.weixin.cp.api.WxCpService; | |||
import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo; | |||
import me.chanjar.weixin.cp.bean.WxCpUserDetail; | |||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | |||
import static me.chanjar.weixin.common.api.WxConsts.OAuth2Scope.*; | |||
import static me.chanjar.weixin.common.api.WxConsts.OAuth2Scope.SNSAPI_PRIVATEINFO; | |||
import static me.chanjar.weixin.common.api.WxConsts.OAuth2Scope.SNSAPI_USERINFO; | |||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.OAuth2.*; | |||
/** | |||
* <pre> | |||
@@ -25,7 +29,7 @@ import static me.chanjar.weixin.common.api.WxConsts.OAuth2Scope.SNSAPI_USERINFO; | |||
* | |||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | |||
*/ | |||
@AllArgsConstructor | |||
@RequiredArgsConstructor | |||
public class WxCpOAuth2ServiceImpl implements WxCpOAuth2Service { | |||
private final WxCpService mainService; | |||
@@ -39,12 +43,12 @@ public class WxCpOAuth2ServiceImpl implements WxCpOAuth2Service { | |||
@Override | |||
public String buildAuthorizationUrl(String redirectUri, String state) { | |||
return this.buildAuthorizationUrl(redirectUri, state, WxConsts.OAuth2Scope.SNSAPI_BASE); | |||
return this.buildAuthorizationUrl(redirectUri, state, SNSAPI_BASE); | |||
} | |||
@Override | |||
public String buildAuthorizationUrl(String redirectUri, String state, String scope) { | |||
StringBuilder url = new StringBuilder(WxCpOAuth2Service.URL_OAUTH_2_AUTHORIZE); | |||
StringBuilder url = new StringBuilder(URL_OAUTH2_AUTHORIZE); | |||
url.append("?appid=").append(this.mainService.getWxCpConfigStorage().getCorpId()); | |||
url.append("&redirect_uri=").append(URIUtil.encodeURIComponent(redirectUri)); | |||
url.append("&response_type=code"); | |||
@@ -69,7 +73,7 @@ public class WxCpOAuth2ServiceImpl implements WxCpOAuth2Service { | |||
@Override | |||
public WxCpOauth2UserInfo getUserInfo(Integer agentId, String code) throws WxErrorException { | |||
String responseText = this.mainService.get(String.format(this.mainService.getWxCpConfigStorage().getApiUrl(WxCpOAuth2Service.URL_GET_USER_INFO), code, agentId), null); | |||
String responseText = this.mainService.get(String.format(this.mainService.getWxCpConfigStorage().getApiUrl(GET_USER_INFO), code, agentId), null); | |||
JsonElement je = new JsonParser().parse(responseText); | |||
JsonObject jo = je.getAsJsonObject(); | |||
@@ -86,7 +90,7 @@ public class WxCpOAuth2ServiceImpl implements WxCpOAuth2Service { | |||
public WxCpUserDetail getUserDetail(String userTicket) throws WxErrorException { | |||
JsonObject param = new JsonObject(); | |||
param.addProperty("user_ticket", userTicket); | |||
String responseText = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(WxCpOAuth2Service.URL_GET_USER_DETAIL), param.toString()); | |||
String responseText = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(GET_USER_DETAIL), param.toString()); | |||
return WxCpGsonBuilder.create().fromJson(responseText, WxCpUserDetail.class); | |||
} | |||
} |
@@ -5,6 +5,7 @@ import com.google.gson.JsonElement; | |||
import com.google.gson.JsonObject; | |||
import com.google.gson.JsonParser; | |||
import com.google.gson.reflect.TypeToken; | |||
import lombok.RequiredArgsConstructor; | |||
import me.chanjar.weixin.common.error.WxErrorException; | |||
import me.chanjar.weixin.cp.api.WxCpOaService; | |||
import me.chanjar.weixin.cp.api.WxCpService; | |||
@@ -12,25 +13,25 @@ import me.chanjar.weixin.cp.bean.WxCpApprovalDataResult; | |||
import me.chanjar.weixin.cp.bean.WxCpCheckinData; | |||
import me.chanjar.weixin.cp.bean.WxCpCheckinOption; | |||
import me.chanjar.weixin.cp.bean.WxCpDialRecord; | |||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | |||
import java.util.Date; | |||
import java.util.List; | |||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*; | |||
/** | |||
* @author Element | |||
* @date 2019-04-06 11:20 | |||
*/ | |||
@RequiredArgsConstructor | |||
public class WxCpOaServiceImpl implements WxCpOaService { | |||
private WxCpService mainService; | |||
public WxCpOaServiceImpl(WxCpService mainService) { | |||
this.mainService = mainService; | |||
} | |||
private final WxCpService mainService; | |||
@Override | |||
public List<WxCpCheckinData> getCheckinData(Integer openCheckinDataType, Date startTime, Date endTime, List<String> userIdList) throws WxErrorException { | |||
public List<WxCpCheckinData> getCheckinData(Integer openCheckinDataType, Date startTime, Date endTime, | |||
List<String> userIdList) throws WxErrorException { | |||
if (startTime == null || endTime == null) { | |||
throw new RuntimeException("starttime and endtime can't be null"); | |||
} | |||
@@ -59,7 +60,7 @@ public class WxCpOaServiceImpl implements WxCpOaService { | |||
jsonObject.add("useridlist", jsonArray); | |||
String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(WxCpOaService.GET_CHECKIN_DATA), jsonObject.toString()); | |||
String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(GET_CHECKIN_DATA), jsonObject.toString()); | |||
JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | |||
return WxCpGsonBuilder.create() | |||
.fromJson( | |||
@@ -88,7 +89,7 @@ public class WxCpOaServiceImpl implements WxCpOaService { | |||
jsonObject.addProperty("datetime", datetime.getTime() / 1000L); | |||
jsonObject.add("useridlist", jsonArray); | |||
String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(WxCpOaService.GET_CHECKIN_OPTION), jsonObject.toString()); | |||
String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(GET_CHECKIN_OPTION), jsonObject.toString()); | |||
JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | |||
return WxCpGsonBuilder.create() | |||
@@ -108,7 +109,7 @@ public class WxCpOaServiceImpl implements WxCpOaService { | |||
jsonObject.addProperty("next_spnum", nextSpnum); | |||
} | |||
String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(WxCpOaService.GET_APPROVAL_DATA), jsonObject.toString()); | |||
String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(GET_APPROVAL_DATA), jsonObject.toString()); | |||
return WxCpGsonBuilder.create().fromJson(responseContent, WxCpApprovalDataResult.class); | |||
} | |||
@@ -140,7 +141,7 @@ public class WxCpOaServiceImpl implements WxCpOaService { | |||
jsonObject.addProperty("end_time", endtimestamp); | |||
} | |||
String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(WxCpOaService.GET_DIAL_RECORD), jsonObject.toString()); | |||
String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(GET_DIAL_RECORD), jsonObject.toString()); | |||
JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | |||
return WxCpGsonBuilder.create() | |||
@@ -8,8 +8,8 @@ import me.chanjar.weixin.common.error.WxErrorException; | |||
import me.chanjar.weixin.common.util.http.HttpType; | |||
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; | |||
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; | |||
import me.chanjar.weixin.cp.api.WxCpService; | |||
import me.chanjar.weixin.cp.config.WxCpConfigStorage; | |||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||
import org.apache.http.HttpHost; | |||
import org.apache.http.client.config.RequestConfig; | |||
import org.apache.http.client.methods.CloseableHttpResponse; | |||
@@ -23,8 +23,8 @@ import java.io.IOException; | |||
* @author someone | |||
*/ | |||
public class WxCpServiceApacheHttpClientImpl extends BaseWxCpServiceImpl<CloseableHttpClient, HttpHost> { | |||
protected CloseableHttpClient httpClient; | |||
protected HttpHost httpProxy; | |||
private CloseableHttpClient httpClient; | |||
private HttpHost httpProxy; | |||
@Override | |||
public CloseableHttpClient getRequestHttpClient() { | |||
@@ -48,7 +48,7 @@ public class WxCpServiceApacheHttpClientImpl extends BaseWxCpServiceImpl<Closeab | |||
} | |||
synchronized (this.globalAccessTokenRefreshLock) { | |||
String url = String.format(this.configStorage.getApiUrl(WxCpService.GET_TOKEN), this.configStorage.getCorpId(), this.configStorage.getCorpSecret()); | |||
String url = String.format(this.configStorage.getApiUrl(WxCpApiPathConsts.GET_TOKEN), this.configStorage.getCorpId(), this.configStorage.getCorpSecret()); | |||
try { | |||
HttpGet httpGet = new HttpGet(url); | |||
@@ -10,16 +10,15 @@ import me.chanjar.weixin.common.bean.WxAccessToken; | |||
import me.chanjar.weixin.common.error.WxError; | |||
import me.chanjar.weixin.common.error.WxErrorException; | |||
import me.chanjar.weixin.common.util.http.HttpType; | |||
import me.chanjar.weixin.cp.api.WxCpService; | |||
import me.chanjar.weixin.cp.config.WxCpConfigStorage; | |||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||
/** | |||
* @author someone | |||
*/ | |||
public class WxCpServiceJoddHttpImpl extends BaseWxCpServiceImpl<HttpConnectionProvider, ProxyInfo> { | |||
protected HttpConnectionProvider httpClient; | |||
protected ProxyInfo httpProxy; | |||
private HttpConnectionProvider httpClient; | |||
private ProxyInfo httpProxy; | |||
@Override | |||
public HttpConnectionProvider getRequestHttpClient() { | |||
@@ -43,7 +42,8 @@ public class WxCpServiceJoddHttpImpl extends BaseWxCpServiceImpl<HttpConnectionP | |||
} | |||
synchronized (this.globalAccessTokenRefreshLock) { | |||
HttpRequest request = HttpRequest.get(String.format(this.configStorage.getApiUrl(WxCpService.GET_TOKEN), this.configStorage.getCorpId(), this.configStorage.getCorpSecret())); | |||
HttpRequest request = HttpRequest.get(String.format(this.configStorage.getApiUrl(WxCpApiPathConsts.GET_TOKEN), | |||
this.configStorage.getCorpId(), this.configStorage.getCorpSecret())); | |||
if (this.httpProxy != null) { | |||
httpClient.useProxy(this.httpProxy); | |||
} | |||
@@ -64,7 +64,8 @@ public class WxCpServiceJoddHttpImpl extends BaseWxCpServiceImpl<HttpConnectionP | |||
@Override | |||
public void initHttp() { | |||
if (this.configStorage.getHttpProxyHost() != null && this.configStorage.getHttpProxyPort() > 0) { | |||
httpProxy = new ProxyInfo(ProxyInfo.ProxyType.HTTP, configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword()); | |||
httpProxy = new ProxyInfo(ProxyInfo.ProxyType.HTTP, configStorage.getHttpProxyHost(), | |||
configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword()); | |||
} | |||
httpClient = JoddHttp.httpConnectionProvider; | |||
@@ -1,25 +1,23 @@ | |||
package me.chanjar.weixin.cp.api.impl; | |||
import lombok.extern.slf4j.Slf4j; | |||
import me.chanjar.weixin.common.WxType; | |||
import me.chanjar.weixin.common.bean.WxAccessToken; | |||
import me.chanjar.weixin.common.error.WxError; | |||
import me.chanjar.weixin.common.error.WxErrorException; | |||
import me.chanjar.weixin.common.util.http.HttpType; | |||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; | |||
import me.chanjar.weixin.cp.api.WxCpService; | |||
import me.chanjar.weixin.cp.config.WxCpConfigStorage; | |||
import okhttp3.Authenticator; | |||
import okhttp3.Credentials; | |||
import okhttp3.OkHttpClient; | |||
import okhttp3.Request; | |||
import okhttp3.Response; | |||
import okhttp3.Route; | |||
import okhttp3.*; | |||
import java.io.IOException; | |||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.GET_TOKEN; | |||
/** | |||
* @author someone | |||
*/ | |||
@Slf4j | |||
public class WxCpServiceOkHttpImpl extends BaseWxCpServiceImpl<OkHttpClient, OkHttpProxyInfo> { | |||
private OkHttpClient httpClient; | |||
private OkHttpProxyInfo httpProxy; | |||
@@ -50,7 +48,7 @@ public class WxCpServiceOkHttpImpl extends BaseWxCpServiceImpl<OkHttpClient, OkH | |||
OkHttpClient client = getRequestHttpClient(); | |||
//请求的request | |||
Request request = new Request.Builder() | |||
.url(String.format(this.configStorage.getApiUrl(WxCpService.GET_TOKEN), this.configStorage.getCorpId(), this.configStorage.getCorpSecret())) | |||
.url(String.format(this.configStorage.getApiUrl(GET_TOKEN), this.configStorage.getCorpId(), this.configStorage.getCorpSecret())) | |||
.get() | |||
.build(); | |||
String resultContent = null; | |||
@@ -58,7 +56,7 @@ public class WxCpServiceOkHttpImpl extends BaseWxCpServiceImpl<OkHttpClient, OkH | |||
Response response = client.newCall(request).execute(); | |||
resultContent = response.body().string(); | |||
} catch (IOException e) { | |||
this.log.error(e.getMessage(), e); | |||
log.error(e.getMessage(), e); | |||
} | |||
WxError error = WxError.fromJson(resultContent, WxType.CP); | |||
@@ -74,7 +72,7 @@ public class WxCpServiceOkHttpImpl extends BaseWxCpServiceImpl<OkHttpClient, OkH | |||
@Override | |||
public void initHttp() { | |||
this.log.debug("WxCpServiceOkHttpImpl initHttp"); | |||
log.debug("WxCpServiceOkHttpImpl initHttp"); | |||
//设置代理 | |||
if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) { | |||
httpProxy = OkHttpProxyInfo.httpProxy(configStorage.getHttpProxyHost(), | |||
@@ -1,37 +1,33 @@ | |||
package me.chanjar.weixin.cp.api.impl; | |||
import me.chanjar.weixin.common.bean.WxAccessToken; | |||
import me.chanjar.weixin.common.error.WxErrorException; | |||
import me.chanjar.weixin.cp.api.WxCpTpService; | |||
/** | |||
* <pre> | |||
* 默认接口实现类,使用apache httpclient实现,配合第三方应用service使用 | |||
* Created by zhenjun cai. | |||
* </pre> | |||
* | |||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | |||
*/ | |||
public class WxCpServiceOnTpImpl extends WxCpServiceApacheHttpClientImpl { | |||
//第三方应用service | |||
WxCpTpService wxCpTpService; | |||
public void setWxCpTpService(WxCpTpService wxCpTpService) { | |||
this.wxCpTpService = wxCpTpService; | |||
} | |||
@Override | |||
public String getAccessToken(boolean forceRefresh) throws WxErrorException { | |||
if (!this.configStorage.isAccessTokenExpired() && !forceRefresh) { | |||
return this.configStorage.getAccessToken(); | |||
} | |||
//access token通过第三方应用service获取 | |||
//corpSecret对应企业永久授权码 | |||
WxAccessToken accessToken = wxCpTpService.getCorpToken(this.configStorage.getCorpId(), this.configStorage.getCorpSecret()); | |||
this.configStorage.updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); | |||
return this.configStorage.getAccessToken(); | |||
} | |||
} | |||
package me.chanjar.weixin.cp.api.impl; | |||
import lombok.RequiredArgsConstructor; | |||
import me.chanjar.weixin.common.bean.WxAccessToken; | |||
import me.chanjar.weixin.common.error.WxErrorException; | |||
import me.chanjar.weixin.cp.api.WxCpTpService; | |||
/** | |||
* <pre> | |||
* 默认接口实现类,使用apache httpclient实现,配合第三方应用service使用 | |||
* Created by zhenjun cai. | |||
* </pre> | |||
* | |||
* @author zhenjun cai | |||
*/ | |||
@RequiredArgsConstructor | |||
public class WxCpServiceOnTpImpl extends WxCpServiceApacheHttpClientImpl { | |||
private final WxCpTpService wxCpTpService; | |||
@Override | |||
public String getAccessToken(boolean forceRefresh) throws WxErrorException { | |||
if (!this.configStorage.isAccessTokenExpired() && !forceRefresh) { | |||
return this.configStorage.getAccessToken(); | |||
} | |||
//access token通过第三方应用service获取 | |||
//corpSecret对应企业永久授权码 | |||
WxAccessToken accessToken = wxCpTpService.getCorpToken(this.configStorage.getCorpId(), this.configStorage.getCorpSecret()); | |||
this.configStorage.updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); | |||
return this.configStorage.getAccessToken(); | |||
} | |||
} |
@@ -1,11 +1,8 @@ | |||
package me.chanjar.weixin.cp.api.impl; | |||
import com.google.gson.JsonArray; | |||
import com.google.gson.JsonElement; | |||
import com.google.gson.JsonObject; | |||
import com.google.gson.JsonParser; | |||
import com.google.gson.JsonPrimitive; | |||
import com.google.gson.*; | |||
import com.google.gson.reflect.TypeToken; | |||
import lombok.RequiredArgsConstructor; | |||
import me.chanjar.weixin.common.error.WxErrorException; | |||
import me.chanjar.weixin.cp.api.WxCpService; | |||
import me.chanjar.weixin.cp.api.WxCpTagService; | |||
@@ -13,10 +10,15 @@ import me.chanjar.weixin.cp.bean.WxCpTag; | |||
import me.chanjar.weixin.cp.bean.WxCpTagAddOrRemoveUsersResult; | |||
import me.chanjar.weixin.cp.bean.WxCpTagGetResult; | |||
import me.chanjar.weixin.cp.bean.WxCpUser; | |||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | |||
import java.util.List; | |||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tag.*; | |||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tag.TAG_CREATE; | |||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tag.TAG_UPDATE; | |||
/** | |||
* <pre> | |||
* 标签管理接口. | |||
@@ -25,18 +27,15 @@ import java.util.List; | |||
* | |||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | |||
*/ | |||
@RequiredArgsConstructor | |||
public class WxCpTagServiceImpl implements WxCpTagService { | |||
private WxCpService mainService; | |||
public WxCpTagServiceImpl(WxCpService mainService) { | |||
this.mainService = mainService; | |||
} | |||
private final WxCpService mainService; | |||
@Override | |||
public String create(String tagName) throws WxErrorException { | |||
JsonObject o = new JsonObject(); | |||
o.addProperty("tagname", tagName); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpTagService.TAG_CREATE); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(TAG_CREATE); | |||
String responseContent = this.mainService.post(url, o.toString()); | |||
JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | |||
return tmpJsonElement.getAsJsonObject().get("tagid").getAsString(); | |||
@@ -44,7 +43,7 @@ public class WxCpTagServiceImpl implements WxCpTagService { | |||
@Override | |||
public void update(String tagId, String tagName) throws WxErrorException { | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpTagService.TAG_UPDATE); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(TAG_UPDATE); | |||
JsonObject o = new JsonObject(); | |||
o.addProperty("tagid", tagId); | |||
o.addProperty("tagname", tagName); | |||
@@ -53,13 +52,13 @@ public class WxCpTagServiceImpl implements WxCpTagService { | |||
@Override | |||
public void delete(String tagId) throws WxErrorException { | |||
String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(WxCpTagService.TAG_DELETE), tagId); | |||
String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(TAG_DELETE), tagId); | |||
this.mainService.get(url, null); | |||
} | |||
@Override | |||
public List<WxCpTag> listAll() throws WxErrorException { | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpTagService.TAG_LIST); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(TAG_LIST); | |||
String responseContent = this.mainService.get(url, null); | |||
JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | |||
return WxCpGsonBuilder.create() | |||
@@ -72,7 +71,7 @@ public class WxCpTagServiceImpl implements WxCpTagService { | |||
@Override | |||
public List<WxCpUser> listUsersByTagId(String tagId) throws WxErrorException { | |||
String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(WxCpTagService.TAG_GET), tagId); | |||
String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(TAG_GET), tagId); | |||
String responseContent = this.mainService.get(url, null); | |||
JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | |||
return WxCpGsonBuilder.create() | |||
@@ -85,7 +84,7 @@ public class WxCpTagServiceImpl implements WxCpTagService { | |||
@Override | |||
public WxCpTagAddOrRemoveUsersResult addUsers2Tag(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException { | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpTagService.TAG_ADDTAGUSERS); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(TAG_ADD_TAG_USERS); | |||
JsonObject jsonObject = new JsonObject(); | |||
jsonObject.addProperty("tagid", tagId); | |||
this.addUserIdsAndPartyIdsToJson(userIds, partyIds, jsonObject); | |||
@@ -95,7 +94,7 @@ public class WxCpTagServiceImpl implements WxCpTagService { | |||
@Override | |||
public WxCpTagAddOrRemoveUsersResult removeUsersFromTag(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException { | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpTagService.TAG_DELTAGUSERS); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(TAG_DEL_TAG_USERS); | |||
JsonObject jsonObject = new JsonObject(); | |||
jsonObject.addProperty("tagid", tagId); | |||
this.addUserIdsAndPartyIdsToJson(userIds, partyIds, jsonObject); | |||
@@ -127,7 +126,7 @@ public class WxCpTagServiceImpl implements WxCpTagService { | |||
throw new IllegalArgumentException("缺少tagId参数"); | |||
} | |||
String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(WxCpTagService.TAG_GET), tagId); | |||
String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(TAG_GET), tagId); | |||
String responseContent = this.mainService.get(url, null); | |||
return WxCpTagGetResult.fromJson(responseContent); | |||
} | |||
@@ -3,14 +3,16 @@ package me.chanjar.weixin.cp.api.impl; | |||
import lombok.RequiredArgsConstructor; | |||
import me.chanjar.weixin.common.error.WxErrorException; | |||
import me.chanjar.weixin.common.util.json.WxGsonBuilder; | |||
import me.chanjar.weixin.cp.WxCpConsts; | |||
import me.chanjar.weixin.cp.api.WxCpService; | |||
import me.chanjar.weixin.cp.api.WxCpTaskCardService; | |||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.TaskCard.*; | |||
/** | |||
* <pre> | |||
* 任务卡片管理接口. | |||
@@ -34,7 +36,7 @@ public class WxCpTaskCardServiceImpl implements WxCpTaskCardService { | |||
data.put("task_id", taskId); | |||
data.put("clicked_key", clickedKey); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(MESSAGE_UPDATE_TASKCARD); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_TASK_CARD); | |||
this.mainService.post(url, WxGsonBuilder.create().toJson(data)); | |||
} | |||
} |
@@ -9,8 +9,8 @@ import me.chanjar.weixin.common.error.WxErrorException; | |||
import me.chanjar.weixin.common.util.http.HttpType; | |||
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; | |||
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; | |||
import me.chanjar.weixin.cp.api.WxCpTpService; | |||
import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; | |||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||
import org.apache.http.Consts; | |||
import org.apache.http.HttpHost; | |||
import org.apache.http.client.config.RequestConfig; | |||
@@ -52,7 +52,7 @@ public class WxCpTpServiceApacheHttpClientImpl extends BaseWxCpTpServiceImpl<Clo | |||
synchronized (this.globalSuiteAccessTokenRefreshLock) { | |||
try { | |||
HttpPost httpPost = new HttpPost(configStorage.getApiUrl(WxCpTpService.GET_SUITE_TOKEN)); | |||
HttpPost httpPost = new HttpPost(configStorage.getApiUrl(WxCpApiPathConsts.Tp.GET_SUITE_TOKEN)); | |||
if (this.httpProxy != null) { | |||
RequestConfig config = RequestConfig.custom() | |||
.setProxy(this.httpProxy).build(); | |||
@@ -1,12 +1,12 @@ | |||
package me.chanjar.weixin.cp.api.impl; | |||
/** | |||
* <pre> | |||
* 默认接口实现类,使用apache httpclient实现 | |||
* Created by zhenjun cai. | |||
* </pre> | |||
* | |||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | |||
*/ | |||
public class WxCpTpServiceImpl extends WxCpTpServiceApacheHttpClientImpl { | |||
} | |||
package me.chanjar.weixin.cp.api.impl; | |||
/** | |||
* <pre> | |||
* 默认接口实现类,使用apache httpclient实现 | |||
* Created by zhenjun cai. | |||
* </pre> | |||
* | |||
* @author zhenjun cai | |||
*/ | |||
public class WxCpTpServiceImpl extends WxCpTpServiceApacheHttpClientImpl { | |||
} |
@@ -1,24 +1,23 @@ | |||
package me.chanjar.weixin.cp.api.impl; | |||
import com.google.common.collect.Maps; | |||
import com.google.gson.JsonArray; | |||
import com.google.gson.JsonElement; | |||
import com.google.gson.JsonObject; | |||
import com.google.gson.JsonParser; | |||
import com.google.gson.JsonPrimitive; | |||
import com.google.gson.*; | |||
import com.google.gson.reflect.TypeToken; | |||
import lombok.RequiredArgsConstructor; | |||
import me.chanjar.weixin.common.error.WxErrorException; | |||
import me.chanjar.weixin.cp.WxCpConsts; | |||
import me.chanjar.weixin.cp.api.WxCpService; | |||
import me.chanjar.weixin.cp.api.WxCpUserService; | |||
import me.chanjar.weixin.cp.bean.WxCpInviteResult; | |||
import me.chanjar.weixin.cp.bean.WxCpUser; | |||
import me.chanjar.weixin.cp.bean.WxCpUserExternalContactInfo; | |||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | |||
import java.util.List; | |||
import java.util.Map; | |||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.User.*; | |||
/** | |||
* <pre> | |||
* Created by BinaryWang on 2017/6/24. | |||
@@ -26,34 +25,31 @@ import java.util.Map; | |||
* | |||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | |||
*/ | |||
@RequiredArgsConstructor | |||
public class WxCpUserServiceImpl implements WxCpUserService { | |||
private final WxCpService mainService; | |||
public WxCpUserServiceImpl(WxCpService mainService) { | |||
this.mainService = mainService; | |||
} | |||
@Override | |||
public void authenticate(String userId) throws WxErrorException { | |||
this.mainService.get(this.mainService.getWxCpConfigStorage().getApiUrl(WxCpUserService.URL_AUTHENTICATE + userId), null); | |||
this.mainService.get(this.mainService.getWxCpConfigStorage().getApiUrl(USER_AUTHENTICATE + userId), null); | |||
} | |||
@Override | |||
public void create(WxCpUser user) throws WxErrorException { | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpUserService.URL_USER_CREATE); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(USER_CREATE); | |||
this.mainService.post(url, user.toJson()); | |||
} | |||
@Override | |||
public void update(WxCpUser user) throws WxErrorException { | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpUserService.URL_USER_UPDATE); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(USER_UPDATE); | |||
this.mainService.post(url, user.toJson()); | |||
} | |||
@Override | |||
public void delete(String... userIds) throws WxErrorException { | |||
if (userIds.length == 1) { | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpUserService.URL_USER_DELETE + userIds[0]); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(USER_DELETE + userIds[0]); | |||
this.mainService.get(url, null); | |||
return; | |||
} | |||
@@ -65,12 +61,12 @@ public class WxCpUserServiceImpl implements WxCpUserService { | |||
} | |||
jsonObject.add("useridlist", jsonArray); | |||
this.mainService.post(WxCpUserService.URL_USER_BATCH_DELETE, jsonObject.toString()); | |||
this.mainService.post(USER_BATCH_DELETE, jsonObject.toString()); | |||
} | |||
@Override | |||
public WxCpUser getById(String userid) throws WxErrorException { | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpUserService.URL_USER_GET + userid); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(USER_GET + userid); | |||
String responseContent = this.mainService.get(url, null); | |||
return WxCpUser.fromJson(responseContent); | |||
} | |||
@@ -87,7 +83,7 @@ public class WxCpUserServiceImpl implements WxCpUserService { | |||
params += "&status=0"; | |||
} | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpUserService.URL_USER_LIST + departId); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(USER_LIST + departId); | |||
String responseContent = this.mainService.get(url, params); | |||
JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | |||
return WxCpGsonBuilder.create() | |||
@@ -109,7 +105,7 @@ public class WxCpUserServiceImpl implements WxCpUserService { | |||
params += "&status=0"; | |||
} | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpUserService.URL_USER_SIMPLE_LIST + departId); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(USER_SIMPLE_LIST + departId); | |||
String responseContent = this.mainService.get(url, params); | |||
JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | |||
return WxCpGsonBuilder.create() | |||
@@ -147,13 +143,13 @@ public class WxCpUserServiceImpl implements WxCpUserService { | |||
jsonObject.add("tag", jsonArray); | |||
} | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpUserService.URL_BATCH_INVITE); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(BATCH_INVITE); | |||
return WxCpInviteResult.fromJson(this.mainService.post(url, jsonObject.toString())); | |||
} | |||
@Override | |||
public Map<String, String> userId2Openid(String userId, Integer agentId) throws WxErrorException { | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpUserService.URL_CONVERT_TO_OPENID); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(USER_CONVERT_TO_OPENID); | |||
JsonObject jsonObject = new JsonObject(); | |||
jsonObject.addProperty("userid", userId); | |||
if (agentId != null) { | |||
@@ -178,7 +174,7 @@ public class WxCpUserServiceImpl implements WxCpUserService { | |||
public String openid2UserId(String openid) throws WxErrorException { | |||
JsonObject jsonObject = new JsonObject(); | |||
jsonObject.addProperty("openid", openid); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpUserService.URL_CONVERT_TO_USERID); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(USER_CONVERT_TO_USERID); | |||
String responseContent = this.mainService.post(url, jsonObject.toString()); | |||
JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | |||
return tmpJsonElement.getAsJsonObject().get("userid").getAsString(); | |||
@@ -186,7 +182,7 @@ public class WxCpUserServiceImpl implements WxCpUserService { | |||
@Override | |||
public WxCpUserExternalContactInfo getExternalContact(String userId) throws WxErrorException { | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(WxCpUserService.URL_GET_EXTERNAL_CONTACT + userId); | |||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_EXTERNAL_CONTACT + userId); | |||
String responseContent = this.mainService.get(url, null); | |||
return WxCpUserExternalContactInfo.fromJson(responseContent); | |||
} | |||
@@ -6,7 +6,7 @@ import lombok.AllArgsConstructor; | |||
import lombok.Builder; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import me.chanjar.weixin.cp.WxCpConsts.AppChatMsgType; | |||
import me.chanjar.weixin.cp.constant.WxCpConsts.AppChatMsgType; | |||
import me.chanjar.weixin.cp.bean.article.MpnewsArticle; | |||
import me.chanjar.weixin.cp.bean.article.NewArticle; | |||
@@ -162,7 +162,7 @@ public class WxCpXmlMessage implements Serializable { | |||
/** | |||
* 通讯录变更事件. | |||
* 请参考常量 me.chanjar.weixin.cp.WxCpConsts.ContactChangeType | |||
* 请参考常量 me.chanjar.weixin.cp.constant.WxCpConsts.ContactChangeType | |||
*/ | |||
@XStreamAlias("ChangeType") | |||
@XStreamConverter(value = XStreamCDataConverter.class) | |||
@@ -6,7 +6,7 @@ import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; | |||
import java.io.File; | |||
/** | |||
* 微信客户端配置存储 | |||
* 微信客户端配置存储. | |||
* | |||
* @author Daniel Qian | |||
*/ | |||
@@ -14,7 +14,6 @@ public interface WxCpConfigStorage { | |||
/** | |||
* 设置企业微信服务器 baseUrl. | |||
* | |||
* 默认值是 https://qyapi.weixin.qq.com , 如果使用默认值,则不需要调用 setBaseApiUrl | |||
* | |||
* @param baseUrl 企业微信服务器 Url | |||
@@ -23,7 +22,6 @@ public interface WxCpConfigStorage { | |||
/** | |||
* 读取企业微信 API Url. | |||
* | |||
* 支持私有化企业微信服务器. | |||
*/ | |||
String getApiUrl(String path); | |||
@@ -33,7 +31,7 @@ public interface WxCpConfigStorage { | |||
boolean isAccessTokenExpired(); | |||
/** | |||
* 强制将access token过期掉 | |||
* 强制将access token过期掉. | |||
*/ | |||
void expireAccessToken(); | |||
@@ -46,12 +44,12 @@ public interface WxCpConfigStorage { | |||
boolean isJsapiTicketExpired(); | |||
/** | |||
* 强制将jsapi ticket过期掉 | |||
* 强制将jsapi ticket过期掉. | |||
*/ | |||
void expireJsapiTicket(); | |||
/** | |||
* 应该是线程安全的 | |||
* 应该是线程安全的. | |||
*/ | |||
void updateJsapiTicket(String jsapiTicket, int expiresInSeconds); | |||
@@ -60,12 +58,12 @@ public interface WxCpConfigStorage { | |||
boolean isAgentJsapiTicketExpired(); | |||
/** | |||
* 强制将jsapi ticket过期掉 | |||
* 强制将jsapi ticket过期掉. | |||
*/ | |||
void expireAgentJsapiTicket(); | |||
/** | |||
* 应该是线程安全的 | |||
* 应该是线程安全的. | |||
*/ | |||
void updateAgentJsapiTicket(String jsapiTicket, int expiresInSeconds); | |||
@@ -94,7 +92,7 @@ public interface WxCpConfigStorage { | |||
File getTmpDirFile(); | |||
/** | |||
* http client builder | |||
* http client builder. | |||
* | |||
* @return ApacheHttpClientBuilder | |||
*/ | |||
@@ -2,6 +2,7 @@ package me.chanjar.weixin.cp.config; | |||
import me.chanjar.weixin.common.bean.WxAccessToken; | |||
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; | |||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | |||
import java.io.File; | |||
@@ -12,7 +13,6 @@ import java.io.File; | |||
* @author Daniel Qian | |||
*/ | |||
public class WxCpInMemoryConfigStorage implements WxCpConfigStorage { | |||
protected volatile String corpId; | |||
protected volatile String corpSecret; | |||
@@ -49,7 +49,7 @@ public class WxCpInMemoryConfigStorage implements WxCpConfigStorage { | |||
@Override | |||
public String getApiUrl(String path) { | |||
if (baseApiUrl == null) { | |||
baseApiUrl = "https://qyapi.weixin.qq.com"; | |||
baseApiUrl = WxCpApiPathConsts.DEFAULT_CP_BASE_URL; | |||
} | |||
return baseApiUrl + path; | |||
} | |||
@@ -2,6 +2,7 @@ package me.chanjar.weixin.cp.config; | |||
import me.chanjar.weixin.common.bean.WxAccessToken; | |||
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; | |||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||
import redis.clients.jedis.Jedis; | |||
import redis.clients.jedis.JedisPool; | |||
import redis.clients.jedis.JedisPoolConfig; | |||
@@ -48,7 +49,7 @@ public class WxCpJedisConfigStorage implements WxCpConfigStorage { | |||
@Override | |||
public String getApiUrl(String path) { | |||
if (baseApiUrl == null) { | |||
baseApiUrl = "https://qyapi.weixin.qq.com"; | |||
baseApiUrl = WxCpApiPathConsts.DEFAULT_CP_BASE_URL; | |||
} | |||
return baseApiUrl + path; | |||
} | |||
@@ -0,0 +1,106 @@ | |||
package me.chanjar.weixin.cp.constant; | |||
/** | |||
* <pre> | |||
* 企业微信api地址常量类 | |||
* Created by BinaryWang on 2019-06-02. | |||
* </pre> | |||
* | |||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | |||
*/ | |||
public final class WxCpApiPathConsts { | |||
public static final String DEFAULT_CP_BASE_URL = "https://qyapi.weixin.qq.com"; | |||
public static final String GET_JSAPI_TICKET = "/cgi-bin/get_jsapi_ticket"; | |||
public static final String GET_AGENT_CONFIG_TICKET = "/cgi-bin/ticket/get?&type=agent_config"; | |||
public static final String MESSAGE_SEND = "/cgi-bin/message/send"; | |||
public static final String GET_CALLBACK_IP = "/cgi-bin/getcallbackip"; | |||
public static final String BATCH_REPLACE_PARTY = "/cgi-bin/batch/replaceparty"; | |||
public static final String BATCH_REPLACE_USER = "/cgi-bin/batch/replaceuser"; | |||
public static final String BATCH_GET_RESULT = "/cgi-bin/batch/getresult?jobid="; | |||
public static final String JSCODE_TO_SESSION = "/cgi-bin/miniprogram/jscode2session"; | |||
public static final String GET_TOKEN = "/cgi-bin/gettoken?&corpid=%s&corpsecret=%s"; | |||
public static class Agent { | |||
public static final String AGENT_GET = "/cgi-bin/agent/get?agentid=%d"; | |||
public static final String AGENT_SET = "/cgi-bin/agent/set"; | |||
public static final String AGENT_LIST = "/cgi-bin/agent/list"; | |||
} | |||
public static class OAuth2 { | |||
public static final String GET_USER_INFO = "/cgi-bin/user/getuserinfo?code=%s&agentid=%d"; | |||
public static final String GET_USER_DETAIL = "/cgi-bin/user/getuserdetail"; | |||
public static final String URL_OAUTH2_AUTHORIZE = "https://open.weixin.qq.com/connect/oauth2/authorize"; | |||
} | |||
public static class Chat { | |||
public static final String APPCHAT_CREATE = "/cgi-bin/appchat/create"; | |||
public static final String APPCHAT_UPDATE = "/cgi-bin/appchat/update"; | |||
public static final String APPCHAT_GET_CHATID = "/cgi-bin/appchat/get?chatid="; | |||
public static final String APPCHAT_SEND = "/cgi-bin/appchat/send"; | |||
} | |||
public static class Department { | |||
public static final String DEPARTMENT_CREATE = "/cgi-bin/department/create"; | |||
public static final String DEPARTMENT_UPDATE = "/cgi-bin/department/update"; | |||
public static final String DEPARTMENT_DELETE = "/cgi-bin/department/delete?id=%d"; | |||
public static final String DEPARTMENT_LIST = "/cgi-bin/department/list"; | |||
} | |||
public static class Media { | |||
public static final String MEDIA_GET = "/cgi-bin/media/get"; | |||
public static final String MEDIA_UPLOAD = "/cgi-bin/media/upload?type="; | |||
public static final String IMG_UPLOAD = "/cgi-bin/media/uploadimg"; | |||
public static final String JSSDK_MEDIA_GET = "/cgi-bin/media/get/jssdk"; | |||
} | |||
public static class Menu { | |||
public static final String MENU_CREATE = "/cgi-bin/menu/create?agentid=%d"; | |||
public static final String MENU_DELETE = "/cgi-bin/menu/delete?agentid=%d"; | |||
public static final String MENU_GET = "/cgi-bin/menu/get?agentid=%d"; | |||
} | |||
public static class Oa { | |||
public static final String GET_CHECKIN_DATA = "/cgi-bin/checkin/getcheckindata"; | |||
public static final String GET_CHECKIN_OPTION = "/cgi-bin/checkin/getcheckinoption"; | |||
public static final String GET_APPROVAL_DATA = "/cgi-bin/corp/getapprovaldata"; | |||
public static final String GET_DIAL_RECORD = "/cgi-bin/dial/get_dial_record"; | |||
} | |||
public static class Tag { | |||
public static final String TAG_CREATE = "/cgi-bin/tag/create"; | |||
public static final String TAG_UPDATE = "/cgi-bin/tag/update"; | |||
public static final String TAG_DELETE = "/cgi-bin/tag/delete?tagid=%s"; | |||
public static final String TAG_LIST = "/cgi-bin/tag/list"; | |||
public static final String TAG_GET = "/cgi-bin/tag/get?tagid=%s"; | |||
public static final String TAG_ADD_TAG_USERS = "/cgi-bin/tag/addtagusers"; | |||
public static final String TAG_DEL_TAG_USERS = "/cgi-bin/tag/deltagusers"; | |||
} | |||
public static class TaskCard { | |||
public static final String UPDATE_TASK_CARD = "/cgi-bin/message/update_taskcard"; | |||
} | |||
public static class Tp { | |||
public static final String JSCODE_TO_SESSION = "/cgi-bin/service/miniprogram/jscode2session"; | |||
public static final String GET_CORP_TOKEN = "/cgi-bin/service/get_corp_token"; | |||
public static final String GET_PERMANENT_CODE = "/cgi-bin/service/get_permanent_code"; | |||
public static final String GET_SUITE_TOKEN = "/cgi-bin/service/get_suite_token"; | |||
} | |||
public static class User { | |||
public static final String USER_AUTHENTICATE = "/cgi-bin/user/authsucc?userid="; | |||
public static final String USER_CREATE = "/cgi-bin/user/create"; | |||
public static final String USER_UPDATE = "/cgi-bin/user/update"; | |||
public static final String USER_DELETE = "/cgi-bin/user/delete?userid="; | |||
public static final String USER_BATCH_DELETE = "/cgi-bin/user/batchdelete"; | |||
public static final String USER_GET = "/cgi-bin/user/get?userid="; | |||
public static final String USER_LIST = "/cgi-bin/user/list?department_id="; | |||
public static final String USER_SIMPLE_LIST = "/cgi-bin/user/simplelist?department_id="; | |||
public static final String BATCH_INVITE = "/cgi-bin/batch/invite"; | |||
public static final String USER_CONVERT_TO_OPENID = "/cgi-bin/user/convert_to_openid"; | |||
public static final String USER_CONVERT_TO_USERID = "/cgi-bin/user/convert_to_userid"; | |||
public static final String GET_EXTERNAL_CONTACT = "/cgi-bin/crm/get_external_contact?external_userid="; | |||
} | |||
} |
@@ -1,4 +1,4 @@ | |||
package me.chanjar.weixin.cp; | |||
package me.chanjar.weixin.cp.constant; | |||
/** | |||
* <pre> |
@@ -2,11 +2,11 @@ package me.chanjar.weixin.cp.api.impl; | |||
import com.google.inject.Inject; | |||
import me.chanjar.weixin.common.error.WxErrorException; | |||
import me.chanjar.weixin.cp.WxCpConsts; | |||
import me.chanjar.weixin.cp.api.ApiTestModule; | |||
import me.chanjar.weixin.cp.api.WxCpAgentService; | |||
import me.chanjar.weixin.cp.api.WxCpService; | |||
import me.chanjar.weixin.cp.bean.WxCpAgent; | |||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||
import org.testng.annotations.Guice; | |||
import org.testng.annotations.Test; | |||
@@ -70,7 +70,7 @@ public class WxCpAgentServiceImplTest { | |||
@Test | |||
public void testGet() throws Exception { | |||
String returnJson = "{\"errcode\": 0,\"errmsg\": \"ok\",\"agentid\": 9,\"name\": \"测试应用\",\"square_logo_url\": \"http://wx.qlogo.cn/mmhead/alksjf;lasdjf;lasjfuodiuj3rj2o34j/0\",\"description\": \"这是一个企业号应用\",\"allow_userinfos\": {\"user\": [{\"userid\": \"0009854\"}, {\"userid\": \"1723\"}, {\"userid\": \"5625\"}]},\"allow_partys\": {\"partyid\": [42762742]},\"allow_tags\": {\"tagid\": [23, 22, 35, 19, 32, 125, 133, 46, 150, 38, 183, 9, 7]},\"close\": 0,\"redirect_domain\": \"weixin.com.cn\",\"report_location_flag\": 0,\"isreportenter\": 0,\"home_url\": \"\"}"; | |||
when(wxService.get(String.format(wxService.getWxCpConfigStorage().getApiUrl(WxCpAgentService.GET_AGENT), 9), null)).thenReturn(returnJson); | |||
when(wxService.get(String.format(wxService.getWxCpConfigStorage().getApiUrl(WxCpApiPathConsts.Agent.AGENT_GET), 9), null)).thenReturn(returnJson); | |||
when(wxService.getAgentService()).thenReturn(new WxCpAgentServiceImpl(wxService)); | |||
WxCpAgentService wxAgentService = this.wxService.getAgentService(); | |||
@@ -8,7 +8,7 @@ import org.testng.annotations.*; | |||
import com.google.common.collect.Lists; | |||
import com.google.inject.Inject; | |||
import me.chanjar.weixin.common.error.WxErrorException; | |||
import me.chanjar.weixin.cp.WxCpConsts.AppChatMsgType; | |||
import me.chanjar.weixin.cp.constant.WxCpConsts.AppChatMsgType; | |||
import me.chanjar.weixin.cp.api.ApiTestModule; | |||
import me.chanjar.weixin.cp.api.WxCpService; | |||
import me.chanjar.weixin.cp.bean.WxCpAppChatMessage; | |||
@@ -10,6 +10,7 @@ import me.chanjar.weixin.cp.bean.WxCpTag; | |||
import me.chanjar.weixin.cp.bean.WxCpTagAddOrRemoveUsersResult; | |||
import me.chanjar.weixin.cp.bean.WxCpTagGetResult; | |||
import me.chanjar.weixin.cp.bean.WxCpUser; | |||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||
import org.testng.annotations.Guice; | |||
import org.testng.annotations.Test; | |||
@@ -82,7 +83,7 @@ public class WxCpTagServiceImplTest { | |||
public void testGet() throws WxErrorException { | |||
String apiResultJson = "{\"errcode\": 0,\"errmsg\": \"ok\",\"userlist\": [{\"userid\": \"0124035\",\"name\": \"王五\"},{\"userid\": \"0114035\",\"name\": \"梦雪\"}],\"partylist\": [9576,9567,9566],\"tagname\": \"测试标签-001\"}"; | |||
WxCpService wxService = mock(WxCpService.class); | |||
when(wxService.get(String.format(wxService.getWxCpConfigStorage().getApiUrl(WxCpTagService.TAG_GET), 150), null)).thenReturn(apiResultJson); | |||
when(wxService.get(String.format(wxService.getWxCpConfigStorage().getApiUrl(WxCpApiPathConsts.Tag.TAG_GET), 150), null)).thenReturn(apiResultJson); | |||
when(wxService.getTagService()).thenReturn(new WxCpTagServiceImpl(wxService)); | |||
WxCpTagService wxCpTagService = wxService.getTagService(); | |||
@@ -3,7 +3,7 @@ package me.chanjar.weixin.cp.bean; | |||
import me.chanjar.weixin.common.api.WxConsts; | |||
import org.testng.annotations.Test; | |||
import static me.chanjar.weixin.cp.WxCpConsts.EventType.TASKCARD_CLICK; | |||
import static me.chanjar.weixin.cp.constant.WxCpConsts.EventType.TASKCARD_CLICK; | |||
import static org.testng.Assert.assertEquals; | |||
import static org.testng.Assert.assertNotNull; | |||
@@ -10,7 +10,7 @@ import org.eclipse.jetty.servlet.ServletHolder; | |||
import me.chanjar.weixin.common.error.WxErrorException; | |||
import me.chanjar.weixin.common.session.WxSessionManager; | |||
import me.chanjar.weixin.cp.WxCpConsts; | |||
import me.chanjar.weixin.cp.constant.WxCpConsts; | |||
import me.chanjar.weixin.cp.api.WxCpService; | |||
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; | |||
import me.chanjar.weixin.cp.bean.WxCpXmlMessage; | |||