根据网上下载的仿微信菜单设置界面
image.png目前实现了查询和修改接口,代码如下:
/**
* 查询微信菜单
* @throws Exception
*/
@RequestMapping("wxMenu/queryWxMenu")
@ResponseBody
public R queryWxMenu(){
try {
wxMpService.getAccessToken(false);
WxMpMenu wxMpMenu = wxMpService.getMenuService().menuGet();
return R.ok().put("data", wxMpMenu);
} catch (WxErrorException e) {
logger.error(e.getMessage());
return R.error("获取菜单失败");
}
}
/**
* 设置微信菜单
* @param menu
* @throws Exception
*/
@RequestMapping("wxMenu/setUpWxMenu")
@ResponseBody
public R setUpWxMenu(@RequestBody WxMenu menu){
try {
//创建一级菜单
logger.info(JsonUtil.getJsonByObj(menu));
wxMpService.getMenuService().menuCreate(menu);
return R.ok();
} catch (WxErrorException e) {
logger.error(e.getMessage());
return R.error("创建菜单失败");
}
}
网友评论