11package me .chanjar .weixin .mp .api .impl ;
22
3+ import org .slf4j .Logger ;
4+ import org .slf4j .LoggerFactory ;
5+
36import me .chanjar .weixin .common .bean .menu .WxMenu ;
47import me .chanjar .weixin .common .exception .WxErrorException ;
58import me .chanjar .weixin .common .util .http .SimpleGetRequestExecutor ;
1215 */
1316public class WxMpMenuServiceImpl implements WxMpMenuService {
1417 private static final String API_URL_PREFIX = "https://api.weixin.qq.com/cgi-bin/menu" ;
18+ private static Logger log = LoggerFactory .getLogger (WxMpMenuServiceImpl .class );
1519
1620 private WxMpService wxMpService ;
1721
@@ -21,25 +25,38 @@ public WxMpMenuServiceImpl(WxMpService wxMpService) {
2125
2226 @ Override
2327 public void menuCreate (WxMenu menu ) throws WxErrorException {
28+ String menuJson = menu .toJson ();
29+ String url = API_URL_PREFIX + "/create" ;
2430 if (menu .getMatchRule () != null ) {
25- String url = API_URL_PREFIX + "/addconditional" ;
26- this .wxMpService .execute (new SimplePostRequestExecutor (), url , menu .toJson ());
27- } else {
28- String url = API_URL_PREFIX + "/create" ;
29- this .wxMpService .execute (new SimplePostRequestExecutor (), url , menu .toJson ());
31+ url = API_URL_PREFIX + "/addconditional" ;
32+ }
33+ if (log .isTraceEnabled ()){
34+ log .trace ("开始创建菜单:{}" , menuJson );
35+ }
36+
37+ String result = this .wxMpService .execute (new SimplePostRequestExecutor (), url ,menuJson );
38+
39+ if (log .isDebugEnabled ()){
40+ log .debug ("创建菜单:{},结果:{}" , menuJson , result );
3041 }
3142 }
3243
3344 @ Override
3445 public void menuDelete () throws WxErrorException {
3546 String url = API_URL_PREFIX + "/delete" ;
36- this .wxMpService .execute (new SimpleGetRequestExecutor (), url , null );
47+ String result = this .wxMpService .execute (new SimpleGetRequestExecutor (), url , null );
48+ if (log .isDebugEnabled ()){
49+ log .debug ("删除菜单结果:{}" , result );
50+ }
3751 }
3852
3953 @ Override
4054 public void menuDelete (String menuid ) throws WxErrorException {
4155 String url = API_URL_PREFIX + "/delconditional" ;
42- this .wxMpService .execute (new SimpleGetRequestExecutor (), url , "menuid=" + menuid );
56+ String result = this .wxMpService .execute (new SimpleGetRequestExecutor (), url , "menuid=" + menuid );
57+ if (log .isDebugEnabled ()){
58+ log .debug ("根据MeunId({})删除菜单结果:{}" , menuid ,result );
59+ }
4360 }
4461
4562 @ Override
0 commit comments