55
66import me .chanjar .weixin .common .bean .menu .WxMenu ;
77import me .chanjar .weixin .common .exception .WxErrorException ;
8- import me .chanjar .weixin .common .util .http .SimpleGetRequestExecutor ;
9- import me .chanjar .weixin .common .util .http .SimplePostRequestExecutor ;
108import me .chanjar .weixin .mp .api .WxMpMenuService ;
119import me .chanjar .weixin .mp .api .WxMpService ;
1210
1513 */
1614public class WxMpMenuServiceImpl implements WxMpMenuService {
1715 private static final String API_URL_PREFIX = "https://api.weixin.qq.com/cgi-bin/menu" ;
18- private static Logger log = LoggerFactory .getLogger (WxMpMenuServiceImpl .class );
16+ private static Logger log = LoggerFactory
17+ .getLogger (WxMpMenuServiceImpl .class );
1918
2019 private WxMpService wxMpService ;
2120
@@ -25,36 +24,37 @@ public WxMpMenuServiceImpl(WxMpService wxMpService) {
2524
2625 @ Override
2726 public void menuCreate (WxMenu menu ) throws WxErrorException {
28- String menuJson = menu .toJson ();
29- String url = API_URL_PREFIX + "/create" ;
27+ String menuJson = menu .toJson ();
28+ String url = API_URL_PREFIX + "/create" ;
3029 if (menu .getMatchRule () != null ) {
3130 url = API_URL_PREFIX + "/addconditional" ;
32- }
33- log .trace ("开始创建菜单:{}" , menuJson );
34-
35- String result = this .wxMpService .execute (new SimplePostRequestExecutor (), url ,menuJson );
31+ }
32+
33+ log .debug ("开始创建菜单:{}" , menuJson );
34+
35+ String result = this .wxMpService .post (url , menuJson );
3636 log .debug ("创建菜单:{},结果:{}" , menuJson , result );
3737 }
3838
3939 @ Override
4040 public void menuDelete () throws WxErrorException {
4141 String url = API_URL_PREFIX + "/delete" ;
42- String result = this .wxMpService .execute ( new SimpleGetRequestExecutor (), url , null );
42+ String result = this .wxMpService .get ( url , null );
4343 log .debug ("删除菜单结果:{}" , result );
4444 }
4545
4646 @ Override
4747 public void menuDelete (String menuid ) throws WxErrorException {
4848 String url = API_URL_PREFIX + "/delconditional" ;
49- String result = this .wxMpService .execute ( new SimpleGetRequestExecutor (), url , "menuid=" + menuid );
50- log .debug ("根据MeunId({})删除菜单结果:{}" , menuid ,result );
49+ String result = this .wxMpService .get ( url , "menuid=" + menuid );
50+ log .debug ("根据MeunId({})删除菜单结果:{}" , menuid , result );
5151 }
5252
5353 @ Override
5454 public WxMenu menuGet () throws WxErrorException {
5555 String url = API_URL_PREFIX + "/get" ;
5656 try {
57- String resultContent = this .wxMpService .execute ( new SimpleGetRequestExecutor (), url , null );
57+ String resultContent = this .wxMpService .get ( url , null );
5858 return WxMenu .fromJson (resultContent );
5959 } catch (WxErrorException e ) {
6060 // 46003 不存在的菜单数据
@@ -69,11 +69,12 @@ public WxMenu menuGet() throws WxErrorException {
6969 public WxMenu menuTryMatch (String userid ) throws WxErrorException {
7070 String url = API_URL_PREFIX + "/trymatch" ;
7171 try {
72- String resultContent = this .wxMpService .execute ( new SimpleGetRequestExecutor (), url , "user_id=" + userid );
72+ String resultContent = this .wxMpService .get ( url , "user_id=" + userid );
7373 return WxMenu .fromJson (resultContent );
7474 } catch (WxErrorException e ) {
7575 // 46003 不存在的菜单数据 46002 不存在的菜单版本
76- if (e .getError ().getErrorCode () == 46003 || e .getError ().getErrorCode () == 46002 ) {
76+ if (e .getError ().getErrorCode () == 46003
77+ || e .getError ().getErrorCode () == 46002 ) {
7778 return null ;
7879 }
7980 throw e ;
0 commit comments