|
2 | 2 |
|
3 | 3 | import java.io.File;
|
4 | 4 | import java.io.IOException;
|
5 |
| -import java.io.InputStream; |
6 | 5 | import java.io.StringReader;
|
7 | 6 | import java.io.UnsupportedEncodingException;
|
8 | 7 | import java.net.URLEncoder;
|
|
16 | 15 | import java.util.Map.Entry;
|
17 | 16 | import java.util.SortedMap;
|
18 | 17 | import java.util.TreeMap;
|
19 |
| -import java.util.UUID; |
20 | 18 |
|
21 |
| -import me.chanjar.weixin.mp.api.impl.WxMpMaterialServiceImpl; |
22 | 19 | import org.apache.http.Consts;
|
23 | 20 | import org.apache.http.HttpHost;
|
24 | 21 | import org.apache.http.client.ClientProtocolException;
|
|
44 | 41 | import com.google.gson.stream.JsonReader;
|
45 | 42 | import com.thoughtworks.xstream.XStream;
|
46 | 43 |
|
47 |
| -import me.chanjar.weixin.common.api.WxConsts; |
48 | 44 | import me.chanjar.weixin.common.bean.WxAccessToken;
|
49 | 45 | import me.chanjar.weixin.common.bean.WxCardApiSignature;
|
50 | 46 | import me.chanjar.weixin.common.bean.WxJsapiSignature;
|
51 |
| -import me.chanjar.weixin.common.bean.WxMenu; |
52 | 47 | import me.chanjar.weixin.common.bean.result.WxError;
|
53 |
| -import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; |
54 | 48 | import me.chanjar.weixin.common.exception.WxErrorException;
|
55 | 49 | import me.chanjar.weixin.common.session.StandardSessionManager;
|
56 | 50 | import me.chanjar.weixin.common.session.WxSessionManager;
|
57 | 51 | import me.chanjar.weixin.common.util.RandomUtils;
|
58 | 52 | import me.chanjar.weixin.common.util.crypto.SHA1;
|
59 | 53 | import me.chanjar.weixin.common.util.crypto.WxCryptUtil;
|
60 |
| -import me.chanjar.weixin.common.util.fs.FileUtils; |
61 | 54 | import me.chanjar.weixin.common.util.http.ApacheHttpClientBuilder;
|
62 | 55 | import me.chanjar.weixin.common.util.http.DefaultApacheHttpHttpClientBuilder;
|
63 |
| -import me.chanjar.weixin.common.util.http.MediaDownloadRequestExecutor; |
64 |
| -import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; |
65 | 56 | import me.chanjar.weixin.common.util.http.RequestExecutor;
|
66 | 57 | import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor;
|
67 | 58 | import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor;
|
68 | 59 | import me.chanjar.weixin.common.util.http.URIUtil;
|
69 | 60 | import me.chanjar.weixin.common.util.http.Utf8ResponseHandler;
|
70 | 61 | import me.chanjar.weixin.common.util.json.GsonHelper;
|
71 |
| -import me.chanjar.weixin.common.util.json.WxGsonBuilder; |
72 | 62 | import me.chanjar.weixin.common.util.xml.XStreamInitializer;
|
73 | 63 | import me.chanjar.weixin.mp.api.impl.WxMpKefuServiceImpl;
|
| 64 | +import me.chanjar.weixin.mp.api.impl.WxMpMaterialServiceImpl; |
| 65 | +import me.chanjar.weixin.mp.api.impl.WxMpMenuServiceImpl; |
74 | 66 | import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
|
75 | 67 | import me.chanjar.weixin.mp.bean.WxMpGroup;
|
76 | 68 | import me.chanjar.weixin.mp.bean.WxMpIndustry;
|
|
79 | 71 | import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage;
|
80 | 72 | import me.chanjar.weixin.mp.bean.WxMpMassPreviewMessage;
|
81 | 73 | import me.chanjar.weixin.mp.bean.WxMpMassVideo;
|
82 |
| -import me.chanjar.weixin.mp.bean.WxMpMaterial; |
83 |
| -import me.chanjar.weixin.mp.bean.WxMpMaterialArticleUpdate; |
84 |
| -import me.chanjar.weixin.mp.bean.WxMpMaterialNews; |
85 | 74 | import me.chanjar.weixin.mp.bean.WxMpSemanticQuery;
|
86 | 75 | import me.chanjar.weixin.mp.bean.WxMpTemplateMessage;
|
87 |
| -import me.chanjar.weixin.mp.bean.result.WxMediaImgUploadResult; |
88 | 76 | import me.chanjar.weixin.mp.bean.result.WxMpCardResult;
|
89 | 77 | import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult;
|
90 | 78 | import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult;
|
91 |
| -import me.chanjar.weixin.mp.bean.result.WxMpMaterialCountResult; |
92 |
| -import me.chanjar.weixin.mp.bean.result.WxMpMaterialFileBatchGetResult; |
93 |
| -import me.chanjar.weixin.mp.bean.result.WxMpMaterialNewsBatchGetResult; |
94 |
| -import me.chanjar.weixin.mp.bean.result.WxMpMaterialUploadResult; |
95 |
| -import me.chanjar.weixin.mp.bean.result.WxMpMaterialVideoInfoResult; |
96 | 79 | import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
|
97 | 80 | import me.chanjar.weixin.mp.bean.result.WxMpPayCallback;
|
98 | 81 | import me.chanjar.weixin.mp.bean.result.WxMpPayRefundResult;
|
|
105 | 88 | import me.chanjar.weixin.mp.bean.result.WxMpUserList;
|
106 | 89 | import me.chanjar.weixin.mp.bean.result.WxMpUserSummary;
|
107 | 90 | import me.chanjar.weixin.mp.bean.result.WxRedpackResult;
|
108 |
| -import me.chanjar.weixin.mp.util.http.MaterialDeleteRequestExecutor; |
109 |
| -import me.chanjar.weixin.mp.util.http.MaterialNewsInfoRequestExecutor; |
110 |
| -import me.chanjar.weixin.mp.util.http.MaterialUploadRequestExecutor; |
111 |
| -import me.chanjar.weixin.mp.util.http.MaterialVideoInfoRequestExecutor; |
112 |
| -import me.chanjar.weixin.mp.util.http.MaterialVoiceAndImageDownloadRequestExecutor; |
113 |
| -import me.chanjar.weixin.mp.util.http.MediaImgUploadRequestExecutor; |
114 | 91 | import me.chanjar.weixin.mp.util.http.QrCodeRequestExecutor;
|
115 | 92 | import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
116 | 93 |
|
@@ -139,6 +116,8 @@ public class WxMpServiceImpl implements WxMpService {
|
139 | 116 |
|
140 | 117 | protected WxMpMaterialService materialService = new WxMpMaterialServiceImpl(this);
|
141 | 118 |
|
| 119 | + protected WxMpMenuService menuService = new WxMpMenuServiceImpl(this); |
| 120 | + |
142 | 121 | protected CloseableHttpClient httpClient;
|
143 | 122 |
|
144 | 123 | protected HttpHost httpProxy;
|
@@ -259,59 +238,6 @@ public void customMessageSend(WxMpCustomMessage message) throws WxErrorException
|
259 | 238 | execute(new SimplePostRequestExecutor(), url, message.toJson());
|
260 | 239 | }
|
261 | 240 |
|
262 |
| - @Override |
263 |
| - public void menuCreate(WxMenu menu) throws WxErrorException { |
264 |
| - if (menu.getMatchRule() != null) { |
265 |
| - String url = "https://api.weixin.qq.com/cgi-bin/menu/addconditional"; |
266 |
| - execute(new SimplePostRequestExecutor(), url, menu.toJson()); |
267 |
| - } else { |
268 |
| - String url = "https://api.weixin.qq.com/cgi-bin/menu/create"; |
269 |
| - execute(new SimplePostRequestExecutor(), url, menu.toJson()); |
270 |
| - } |
271 |
| - } |
272 |
| - |
273 |
| - @Override |
274 |
| - public void menuDelete() throws WxErrorException { |
275 |
| - String url = "https://api.weixin.qq.com/cgi-bin/menu/delete"; |
276 |
| - execute(new SimpleGetRequestExecutor(), url, null); |
277 |
| - } |
278 |
| - |
279 |
| - @Override |
280 |
| - public void menuDelete(String menuid) throws WxErrorException { |
281 |
| - String url = "https://api.weixin.qq.com/cgi-bin/menu/delconditional"; |
282 |
| - execute(new SimpleGetRequestExecutor(), url, "menuid=" + menuid); |
283 |
| - } |
284 |
| - |
285 |
| - @Override |
286 |
| - public WxMenu menuGet() throws WxErrorException { |
287 |
| - String url = "https://api.weixin.qq.com/cgi-bin/menu/get"; |
288 |
| - try { |
289 |
| - String resultContent = execute(new SimpleGetRequestExecutor(), url, null); |
290 |
| - return WxMenu.fromJson(resultContent); |
291 |
| - } catch (WxErrorException e) { |
292 |
| - // 46003 不存在的菜单数据 |
293 |
| - if (e.getError().getErrorCode() == 46003) { |
294 |
| - return null; |
295 |
| - } |
296 |
| - throw e; |
297 |
| - } |
298 |
| - } |
299 |
| - |
300 |
| - @Override |
301 |
| - public WxMenu menuTryMatch(String userid) throws WxErrorException { |
302 |
| - String url = "https://api.weixin.qq.com/cgi-bin/menu/trymatch"; |
303 |
| - try { |
304 |
| - String resultContent = execute(new SimpleGetRequestExecutor(), url, "user_id=" + userid); |
305 |
| - return WxMenu.fromJson(resultContent); |
306 |
| - } catch (WxErrorException e) { |
307 |
| - // 46003 不存在的菜单数据 46002 不存在的菜单版本 |
308 |
| - if (e.getError().getErrorCode() == 46003 || e.getError().getErrorCode() == 46002) { |
309 |
| - return null; |
310 |
| - } |
311 |
| - throw e; |
312 |
| - } |
313 |
| - } |
314 |
| - |
315 | 241 | @Override
|
316 | 242 | public WxMpMassUploadResult massNewsUpload(WxMpMassNews news) throws WxErrorException {
|
317 | 243 | String url = "https://api.weixin.qq.com/cgi-bin/media/uploadnews";
|
@@ -1323,5 +1249,10 @@ public WxMpKefuService getKefuService() {
|
1323 | 1249 | public WxMpMaterialService getMaterialService() {
|
1324 | 1250 | return this.materialService;
|
1325 | 1251 | }
|
1326 |
| - |
| 1252 | + |
| 1253 | + @Override |
| 1254 | + public WxMpMenuService getMenuService() { |
| 1255 | + return this.menuService; |
| 1256 | + } |
| 1257 | + |
1327 | 1258 | }
|
0 commit comments