| | |
| | | package com.lf.server.controller.data; |
| | | |
| | | import com.lf.server.controller.BaseController; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.data.DictEntity; |
| | | import com.lf.server.entity.data.MenusEntity; |
| | | import com.lf.server.service.data.MenusService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | * @date 2022-09-23 |
| | | */ |
| | | |
| | | @Api(tags= "菜单管理") |
| | | @RestController |
| | | @RequestMapping("/Menu") |
| | | public class MenusController { |
| | | public class MenusController extends BaseController { |
| | | @Autowired |
| | | MenusService menuService; |
| | | |
| | | @ApiOperation(value = "插入一条数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "MenusEntity", value = "字典实体类", dataType = "com.lf.server.entity.data.MenusEntity", paramType = "body", example = "") |
| | | }) |
| | | @RequestMapping(value = "/insertMenu", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public Integer insertMenu(MenusEntity menusEntity) { |
| | | |
| | | return menuService.insertMenu(menusEntity); |
| | | } |
| | | |
| | | @RequestMapping(value = "/insertMenus", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public Integer insertMenus(@RequestBody List<MenusEntity> menusEntity) { |
| | | |
| | | return menuService.insertMenus(menusEntity); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value = "/deleteMenu", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public Integer deleteMenu(int id) { |
| | | return menuService.deleteMenu(id); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/deleteMenus", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public Integer deleteMenus(@RequestBody List<Integer> ids) { |
| | | if (!ids.isEmpty()) { |
| | | return menuService.deleteMenus(ids); |
| | | } else { |
| | | return -1; |
| | | public ResponseMsg<Integer> insertMenu(MenusEntity menusEntity) { |
| | | try { |
| | | int count = menuService.insertMenu(menusEntity); |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "插入多条数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "MenusEntity", value = "字典实体类", dataType = "com.lf.server.entity.data.MenusEntity", paramType = "body", example = "") |
| | | }) |
| | | @RequestMapping(value = "/insertMenus", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> insertMenus(@RequestBody List<MenusEntity> menusEntity) { |
| | | try { |
| | | int count = menuService.insertMenus(menusEntity); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "删除一条数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/deleteMenu") |
| | | public ResponseMsg<Integer> deleteMenu(int id) { |
| | | try { |
| | | int count = menuService.deleteMenu(id); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "删除多条数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/deleteMenus") |
| | | public ResponseMsg<Integer> deleteMenus( List<Integer> ids) { |
| | | try { |
| | | if (ids == null || ids.isEmpty()) { |
| | | return fail("id数组不能为空", -1); |
| | | } |
| | | |
| | | int count = menuService.deleteMenus(ids); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "更新一条数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "MenusEntity", value = "菜单ID集合", dataType = "MenusEntity", paramType = "body", example = "") |
| | | }) |
| | | @ResponseBody |
| | | @RequestMapping(value = "/updateMenu", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public Integer updateMenu(MenusEntity menusEntity) { |
| | | return menuService.updateMenu(menusEntity); |
| | | public ResponseMsg<Integer> updateMenu(MenusEntity menusEntity) { |
| | | try { |
| | | int count = menuService.updateMenu(menusEntity); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "根据ID查询字典") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "字典ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectMenu") |
| | | public MenusEntity selectMenu(int id) { |
| | | return menuService.selectMenu(id); |
| | | public ResponseMsg<MenusEntity> selectMenu(int id) { |
| | | try { |
| | | MenusEntity menusEntity = menuService.selectMenu(id); |
| | | |
| | | return success(menusEntity); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "查询所有字典") |
| | | @GetMapping(value = "/selectMenuAll") |
| | | public List<MenusEntity> selectMenuAll() { |
| | | return menuService.selectMenuAll(); |
| | | public ResponseMsg<List<MenusEntity>> selectMenuAll() { |
| | | try { |
| | | List<MenusEntity> list = menuService.selectMenuAll(); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | } |