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,29 @@ 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 () );
30- }
31+ url = API_URL_PREFIX + "/addconditional" ;
32+ }
33+ log . trace ( "开始创建菜单:{}" , menuJson );
34+
35+ String result = this .wxMpService .execute (new SimplePostRequestExecutor (), url ,menuJson );
36+ log . debug ( "创建菜单:{},结果:{}" , menuJson , result );
3137 }
3238
3339 @ Override
3440 public void menuDelete () throws WxErrorException {
3541 String url = API_URL_PREFIX + "/delete" ;
36- this .wxMpService .execute (new SimpleGetRequestExecutor (), url , null );
42+ String result = this .wxMpService .execute (new SimpleGetRequestExecutor (), url , null );
43+ log .debug ("删除菜单结果:{}" , result );
3744 }
3845
3946 @ Override
4047 public void menuDelete (String menuid ) throws WxErrorException {
4148 String url = API_URL_PREFIX + "/delconditional" ;
42- this .wxMpService .execute (new SimpleGetRequestExecutor (), url , "menuid=" + menuid );
49+ String result = this .wxMpService .execute (new SimpleGetRequestExecutor (), url , "menuid=" + menuid );
50+ log .debug ("根据MeunId({})删除菜单结果:{}" , menuid ,result );
4351 }
4452
4553 @ Override
0 commit comments