From 10f841c5911a54cccc240a325a1bc646551c940e Mon Sep 17 00:00:00 2001 From: Daniel Qian Date: Sat, 24 Jan 2015 15:03:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E4=B8=8B=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E7=AD=BE=E5=90=8D=EF=BC=8C=E4=BB=A3=E7=A0=81=E6=B4=81?= =?UTF-8?q?=E7=99=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/cp/api/WxCpService.java | 64 +++++++++---------- .../weixin/cp/api/WxCpServiceImpl.java | 42 ++++++------ 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java index c24860d00..f1cadd0e5 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java @@ -33,7 +33,7 @@ public interface WxCpService { * @param data 微信传输过来的数据,有可能是echoStr,有可能是xml消息 * @return */ - public boolean checkSignature(String msgSignature, String timestamp, String nonce, String data); + boolean checkSignature(String msgSignature, String timestamp, String nonce, String data); /** *
@@ -43,7 +43,7 @@ public interface WxCpService {
    *
    * @param userId
    */
-  public void userAuthenticated(String userId) throws WxErrorException;
+  void userAuthenticated(String userId) throws WxErrorException;
 
   /**
    * 获取access_token, 不强制刷新access_token
@@ -51,7 +51,7 @@ public interface WxCpService {
    * @return
    * @throws WxErrorException
    */
-  public String getAccessToken() throws WxErrorException;
+  String getAccessToken() throws WxErrorException;
 
   /**
    * 
@@ -65,7 +65,7 @@ public interface WxCpService {
    * @return
    * @throws me.chanjar.weixin.common.exception.WxErrorException
    */
-  public String getAccessToken(boolean forceRefresh) throws WxErrorException;
+  String getAccessToken(boolean forceRefresh) throws WxErrorException;
 
   /**
    * 
@@ -83,7 +83,7 @@ public interface WxCpService {
    * @param inputStream 输入流
    * @throws WxErrorException
    */
-  public WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream)
+  WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream)
       throws WxErrorException, IOException;
 
   /**
@@ -92,7 +92,7 @@ public interface WxCpService {
    * @throws WxErrorException
    * @see #mediaUpload(String, String, InputStream)
    */
-  public WxMediaUploadResult mediaUpload(String mediaType, File file) throws WxErrorException;
+  WxMediaUploadResult mediaUpload(String mediaType, File file) throws WxErrorException;
 
   /**
    * 
@@ -105,7 +105,7 @@ public interface WxCpService {
    * @throws WxErrorException
    * @params media_id
    */
-  public File mediaDownload(String media_id) throws WxErrorException;
+  File mediaDownload(String media_id) throws WxErrorException;
 
   /**
    * 
@@ -116,7 +116,7 @@ public interface WxCpService {
    * @param message
    * @throws WxErrorException
    */
-  public void messageSend(WxCpMessage message) throws WxErrorException;
+  void messageSend(WxCpMessage message) throws WxErrorException;
 
   /**
    * 
@@ -127,7 +127,7 @@ public interface WxCpService {
    * @param menu
    * @throws WxErrorException
    */
-  public void menuCreate(WxMenu menu) throws WxErrorException;
+  void menuCreate(WxMenu menu) throws WxErrorException;
 
   /**
    * 
@@ -137,7 +137,7 @@ public interface WxCpService {
    *
    * @throws WxErrorException
    */
-  public void menuDelete() throws WxErrorException;
+  void menuDelete() throws WxErrorException;
 
   /**
    * 
@@ -148,7 +148,7 @@ public interface WxCpService {
    * @return
    * @throws WxErrorException
    */
-  public WxMenu menuGet() throws WxErrorException;
+  WxMenu menuGet() throws WxErrorException;
 
   /**
    * 
@@ -161,7 +161,7 @@ public interface WxCpService {
    * @return 部门id
    * @throws WxErrorException
    */
-  public Integer departCreate(WxCpDepart depart) throws WxErrorException;
+  Integer departCreate(WxCpDepart depart) throws WxErrorException;
 
   /**
    * 
@@ -172,7 +172,7 @@ public interface WxCpService {
    * @return
    * @throws WxErrorException
    */
