|  | @ -1,16 +1,16 @@
 | 
												
													
														
															|  | package com.yihu.jw.wx.controller;
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | package com.yihu.jw.business.wx.controller;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.business.wx.WechatResponse;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.business.wx.model.WxMenu;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.business.wx.model.WxWechat;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.business.wx.service.WechatService;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.business.wx.service.WxMenuService;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.exception.ApiException;
 | 
												
													
														
															|  | import com.yihu.jw.restmodel.common.Envelop;
 |  | import com.yihu.jw.restmodel.common.Envelop;
 | 
												
													
														
															|  | import com.yihu.jw.restmodel.common.EnvelopRestController;
 |  | import com.yihu.jw.restmodel.common.EnvelopRestController;
 | 
												
													
														
															|  | import com.yihu.jw.restmodel.exception.ApiException;
 |  | 
 | 
												
													
														
															|  | import com.yihu.jw.restmodel.wx.MWxMenu;
 |  | 
 | 
												
													
														
															|  | import com.yihu.jw.restmodel.wx.MWxWechat;
 |  | 
 | 
												
													
														
															|  | import com.yihu.jw.restmodel.wx.WechatContants;
 |  | 
 | 
												
													
														
															|  | import com.yihu.jw.wx.WechatResponse;
 |  | 
 | 
												
													
														
															|  | import com.yihu.jw.wx.model.WxMenu;
 |  | 
 | 
												
													
														
															|  | import com.yihu.jw.wx.model.WxWechat;
 |  | 
 | 
												
													
														
															|  | import com.yihu.jw.wx.service.WechatService;
 |  | 
 | 
												
													
														
															|  | import com.yihu.jw.wx.service.WxMenuService;
 |  | 
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.restmodel.base.wx.MWxMenu;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.restmodel.base.wx.MWxWechat;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.rm.wx.WechatRequestMapping;
 | 
												
													
														
															|  | import io.swagger.annotations.Api;
 |  | import io.swagger.annotations.Api;
 | 
												
													
														
															|  | import io.swagger.annotations.ApiOperation;
 |  | import io.swagger.annotations.ApiOperation;
 | 
												
													
														
															|  | import io.swagger.annotations.ApiParam;
 |  | import io.swagger.annotations.ApiParam;
 | 
												
											
												
													
														
															|  | @ -30,7 +30,7 @@ import java.util.Map;
 | 
												
													
														
															|  |  * Created by Administrator on 2017/5/19 0019.
 |  |  * Created by Administrator on 2017/5/19 0019.
 | 
												
													
														
															|  |  */
 |  |  */
 | 
												
													
														
															|  | @RestController
 |  | @RestController
 | 
												
													
														
															|  | @RequestMapping(WechatContants.api_common)
 |  | 
 | 
												
													
														
															|  | 
 |  | @RequestMapping(WechatRequestMapping.api_common)
 | 
												
													
														
															|  | @Api(value = "微信菜单相关操作", description = "微信菜单相关操作")
 |  | @Api(value = "微信菜单相关操作", description = "微信菜单相关操作")
 | 
												
													
														
															|  | public class WxMenuController extends EnvelopRestController {
 |  | public class WxMenuController extends EnvelopRestController {
 | 
												
													
														
															|  | 
 |  | 
 | 
												
											
												
													
														
															|  | @ -40,34 +40,34 @@ public class WxMenuController extends EnvelopRestController {
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private WechatService wechatService;
 |  |     private WechatService wechatService;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     @PostMapping(value = WechatContants.WxMenu.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
 |  | 
 | 
												
													
														
															|  | 
 |  |     @PostMapping(value = WechatRequestMapping.WxMenu.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
 | 
												
													
														
															|  |     @ApiOperation(value = "添加微信菜单", notes = "添加微信菜单")
 |  |     @ApiOperation(value = "添加微信菜单", notes = "添加微信菜单")
 | 
												
													
														
															|  |     public Envelop createWxMenu(
 |  |     public Envelop createWxMenu(
 | 
												
													
														
															|  |             @ApiParam(name = "json_data", value = "", defaultValue = "")
 |  |             @ApiParam(name = "json_data", value = "", defaultValue = "")
 | 
												
													
														
															|  |             @RequestBody String jsonData) {
 |  |             @RequestBody String jsonData) {
 | 
												
													
														
															|  |         try {
 |  |         try {
 | 
												
													
														
															|  |             WxMenu wxMenu = toEntity(jsonData, WxMenu.class);
 |  |             WxMenu wxMenu = toEntity(jsonData, WxMenu.class);
 | 
												
													
														
															|  |             return Envelop.getSuccess(WechatContants.WxMenu.message_success_create, wxMenuService.createWxMenu(wxMenu));
 |  | 
 | 
												
													
														
															|  | 
 |  |             return Envelop.getSuccess(WechatRequestMapping.WxMenu.message_success_create, wxMenuService.createWxMenu(wxMenu));
 | 
												
													
														
															|  |         } catch (ApiException e) {
 |  |         } catch (ApiException e) {
 | 
												
													
														
															|  |             return Envelop.getError(e.getMessage(), e.getErrorCode());
 |  |             return Envelop.getError(e.getMessage(), e.getErrorCode());
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     @PutMapping(value = WechatContants.WxMenu.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
 |  | 
 | 
												
													
														
															|  | 
 |  |     @PutMapping(value = WechatRequestMapping.WxMenu.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
 | 
												
													
														
															|  |     @ApiOperation(value = "修改微信菜单", notes = "修改微信菜单")
 |  |     @ApiOperation(value = "修改微信菜单", notes = "修改微信菜单")
 | 
												
													
														
															|  |     public Envelop updateWxMenu(
 |  |     public Envelop updateWxMenu(
 | 
												
													
														
															|  |             @ApiParam(name = "json_data", value = "", defaultValue = "")
 |  |             @ApiParam(name = "json_data", value = "", defaultValue = "")
 | 
												
													
														
															|  |             @RequestBody String jsonData) {
 |  |             @RequestBody String jsonData) {
 | 
												
													
														
															|  |         try {
 |  |         try {
 | 
												
													
														
															|  |             WxMenu wxMenu = toEntity(jsonData, WxMenu.class);
 |  |             WxMenu wxMenu = toEntity(jsonData, WxMenu.class);
 | 
												
													
														
															|  |             return Envelop.getSuccess(WechatContants.WxMenu.message_success_update, wxMenuService.updateWxMenu(wxMenu));
 |  | 
 | 
												
													
														
															|  | 
 |  |             return Envelop.getSuccess(WechatRequestMapping.WxMenu.message_success_update, wxMenuService.updateWxMenu(wxMenu));
 | 
												
													
														
															|  |         } catch (ApiException e) {
 |  |         } catch (ApiException e) {
 | 
												
													
														
															|  |             return Envelop.getError(e.getMessage(), e.getErrorCode());
 |  |             return Envelop.getError(e.getMessage(), e.getErrorCode());
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     @DeleteMapping(value = WechatContants.WxMenu.api_delete)
 |  | 
 | 
												
													
														
															|  | 
 |  |     @DeleteMapping(value = WechatRequestMapping.WxMenu.api_delete)
 | 
												
													
														
															|  |     @ApiOperation(value = "删除微信菜单", notes = "删除微信菜单")
 |  |     @ApiOperation(value = "删除微信菜单", notes = "删除微信菜单")
 | 
												
													
														
															|  |     public Envelop deleteWxMenu(
 |  |     public Envelop deleteWxMenu(
 | 
												
													
														
															|  |             @ApiParam(name = "codes", value = "codes")
 |  |             @ApiParam(name = "codes", value = "codes")
 | 
												
											
												
													
														
															|  | @ -79,26 +79,26 @@ public class WxMenuController extends EnvelopRestController {
 | 
												
													
														
															|  |     ) {
 |  |     ) {
 | 
												
													
														
															|  |         try {
 |  |         try {
 | 
												
													
														
															|  |             wxMenuService.deleteWxMenu(codes, userCode, userName);
 |  |             wxMenuService.deleteWxMenu(codes, userCode, userName);
 | 
												
													
														
															|  |             return Envelop.getSuccess(WechatContants.WxMenu.message_success_delete );
 |  | 
 | 
												
													
														
															|  | 
 |  |             return Envelop.getSuccess(WechatRequestMapping.WxMenu.message_success_delete );
 | 
												
													
														
															|  |         } catch (ApiException e) {
 |  |         } catch (ApiException e) {
 | 
												
													
														
															|  |             return Envelop.getError(e.getMessage(), e.getErrorCode());
 |  |             return Envelop.getError(e.getMessage(), e.getErrorCode());
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     @GetMapping(value = WechatContants.WxMenu.api_getByCode)
 |  | 
 | 
												
													
														
															|  | 
 |  |     @GetMapping(value = WechatRequestMapping.WxMenu.api_getByCode)
 | 
												
													
														
															|  |     @ApiOperation(value = "根据code查找微信菜单", notes = "根据code查找微信菜单")
 |  |     @ApiOperation(value = "根据code查找微信菜单", notes = "根据code查找微信菜单")
 | 
												
													
														
															|  |     public Envelop findByCode(
 |  |     public Envelop findByCode(
 | 
												
													
														
															|  |             @ApiParam(name = "code", value = "code")
 |  |             @ApiParam(name = "code", value = "code")
 | 
												
													
														
															|  |             @RequestParam(value = "code", required = true) String code
 |  |             @RequestParam(value = "code", required = true) String code
 | 
												
													
														
															|  |     ) {
 |  |     ) {
 | 
												
													
														
															|  |         try {
 |  |         try {
 | 
												
													
														
															|  |             return Envelop.getSuccess(WechatContants.WxMenu.message_success_find, wxMenuService.findByCode(code));
 |  | 
 | 
												
													
														
															|  | 
 |  |             return Envelop.getSuccess(WechatRequestMapping.WxMenu.message_success_find, wxMenuService.findByCode(code));
 | 
												
													
														
															|  |         } catch (ApiException e) {
 |  |         } catch (ApiException e) {
 | 
												
													
														
															|  |             return Envelop.getError(e.getMessage(), e.getErrorCode());
 |  |             return Envelop.getError(e.getMessage(), e.getErrorCode());
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     @RequestMapping(value = WechatContants.WxMenu.api_getWxMenus, method = RequestMethod.GET)
 |  | 
 | 
												
													
														
															|  | 
 |  |     @RequestMapping(value = WechatRequestMapping.WxMenu.api_getWxMenus, method = RequestMethod.GET)
 | 
												
													
														
															|  |     @ApiOperation(value = "获取微信菜单列表(分页)")
 |  |     @ApiOperation(value = "获取微信菜单列表(分页)")
 | 
												
													
														
															|  |     public Envelop getWxMenus(
 |  |     public Envelop getWxMenus(
 | 
												
													
														
															|  |             @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
 |  |             @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
 | 
												
											
												
													
														
															|  | @ -133,11 +133,11 @@ public class WxMenuController extends EnvelopRestController {
 | 
												
													
														
															|  |         pagedResponse(request, response, count, page, size);
 |  |         pagedResponse(request, response, count, page, size);
 | 
												
													
														
															|  |         //封装返回格式
 |  |         //封装返回格式
 | 
												
													
														
															|  |         List<MWxWechat> mwechats = convertToModels(wechats, new ArrayList<>(wechats.size()), MWxWechat.class, fields);
 |  |         List<MWxWechat> mwechats = convertToModels(wechats, new ArrayList<>(wechats.size()), MWxWechat.class, fields);
 | 
												
													
														
															|  |         return Envelop.getSuccessListWithPage(WechatContants.WxMenu.message_success_find_functions,mwechats, page, size,count);
 |  | 
 | 
												
													
														
															|  | 
 |  |         return Envelop.getSuccessListWithPage(WechatRequestMapping.WxMenu.message_success_find_functions,mwechats, page, size,count);
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     @GetMapping(value = WechatContants.WxMenu.api_getWxMenuNoPage)
 |  | 
 | 
												
													
														
															|  | 
 |  |     @GetMapping(value = WechatRequestMapping.WxMenu.api_getWxMenuNoPage)
 | 
												
													
														
															|  |     @ApiOperation(value = "获取微信菜单列表,不分页")
 |  |     @ApiOperation(value = "获取微信菜单列表,不分页")
 | 
												
													
														
															|  |     public Envelop getWxMenuNoPage(
 |  |     public Envelop getWxMenuNoPage(
 | 
												
													
														
															|  |             @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
 |  |             @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
 | 
												
											
												
													
														
															|  | @ -163,7 +163,7 @@ public class WxMenuController extends EnvelopRestController {
 | 
												
													
														
															|  |         for(MWxMenu menu:mWxMenus){
 |  |         for(MWxMenu menu:mWxMenus){
 | 
												
													
														
															|  |             menu.setWechatName(map.get(menu.getWechatCode()));
 |  |             menu.setWechatName(map.get(menu.getWechatCode()));
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         return Envelop.getSuccessList(WechatContants.WxMenu.message_success_find_functions,mWxMenus);
 |  | 
 | 
												
													
														
															|  | 
 |  |         return Envelop.getSuccessList(WechatRequestMapping.WxMenu.message_success_find_functions,mWxMenus);
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     /**
 |  |     /**
 | 
												
											
												
													
														
															|  | @ -172,7 +172,7 @@ public class WxMenuController extends EnvelopRestController {
 | 
												
													
														
															|  |      * @return
 |  |      * @return
 | 
												
													
														
															|  |      */
 |  |      */
 | 
												
													
														
															|  |     @ApiOperation(value = "创建微信公众号菜单", notes = "创建微信公众号菜单")
 |  |     @ApiOperation(value = "创建微信公众号菜单", notes = "创建微信公众号菜单")
 | 
												
													
														
															|  |     @RequestMapping(value = WechatContants.WxMenu.api_createMenu ,method = RequestMethod.GET)
 |  | 
 | 
												
													
														
															|  | 
 |  |     @RequestMapping(value = WechatRequestMapping.WxMenu.api_createMenu ,method = RequestMethod.GET)
 | 
												
													
														
															|  |     public Envelop createWechatMenu(
 |  |     public Envelop createWechatMenu(
 | 
												
													
														
															|  |             @ApiParam(name = "wechatCode", value = "", defaultValue = "")
 |  |             @ApiParam(name = "wechatCode", value = "", defaultValue = "")
 | 
												
													
														
															|  |             @RequestParam(value = "wechatCode", required = true)String wechatCode){
 |  |             @RequestParam(value = "wechatCode", required = true)String wechatCode){
 | 
												
											
												
													
														
															|  | @ -192,7 +192,7 @@ public class WxMenuController extends EnvelopRestController {
 | 
												
													
														
															|  |      * @param wechatCode
 |  |      * @param wechatCode
 | 
												
													
														
															|  |      * @return
 |  |      * @return
 | 
												
													
														
															|  |      */
 |  |      */
 | 
												
													
														
															|  |     @GetMapping(value = WechatContants.WxMenu.api_getParentMenu)
 |  | 
 | 
												
													
														
															|  | 
 |  |     @GetMapping(value = WechatRequestMapping.WxMenu.api_getParentMenu)
 | 
												
													
														
															|  |     @ApiOperation(value = "根据微信code查找父菜单", notes = "根据微信code查找父菜单")
 |  |     @ApiOperation(value = "根据微信code查找父菜单", notes = "根据微信code查找父菜单")
 | 
												
													
														
															|  |     public Envelop getParentMenu(
 |  |     public Envelop getParentMenu(
 | 
												
													
														
															|  |             @ApiParam(name = "wechatCode", value = "wechatCode")
 |  |             @ApiParam(name = "wechatCode", value = "wechatCode")
 | 
												
											
												
													
														
															|  | @ -208,7 +208,7 @@ public class WxMenuController extends EnvelopRestController {
 | 
												
													
														
															|  |                     parentMenu.setState("open");
 |  |                     parentMenu.setState("open");
 | 
												
													
														
															|  |                 }
 |  |                 }
 | 
												
													
														
															|  |             }
 |  |             }
 | 
												
													
														
															|  |             return Envelop.getSuccess(WechatContants.WxMenu.message_success_find, parentMenus);
 |  | 
 | 
												
													
														
															|  | 
 |  |             return Envelop.getSuccess(WechatRequestMapping.WxMenu.message_success_find, parentMenus);
 | 
												
													
														
															|  |         } catch (ApiException e) {
 |  |         } catch (ApiException e) {
 | 
												
													
														
															|  |             return Envelop.getError(e.getMessage(), e.getErrorCode());
 |  |             return Envelop.getError(e.getMessage(), e.getErrorCode());
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
											
												
													
														
															|  | @ -220,14 +220,14 @@ public class WxMenuController extends EnvelopRestController {
 | 
												
													
														
															|  |      * @param parentCode
 |  |      * @param parentCode
 | 
												
													
														
															|  |      * @return
 |  |      * @return
 | 
												
													
														
															|  |      */
 |  |      */
 | 
												
													
														
															|  |     @GetMapping(value = WechatContants.WxMenu.api_getChildMenus)
 |  | 
 | 
												
													
														
															|  | 
 |  |     @GetMapping(value = WechatRequestMapping.WxMenu.api_getChildMenus)
 | 
												
													
														
															|  |     @ApiOperation(value = "根据父级菜单code查找子菜单", notes = "根据父级菜单code查找子菜单")
 |  |     @ApiOperation(value = "根据父级菜单code查找子菜单", notes = "根据父级菜单code查找子菜单")
 | 
												
													
														
															|  |     public Envelop getChildMenus(
 |  |     public Envelop getChildMenus(
 | 
												
													
														
															|  |             @ApiParam(name = "parentCode", value = "parentCode")
 |  |             @ApiParam(name = "parentCode", value = "parentCode")
 | 
												
													
														
															|  |             @PathVariable(value = "parentCode", required = true) String parentCode
 |  |             @PathVariable(value = "parentCode", required = true) String parentCode
 | 
												
													
														
															|  |     ) {
 |  |     ) {
 | 
												
													
														
															|  |         try {
 |  |         try {
 | 
												
													
														
															|  |             return Envelop.getSuccess(WechatContants.WxMenu.message_success_find, wxMenuService.findChildMenus(parentCode));
 |  | 
 | 
												
													
														
															|  | 
 |  |             return Envelop.getSuccess(WechatRequestMapping.WxMenu.message_success_find, wxMenuService.findChildMenus(parentCode));
 | 
												
													
														
															|  |         } catch (ApiException e) {
 |  |         } catch (ApiException e) {
 | 
												
													
														
															|  |             return Envelop.getError(e.getMessage(), e.getErrorCode());
 |  |             return Envelop.getError(e.getMessage(), e.getErrorCode());
 | 
												
													
														
															|  |         }
 |  |         }
 |