ÎļþÃû´Ó src/main/java/com/lf/server/controller/sys/RoleMenuController.java ÐÞ¸Ä |
| | |
| | | import com.lf.server.aspect.SysLog; |
| | | import com.lf.server.controller.all.BaseController; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.sys.RoleMenuEntity; |
| | | import com.lf.server.entity.sys.RoleMenuAuthEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.service.sys.RoleMenuService; |
| | | import com.lf.server.service.sys.RoleMenuAuthService; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | |
| | | */ |
| | | @Api(tags = "è¿ç»´ç®¡ç\\è§è²èå") |
| | | @RestController |
| | | @RequestMapping("/roleMenu") |
| | | public class RoleMenuController extends BaseController { |
| | | @RequestMapping("/roleMenuAuth") |
| | | public class RoleMenuAuthController extends BaseController { |
| | | @Autowired |
| | | RoleMenuService roleMenuService; |
| | | RoleMenuAuthService roleMenuAuthService; |
| | | |
| | | @Autowired |
| | | TokenService tokenService; |
| | |
| | | @GetMapping({"/selectCount"}) |
| | | public ResponseMsg<Integer> selectCount(Integer roleid) { |
| | | try { |
| | | int count = roleMenuService.selectCount(roleid); |
| | | int count = roleMenuAuthService.selectCount(roleid); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | @ApiImplicitParam(name = "pageIndex", value = "å页æ°ï¼ä»1å¼å§ï¼", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPage") |
| | | public ResponseMsg<List<RoleMenuEntity>> selectByPage(Integer roleid, Integer pageSize, Integer pageIndex) { |
| | | public ResponseMsg<List<RoleMenuAuthEntity>> selectByPage(Integer roleid, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("æ¯é¡µé¡µæ°æå页æ°å°äº1", null); |
| | | } |
| | | |
| | | List<RoleMenuEntity> rs = roleMenuService.selectByPage(roleid, pageSize, pageSize * (pageIndex - 1)); |
| | | List<RoleMenuAuthEntity> rs = roleMenuAuthService.selectByPage(roleid, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | |
| | | @ApiImplicitParam(name = "pageIndex", value = "å页æ°ï¼ä»1å¼å§ï¼", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPageAndCount") |
| | | public ResponseMsg<List<RoleMenuEntity>> selectByPageAndCount(Integer roleid, Integer pageSize, Integer pageIndex) { |
| | | public ResponseMsg<List<RoleMenuAuthEntity>> selectByPageAndCount(Integer roleid, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("æ¯é¡µé¡µæ°æå页æ°å°äº1", null); |
| | | } |
| | | int count = roleMenuService.selectCount(roleid); |
| | | int count = roleMenuAuthService.selectCount(roleid); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | List<RoleMenuEntity> rs = roleMenuService.selectByPage(roleid, pageSize, pageSize * (pageIndex - 1)); |
| | | List<RoleMenuAuthEntity> rs = roleMenuAuthService.selectByPage(roleid, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "æ¥è¯¢ææ") |
| | | @GetMapping(value = "/selectAll") |
| | | public ResponseMsg<List<RoleMenuEntity>> selectAll() { |
| | | public ResponseMsg<List<RoleMenuAuthEntity>> selectAll() { |
| | | try { |
| | | List<RoleMenuEntity> list = roleMenuService.selectAll(); |
| | | List<RoleMenuAuthEntity> list = roleMenuAuthService.selectAll(); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | |
| | | @ApiImplicitParam(name = "id", value = "ID", dataType = "int", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectById") |
| | | public ResponseMsg<RoleMenuEntity> selectById(int id) { |
| | | public ResponseMsg<RoleMenuAuthEntity> selectById(int id) { |
| | | try { |
| | | RoleMenuEntity entity = roleMenuService.selectById(id); |
| | | RoleMenuAuthEntity entity = roleMenuAuthService.selectById(id); |
| | | |
| | | return success(entity); |
| | | } catch (Exception ex) { |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "æå
¥ä¸æ¡") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "entity", value = "å®ä½ç±»", dataType = "RoleMenuEntity", paramType = "body") |
| | | @ApiImplicitParam(name = "entity", value = "å®ä½ç±»", dataType = "RoleMenuAuthEntity", paramType = "body") |
| | | }) |
| | | @PostMapping(value = "/insert", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> insert(@RequestBody RoleMenuEntity entity, HttpServletRequest req) { |
| | | public ResponseMsg<Integer> insert(@RequestBody RoleMenuAuthEntity entity, HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | entity.setCreateUser(ue.getId()); |
| | | } |
| | | |
| | | int count = roleMenuService.insert(entity); |
| | | int count = roleMenuAuthService.insert(entity); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "æå
¥å¤æ¡") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "list", value = "å®ä½ç±»éå", dataType = "RoleMenuEntity", paramType = "body") |
| | | @ApiImplicitParam(name = "list", value = "å®ä½ç±»éå", dataType = "RoleMenuAuthEntity", paramType = "body") |
| | | }) |
| | | @PostMapping(value = "/inserts", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> inserts(@RequestBody List<RoleMenuEntity> list, HttpServletRequest req) { |
| | | public ResponseMsg<Integer> inserts(@RequestBody List<RoleMenuAuthEntity> list, HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | for (RoleMenuEntity entity : list) { |
| | | for (RoleMenuAuthEntity entity : list) { |
| | | entity.setCreateUser(ue.getId()); |
| | | } |
| | | } |
| | | |
| | | int count = roleMenuService.inserts(list); |
| | | int count = roleMenuAuthService.inserts(list); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | @GetMapping(value = "/delete") |
| | | public ResponseMsg<Integer> delete(int id) { |
| | | try { |
| | | int count = roleMenuService.delete(id); |
| | | int count = roleMenuAuthService.delete(id); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | return fail("idæ°ç»ä¸è½ä¸ºç©º", -1); |
| | | } |
| | | |
| | | int count = roleMenuService.deletes(ids); |
| | | int count = roleMenuAuthService.deletes(ids); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "æ´æ°ä¸æ¡") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "entity", value = "å®ä½ç±»", dataType = "RoleMenuEntity", paramType = "body") |
| | | @ApiImplicitParam(name = "entity", value = "å®ä½ç±»", dataType = "RoleMenuAuthEntity", paramType = "body") |
| | | }) |
| | | @ResponseBody |
| | | @PostMapping(value = "/update", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> update(@RequestBody RoleMenuEntity entity, HttpServletRequest req) { |
| | | public ResponseMsg<Integer> update(@RequestBody RoleMenuAuthEntity entity, HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | entity.setUpdateUser(ue.getId()); |
| | | } |
| | | |
| | | int count = roleMenuService.update(entity); |
| | | int count = roleMenuAuthService.update(entity); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "æ´æ°å¤æ¡") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "list", value = "å®ä½ç±»éå", dataType = "RoleMenuEntity", paramType = "body") |
| | | @ApiImplicitParam(name = "list", value = "å®ä½ç±»éå", dataType = "RoleMenuAuthEntity", paramType = "body") |
| | | }) |
| | | @ResponseBody |
| | | @PostMapping(value = "/updates", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> updates(@RequestBody List<RoleMenuEntity> list, HttpServletRequest req) { |
| | | public ResponseMsg<Integer> updates(@RequestBody List<RoleMenuAuthEntity> list, HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | for (RoleMenuEntity entity : list) { |
| | | for (RoleMenuAuthEntity entity : list) { |
| | | entity.setUpdateUser(ue.getId()); |
| | | } |
| | | } |
| | | |
| | | int count = roleMenuService.updates(list); |
| | | int count = roleMenuAuthService.updates(list); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |