| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 角色-资源 |
| | | * @author WWW |
| | | */ |
| | | @SuppressWarnings("ALL") |
| | | @Api(tags = "运维管理\\角色资源") |
| | | @RestController |
| | | @RequestMapping("/roleRes") |
| | |
| | | PermsService permsService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询记录数") |
| | | @ApiOperation(value = "根据角色ID查询资源") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "roleid", value = "角色ID", dataType = "Integer", paramType = "query", required = false, example = "") |
| | | @ApiImplicitParam(name = "roleid", value = "角色ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping({"/selectCount"}) |
| | | public ResponseMsg<Integer> selectCount(Integer roleid) { |
| | | @GetMapping(value = "/selectResByRole") |
| | | public ResponseMsg<List<RoleResEntity>> selectResByRole(Integer roleid) { |
| | | try { |
| | | int count = roleResService.selectCount(roleid); |
| | | List<RoleResEntity> rs = roleResService.selectResByRole(roleid); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex, -1); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "roleid", value = "角色ID", dataType = "Integer", paramType = "query", example = ""), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPage") |
| | | public ResponseMsg<List<RoleResEntity>> selectByPage(Integer roleid, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | |
| | | List<RoleResEntity> rs = roleResService.selectByPage(roleid, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(rs); |
| | | return success(null == rs ? 0 : rs.size(), rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询并返回记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "roleid", value = "角色ID", dataType = "Integer", paramType = "query", example = ""), |
| | | @ApiImplicitParam(name = "roleid", value = "角色ID", dataType = "Integer", paramType = "query", example = "1"), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | |
| | | int count = roleResService.selectCount(roleid); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | |
| | | List<RoleResEntity> rs = roleResService.selectByPage(roleid, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询所有") |
| | | @GetMapping(value = "/selectAll") |
| | | public ResponseMsg<List<RoleResEntity>> selectAll() { |
| | | try { |
| | | List<RoleResEntity> list = roleResService.selectAll(); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | |
| | | entity.setCreateUser(ue.getId()); |
| | | } |
| | | |
| | | permsService.clearPermsCache(); |
| | | int count = roleResService.insert(entity); |
| | | if (count > 0) { |
| | | permsService.clearResCache(); |
| | | } |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | } |
| | | } |
| | | |
| | | permsService.clearPermsCache(); |
| | | int count = roleResService.inserts(list); |
| | | if (count > 0) { |
| | | permsService.clearResCache(); |
| | | } |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | @GetMapping(value = "/delete") |
| | | public ResponseMsg<Integer> delete(int id) { |
| | | try { |
| | | permsService.clearPermsCache(); |
| | | int count = roleResService.delete(id); |
| | | if (count > 0) { |
| | | permsService.clearResCache(); |
| | | } |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | return fail("id数组不能为空", -1); |
| | | } |
| | | |
| | | permsService.clearPermsCache(); |
| | | int count = roleResService.deletes(ids); |
| | | if (count > 0) { |
| | | permsService.clearResCache(); |
| | | } |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | entity.setUpdateUser(ue.getId()); |
| | | } |
| | | |
| | | permsService.clearPermsCache(); |
| | | int count = roleResService.update(entity); |
| | | if (count > 0) { |
| | | permsService.clearResCache(); |
| | | } |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | } |
| | | } |
| | | |
| | | permsService.clearPermsCache(); |
| | | int count = roleResService.updates(list); |
| | | if (count > 0) { |
| | | permsService.clearResCache(); |
| | | } |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |