改造查询菜单接口,以支持个性化菜单的conditionalmenu和menuid属性, #126

This commit is contained in:
Binary Wang
2017-01-17 15:15:21 +08:00
parent 5018c31e60
commit 39c7f7cd9f
4 changed files with 100 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.api;
import me.chanjar.weixin.common.bean.menu.WxMenu;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.bean.menu.WxMpGetSelfMenuInfoResult;
import me.chanjar.weixin.mp.bean.menu.WxMpMenu;
/**
* 菜单相关操作接口
@@ -54,10 +55,10 @@ public interface WxMpMenuService {
/**
* <pre>
* 自定义菜单查询接口
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单查询接口
* 详情请见 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141014&token=&lang=zh_CN
* </pre>
*/
WxMenu menuGet() throws WxErrorException;
WxMpMenu menuGet() throws WxErrorException;
/**
* <pre>

View File

@@ -7,6 +7,7 @@ import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpMenuService;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.menu.WxMpGetSelfMenuInfoResult;
import me.chanjar.weixin.mp.bean.menu.WxMpMenu;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -78,11 +79,11 @@ public class WxMpMenuServiceImpl implements WxMpMenuService {
}
@Override
public WxMenu menuGet() throws WxErrorException {
public WxMpMenu menuGet() throws WxErrorException {
String url = API_URL_PREFIX + "/get";
try {
String resultContent = this.wxMpService.get(url, null);
return WxMenu.fromJson(resultContent);
return WxMpMenu.fromJson(resultContent);
} catch (WxErrorException e) {
// 46003 不存在的菜单数据
if (e.getError().getErrorCode() == 46003) {