#367 增加对api调用次数清零的接口

This commit is contained in:
Binary Wang 2017-11-22 23:15:18 +08:00
parent 81ebe1a085
commit 20825922ce
3 changed files with 32 additions and 125 deletions

View File

@ -5,8 +5,11 @@ import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestExecutor; import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp; import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.mp.bean.*; import me.chanjar.weixin.mp.bean.WxMpSemanticQuery;
import me.chanjar.weixin.mp.bean.result.*; import me.chanjar.weixin.mp.bean.result.WxMpCurrentAutoReplyInfo;
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
/** /**
* 微信API的Service * 微信API的Service
@ -62,6 +65,11 @@ public interface WxMpService {
*/ */
String GET_CURRENT_AUTOREPLY_INFO_URL = "https://api.weixin.qq.com/cgi-bin/get_current_autoreply_info"; String GET_CURRENT_AUTOREPLY_INFO_URL = "https://api.weixin.qq.com/cgi-bin/get_current_autoreply_info";
/**
* 公众号调用或第三方平台帮公众号调用对公众号的所有api调用包括第三方帮其调用次数进行清零
*/
String CLEAR_QUOTA_URL = "https://api.weixin.qq.com/cgi-bin/clear_quota";
/** /**
* <pre> * <pre>
* 验证消息的确来自微信服务器 * 验证消息的确来自微信服务器
@ -219,6 +227,18 @@ public interface WxMpService {
*/ */
WxMpCurrentAutoReplyInfo getCurrentAutoReplyInfo() throws WxErrorException; WxMpCurrentAutoReplyInfo getCurrentAutoReplyInfo() throws WxErrorException;
/**
* <pre>
* 公众号调用或第三方平台帮公众号调用对公众号的所有api调用包括第三方帮其调用次数进行清零
* HTTP调用https://api.weixin.qq.com/cgi-bin/clear_quota?access_token=ACCESS_TOKEN
* 接口文档地址https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433744592
*
* </pre>
*
* @param appid 公众号的APPID
*/
void clearQuota(String appid) throws WxErrorException;
/** /**
* 当本Service没有实现某个API的时候可以用这个针对所有微信API中的GET请求 * 当本Service没有实现某个API的时候可以用这个针对所有微信API中的GET请求
*/ */
@ -376,6 +396,7 @@ public interface WxMpService {
/** /**
* 返回群发消息相关接口方法的实现类对象以方便调用其各个接口 * 返回群发消息相关接口方法的实现类对象以方便调用其各个接口
*
* @return WxMpMassMessageService * @return WxMpMassMessageService
*/ */
WxMpMassMessageService getMassMessageService(); WxMpMassMessageService getMassMessageService();

View File

@ -207,6 +207,13 @@ public abstract class WxMpServiceAbstractImpl<H, P> implements WxMpService, Requ
return WxMpCurrentAutoReplyInfo.fromJson(this.get(GET_CURRENT_AUTOREPLY_INFO_URL, null)); return WxMpCurrentAutoReplyInfo.fromJson(this.get(GET_CURRENT_AUTOREPLY_INFO_URL, null));
} }
@Override
public void clearQuota(String appid) throws WxErrorException {
JsonObject o = new JsonObject();
o.addProperty("appid", appid);
this.post(CLEAR_QUOTA_URL, o.toString());
}
@Override @Override
public String get(String url, String queryParam) throws WxErrorException { public String get(String url, String queryParam) throws WxErrorException {
return execute(SimpleGetRequestExecutor.create(this), url, queryParam); return execute(SimpleGetRequestExecutor.create(this), url, queryParam);

View File

@ -15,7 +15,6 @@ import static org.testng.Assert.*;
@Test @Test
@Guice(modules = ApiTestModule.class) @Guice(modules = ApiTestModule.class)
public class WxMpServiceImplTest { public class WxMpServiceImplTest {
@Inject @Inject
private WxMpService wxService; private WxMpService wxService;
@ -28,88 +27,8 @@ public class WxMpServiceImplTest {
} }
@Test @Test
public void testCheckSignature() { public void testClearQuota() throws WxErrorException {
Assert.fail("Not yet implemented"); this.wxService.clearQuota(wxService.getWxMpConfigStorage().getAppId());
}
@Test
public void testGetAccessToken() {
Assert.fail("Not yet implemented");
}
@Test
public void testGetAccessTokenBoolean() {
Assert.fail("Not yet implemented");
}
@Test
public void testGetJsapiTicket() {
Assert.fail("Not yet implemented");
}
@Test
public void testGetJsapiTicketBoolean() {
Assert.fail("Not yet implemented");
}
@Test
public void testCreateJsapiSignature() {
Assert.fail("Not yet implemented");
}
@Test
public void testCustomMessageSend() {
Assert.fail("Not yet implemented");
}
@Test
public void testMassNewsUpload() {
Assert.fail("Not yet implemented");
}
@Test
public void testMassVideoUpload() {
Assert.fail("Not yet implemented");
}
@Test
public void testMassGroupMessageSend() {
Assert.fail("Not yet implemented");
}
@Test
public void testMassOpenIdsMessageSend() {
Assert.fail("Not yet implemented");
}
@Test
public void testMassMessagePreview() {
Assert.fail("Not yet implemented");
}
@Test
public void testShortUrl() {
Assert.fail("Not yet implemented");
}
@Test
public void testSetIndustry() {
Assert.fail("Not yet implemented");
}
@Test
public void testGetIndustry() {
Assert.fail("Not yet implemented");
}
@Test
public void testSemanticQuery() {
Assert.fail("Not yet implemented");
}
@Test
public void testOauth2buildAuthorizationUrl() {
Assert.fail("Not yet implemented");
} }
@Test @Test
@ -121,44 +40,4 @@ public class WxMpServiceImplTest {
System.out.println(qrConnectUrl); System.out.println(qrConnectUrl);
} }
@Test
public void testOauth2getAccessToken() {
Assert.fail("Not yet implemented");
}
@Test
public void testOauth2refreshAccessToken() {
Assert.fail("Not yet implemented");
}
@Test
public void testOauth2getUserInfo() {
Assert.fail("Not yet implemented");
}
@Test
public void testOauth2validateAccessToken() {
Assert.fail("Not yet implemented");
}
@Test
public void testGetCallbackIP() {
Assert.fail("Not yet implemented");
}
@Test
public void testGet() {
Assert.fail("Not yet implemented");
}
@Test
public void testPost() {
Assert.fail("Not yet implemented");
}
@Test
public void testExecute() {
Assert.fail("Not yet implemented");
}
} }