-  public List departGet() throws WxErrorException;
+  List departGet() throws WxErrorException;
 
   /**
    * 
@@ -184,7 +184,7 @@ public interface WxCpService {
    * @param group 要更新的group,group的id,name必须设置
    * @throws WxErrorException
    */
-  public void departUpdate(WxCpDepart group) throws WxErrorException;
+  void departUpdate(WxCpDepart group) throws WxErrorException;
 
   /**
    * 
@@ -194,7 +194,7 @@ public interface WxCpService {
    * @param departId
    * @throws WxErrorException
    */
-  public void departDelete(Integer departId) throws WxErrorException;
+  void departDelete(Integer departId) throws WxErrorException;
 
   /**
    * http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E6.88.90.E5.91.98
@@ -205,7 +205,7 @@ public interface WxCpService {
    * @return
    * @throws WxErrorException
    */
-  public List departGetUsers(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException;
+  List departGetUsers(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException;
 
   /**
    * 新建用户
@@ -213,7 +213,7 @@ public interface WxCpService {
    * @param user
    * @throws WxErrorException
    */
-  public void userCreate(WxCpUser user) throws WxErrorException;
+  void userCreate(WxCpUser user) throws WxErrorException;
 
   /**
    * 更新用户
@@ -221,7 +221,7 @@ public interface WxCpService {
    * @param user
    * @throws WxErrorException
    */
-  public void userUpdate(WxCpUser user) throws WxErrorException;
+  void userUpdate(WxCpUser user) throws WxErrorException;
 
   /**
    * 删除用户
@@ -229,7 +229,7 @@ public interface WxCpService {
    * @param userid
    * @throws WxErrorException
    */
-  public void userDelete(String userid) throws WxErrorException;
+  void userDelete(String userid) throws WxErrorException;
 
   /**
    * 获取用户
@@ -238,7 +238,7 @@ public interface WxCpService {
    * @return
    * @throws WxErrorException
    */
-  public WxCpUser userGet(String userid) throws WxErrorException;
+  WxCpUser userGet(String userid) throws WxErrorException;
 
   /**
    * 创建标签
@@ -246,7 +246,7 @@ public interface WxCpService {
    * @param tagName
    * @return
    */
-  public String tagCreate(String tagName) throws WxErrorException;
+  String tagCreate(String tagName) throws WxErrorException;
 
   /**
    * 更新标签
@@ -254,21 +254,21 @@ public interface WxCpService {
    * @param tagId
    * @param tagName
    */
-  public void tagUpdate(String tagId, String tagName) throws WxErrorException;
+  void tagUpdate(String tagId, String tagName) throws WxErrorException;
 
   /**
    * 删除标签
    *
    * @param tagId
    */
-  public void tagDelete(String tagId) throws WxErrorException;
+  void tagDelete(String tagId) throws WxErrorException;
 
   /**
    * 获得标签列表
    *
    * @return
    */
-  public List tagGet() throws WxErrorException;
+  List tagGet() throws WxErrorException;
 
   /**
    * 获取标签成员
@@ -276,7 +276,7 @@ public interface WxCpService {
    * @param tagId
    * @return
    */
-  public List tagGetUsers(String tagId) throws WxErrorException;
+  List tagGetUsers(String tagId) throws WxErrorException;
 
   /**
    * 增加标签成员
@@ -284,7 +284,7 @@ public interface WxCpService {
    * @param tagId
    * @param userIds
    */
-  public void tagAddUsers(String tagId, List userIds) throws WxErrorException;
+  void tagAddUsers(String tagId, List userIds) throws WxErrorException;
 
   /**
    * 
@@ -294,7 +294,7 @@ public interface WxCpService {
    * @param state
    * @return code
    */
-  public String oauth2buildAuthorizationUrl(String state);
+  String oauth2buildAuthorizationUrl(String state);
 
   /**
    * 
@@ -305,7 +305,7 @@ public interface WxCpService {
    * @param code
    * @return [userid, deviceid]
    */
-  public String[] oauth2getUserInfo(String code) throws WxErrorException;
+  String[] oauth2getUserInfo(String code) throws WxErrorException;
 
   /**
    * 移除标签成员
@@ -313,7 +313,7 @@ public interface WxCpService {
    * @param tagId
    * @param userIds
    */
-  public void tagRemoveUsers(String tagId, List userIds) throws WxErrorException;
+  void tagRemoveUsers(String tagId, List userIds) throws WxErrorException;
 
   /**
    * 
@@ -325,7 +325,7 @@ public interface WxCpService {
    * @return 1:微信邀请 2.邮件邀请
    * @throws WxErrorException
    */
-  public int invite(String userId, String inviteTips) throws WxErrorException;
+  int invite(String userId, String inviteTips) throws WxErrorException;
 
   /**
    * 
@@ -369,14 +369,14 @@ public interface WxCpService {
    * @return
    * @throws WxErrorException
    */
-  public  T execute(RequestExecutor executor, String uri, E data) throws WxErrorException;
+   T execute(RequestExecutor executor, String uri, E data) throws WxErrorException;
 
   /**
    * 注入 {@link WxCpConfigStorage} 的实现
    *
    * @param wxConfigProvider
    */
-  public void setWxCpConfigStorage(WxCpConfigStorage wxConfigProvider);
+  void setWxCpConfigStorage(WxCpConfigStorage wxConfigProvider);
 
   /**
    * 
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java
index 788098f35..d88c61279 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java
@@ -78,7 +78,7 @@ public class WxCpServiceImpl implements WxCpService {
 
   public void userAuthenticated(String userId) throws WxErrorException {
     String url = "https://qyapi.weixin.qq.com/cgi-bin/user/authsucc?userid=" + userId;
-    execute(new SimpleGetRequestExecutor(), url, null);
+    get(url, null);
   }
 
   public String getAccessToken() throws WxErrorException {
@@ -123,23 +123,23 @@ public class WxCpServiceImpl implements WxCpService {
 
   public void messageSend(WxCpMessage message) throws WxErrorException {
     String url = "https://qyapi.weixin.qq.com/cgi-bin/message/send";
-    execute(new SimplePostRequestExecutor(), url, message.toJson());
+    post(url, message.toJson());
   }
 
   public void menuCreate(WxMenu menu) throws WxErrorException {
     String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/create?agentid=" + wxCpConfigStorage.getAgentId();
-    execute(new SimplePostRequestExecutor(), url, menu.toJson());
+    post(url, menu.toJson());
   }
 
   public void menuDelete() throws WxErrorException {
     String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/delete?agentid=" + wxCpConfigStorage.getAgentId();
-    execute(new SimpleGetRequestExecutor(), url, null);
+    get(url, null);
   }
 
   public WxMenu menuGet() throws WxErrorException {
     String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/get?agentid=" + wxCpConfigStorage.getAgentId();
     try {
-      String resultContent = execute(new SimpleGetRequestExecutor(), url, null);
+      String resultContent = get(url, null);
       return WxMenu.fromJson(resultContent);
     } catch (WxErrorException e) {
       // 46003 不存在的菜单数据
@@ -178,17 +178,17 @@ public class WxCpServiceImpl implements WxCpService {
 
   public void departUpdate(WxCpDepart group) throws WxErrorException {
     String url = "https://qyapi.weixin.qq.com/cgi-bin/department/update";
-    execute(new SimplePostRequestExecutor(), url, group.toJson());
+    post(url, group.toJson());
   }
 
   public void departDelete(Integer departId) throws WxErrorException {
     String url = "https://qyapi.weixin.qq.com/cgi-bin/department/delete?id=" + departId;
-    execute(new SimpleGetRequestExecutor(), url, null);
+    get(url, null);
   }
 
   public List departGet() throws WxErrorException {
     String url = "https://qyapi.weixin.qq.com/cgi-bin/department/list";
-    String responseContent = execute(new SimpleGetRequestExecutor(), url, null);
+    String responseContent = get(url, null);
     /*
      * 操蛋的微信API,创建时返回的是 { group : { id : ..., name : ...} }
      * 查询时返回的是 { groups : [ { id : ..., name : ..., count : ... }, ... ] }
@@ -204,25 +204,25 @@ public class WxCpServiceImpl implements WxCpService {
   @Override
   public void userCreate(WxCpUser user) throws WxErrorException {
     String url = "https://qyapi.weixin.qq.com/cgi-bin/user/create";
-    execute(new SimplePostRequestExecutor(), url, user.toJson());
+    post(url, user.toJson());
   }
 
   @Override
   public void userUpdate(WxCpUser user) throws WxErrorException {
     String url = "https://qyapi.weixin.qq.com/cgi-bin/user/update";
-    execute(new SimplePostRequestExecutor(), url, user.toJson());
+    post(url, user.toJson());
   }
 
   @Override
   public void userDelete(String userid) throws WxErrorException {
     String url = "https://qyapi.weixin.qq.com/cgi-bin/user/delete?userid=" + userid;
-    execute(new SimpleGetRequestExecutor(), url, null);
+    get(url, null);
   }
 
   @Override
   public WxCpUser userGet(String userid) throws WxErrorException {
     String url = "https://qyapi.weixin.qq.com/cgi-bin/user/get?userid=" + userid;
-    String responseContent = execute(new SimpleGetRequestExecutor(), url, null);
+    String responseContent = get(url, null);
     return WxCpUser.fromJson(responseContent);
   }
 
@@ -239,7 +239,7 @@ public class WxCpServiceImpl implements WxCpService {
       params += "&status=0";
     }
 
-    String responseContent = execute(new SimpleGetRequestExecutor(), url, params);
+    String responseContent = get(url, params);
     JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent)));
     return WxCpGsonBuilder.INSTANCE.create()
         .fromJson(
@@ -253,7 +253,7 @@ public class WxCpServiceImpl implements WxCpService {
     String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/create";
     JsonObject o = new JsonObject();
     o.addProperty("tagname", tagName);
-    String responseContent = execute(new SimplePostRequestExecutor(), url, o.toString());
+    String responseContent = post(url, o.toString());
     JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent)));
     return tmpJsonElement.getAsJsonObject().get("tagid").getAsString();
   }
@@ -264,19 +264,19 @@ public class WxCpServiceImpl implements WxCpService {
     JsonObject o = new JsonObject();
     o.addProperty("tagid", tagId);
     o.addProperty("tagname", tagName);
-    execute(new SimplePostRequestExecutor(), url, o.toString());
+    post(url, o.toString());
   }
 
   @Override
   public void tagDelete(String tagId) throws WxErrorException {
     String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/delete?tagid=" + tagId;
-    execute(new SimpleGetRequestExecutor(), url, null);
+    get(url, null);
   }
 
   @Override
   public List tagGet() throws WxErrorException {
     String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/list";
-    String responseContent = execute(new SimpleGetRequestExecutor(), url, null);
+    String responseContent = get(url, null);
     JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent)));
     return WxCpGsonBuilder.INSTANCE.create()
         .fromJson(
@@ -288,7 +288,7 @@ public class WxCpServiceImpl implements WxCpService {
   @Override
   public List tagGetUsers(String tagId) throws WxErrorException {
     String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/get?tagid=" + tagId;
-    String responseContent = execute(new SimpleGetRequestExecutor(), url, null);
+    String responseContent = get(url, null);
     JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent)));
     return WxCpGsonBuilder.INSTANCE.create()
         .fromJson(
@@ -307,7 +307,7 @@ public class WxCpServiceImpl implements WxCpService {
       jsonArray.add(new JsonPrimitive(userId));
     }
     jsonObject.add("userlist", jsonArray);
-    execute(new SimplePostRequestExecutor(), url, jsonObject.toString());
+    post(url, jsonObject.toString());
   }
 
   @Override
@@ -320,7 +320,7 @@ public class WxCpServiceImpl implements WxCpService {
       jsonArray.add(new JsonPrimitive(userId));
     }
     jsonObject.add("userlist", jsonArray);
-    execute(new SimplePostRequestExecutor(), url, jsonObject.toString());
+    post(url, jsonObject.toString());
   }
 
   @Override
@@ -365,7 +365,7 @@ public class WxCpServiceImpl implements WxCpService {
     if (StringUtils.isNotEmpty(inviteTips)) {
       jsonObject.addProperty("invite_tips", inviteTips);
     }
-    String responseContent = execute(new SimplePostRequestExecutor(), url, jsonObject.toString());
+    String responseContent = post(url, jsonObject.toString());
     JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent)));
     return tmpJsonElement.getAsJsonObject().get("type").getAsInt();
   }