| | |
| | | package com.whyc.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.pojo.*; |
| | | import com.whyc.service.RoleMenuService; |
| | | import com.whyc.service.RolePermissionService; |
| | | import com.whyc.service.RoleService; |
| | | import com.whyc.service.UserRoleService; |
| | | import com.whyc.service.*; |
| | | import com.whyc.util.CommonUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | |
| | | @Autowired |
| | | private RoleMenuService roleMenuService; |
| | | @Autowired |
| | | private PermissionService permissionService; |
| | | |
| | | /**=============用户与角色================**/ |
| | | |
| | | @GetMapping("userWithNoRole") |
| | | @ApiOperation(value = "查询未分配角色的用户") |
| | | // @GetMapping("userWithNoRole") |
| | | // @ApiOperation(value = "查询未分配角色的用户") |
| | | public List<User> getUserWithNoRole(){ |
| | | return userRoleService.getUserWithNoRole(); |
| | | } |
| | | |
| | | @GetMapping("userWithRole") |
| | | @ApiOperation(value = "查询分配角色的用户") |
| | | // @GetMapping("userWithRole") |
| | | // @ApiOperation(value = "查询分配角色的用户") |
| | | public List<UserRole> getUserWithRole(){ |
| | | return userRoleService.getUserWithRole(); |
| | | } |
| | | |
| | | @GetMapping("userWithRoleMap") |
| | | @ApiOperation(value = "查询分配角色的用户Map") |
| | | // @GetMapping("userWithRoleMap") |
| | | // @ApiOperation(value = "查询分配角色的用户Map") |
| | | public Map<String,List<UserRole>> getUserWithRoleMap(){ |
| | | return userRoleService.getUserWithRoleMap(); |
| | | } |
| | |
| | | return roleService.getAll(); |
| | | } |
| | | |
| | | @PostMapping("search") |
| | | @ApiOperation(value = "查询角色分页-根据筛选条件") |
| | | public Response<PageInfo<Role>> getRoleByCondition(@RequestParam int pageNum, @RequestParam int pageSize, @RequestBody Role role){ |
| | | return roleService.getRoleByCondition(pageNum,pageSize,role); |
| | | } |
| | | |
| | | @GetMapping("getUserByRoleId") |
| | | @ApiOperation(value = "通过角色id获取用户信息",notes = "点击权限人员时触发获取") |
| | | public Response<PageInfo<User>> getUserByRoleId(@RequestParam int pageNum,@RequestParam int pageSize,@RequestParam int roleId){ |
| | | return userRoleService.getUserByRoleId(pageNum,pageSize,roleId); |
| | | } |
| | | |
| | | @GetMapping("getUsersByRoleId") |
| | | @ApiOperation(value = "获取角色用户信息",notes = "点击添加人员是触发获取") |
| | | public Response getUsersByRoleId(@RequestParam int roleId){ |
| | | return userRoleService.getUsersByRoleId(roleId); |
| | | } |
| | | @PutMapping("updateRoleUser") |
| | | @ApiOperation(value = "更新角色用户信息",notes = "配置人员信息保存") |
| | | public Response updateRoleUser(@RequestParam int roleId,@RequestBody int[] userIds){ |
| | | return userRoleService.updateRoleUser(roleId,userIds); |
| | | } |
| | | |
| | | @PostMapping |
| | | @ApiOperation(value = "新增角色") |
| | | public boolean add(@RequestBody Role role){ |
| | | public Response add(@RequestBody Role role){ |
| | | return roleService.add(role); |
| | | } |
| | | |
| | | @PostMapping("batch") |
| | | @ApiOperation(value = "批量新增角色") |
| | | @PutMapping("updateRole") |
| | | @ApiOperation(value = "更新角色") |
| | | public Response updateRole(@RequestBody Role role){ |
| | | return roleService.updateRole(role); |
| | | } |
| | | |
| | | @PutMapping("updateRoleState") |
| | | @ApiOperation(value = "启用/冻结角色") |
| | | public Response updateRoleState(@RequestParam int roleId,@RequestParam int state){ |
| | | return roleService.updateRoleState(roleId,state); |
| | | } |
| | | @DeleteMapping("deleteRole") |
| | | @ApiOperation(value = "删除角色") |
| | | public Response deleteRole(@RequestParam int roleId){ |
| | | return roleService.deleteRole(roleId); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // @PostMapping("batch") |
| | | // @ApiOperation(value = "批量新增角色") |
| | | public boolean addBatch(@RequestBody List<Role> roles){ |
| | | return roleService.addBatch(roles); |
| | | } |
| | | |
| | | @PostMapping("bindingUserWithRole") |
| | | @ApiOperation(value = "绑定用户和角色") |
| | | @CacheEvict(cacheNames = {"userBridge"},key="'getAuthorizationInfo'+#p0") //清除 |
| | | // @PostMapping("bindingUserWithRole") |
| | | // @ApiOperation(value = "绑定用户和角色") |
| | | // @CacheEvict(cacheNames = {"userBridge"},key="'getAuthorizationInfo'+#p0") //清除 |
| | | public boolean bindingUserWithRole(@RequestParam int userId,int roleId){ |
| | | return userRoleService.bindingUserWithRole(userId,roleId); |
| | | } |
| | | |
| | | @PostMapping("bindingUserWithRoleBatch") |
| | | @ApiOperation(value = "批量绑定用户和角色",notes = "传入userId和roleId的数组") |
| | | @CacheEvict(cacheNames = {"userBridge"},allEntries = true) //全部清除 |
| | | // @PostMapping("bindingUserWithRoleBatch") |
| | | // @ApiOperation(value = "批量绑定用户和角色",notes = "传入userId和roleId的数组") |
| | | // @CacheEvict(cacheNames = {"userBridge"},allEntries = true) //全部清除 |
| | | public boolean bindingUserWithRoleBatch(@RequestBody List<UserRole> userRoles){ |
| | | return userRoleService.bindingUserWithRoleBatch(userRoles); |
| | | } |
| | | |
| | | /**===============角色与权限================**/ |
| | | |
| | | @PostMapping("bindingRoleWithPermission") |
| | | @ApiOperation(value = "绑定角色-权限") |
| | | @CacheEvict(cacheNames = {"userBridge"},allEntries = true) //全部清除 |
| | | // @GetMapping("allPermissions") |
| | | // @ApiOperation(value = "获取所有权限") |
| | | public List<Permission> getAllPermissions(HttpServletRequest request){ |
| | | return permissionService.getAll(); |
| | | } |
| | | |
| | | // @PostMapping("bindingRoleWithPermission") |
| | | // @ApiOperation(value = "绑定角色-权限") |
| | | // @CacheEvict(cacheNames = {"userBridge"},allEntries = true) //全部清除 |
| | | public boolean bindingRoleWithPermission(@RequestParam int roleId,int permissionId){ |
| | | return rolePermissionService.bindingUserWithRole(roleId,permissionId); |
| | | } |
| | | |
| | | @PostMapping("bindingRoleWithPermissionBatch") |
| | | @ApiOperation(value = "批量绑定角色-权限",notes = "传入roleId和privilegeId的数组") |
| | | @CacheEvict(cacheNames = {"userBridge"},allEntries = true) //全部清除 |
| | | // @PostMapping("bindingRoleWithPermissionBatch") |
| | | // @ApiOperation(value = "批量绑定角色-权限",notes = "传入roleId和privilegeId的数组") |
| | | // @CacheEvict(cacheNames = {"userBridge"},allEntries = true) //全部清除 |
| | | public boolean bindingRoleWithPermissionBatch(@RequestBody List<RolePermission> rolePermissions){ |
| | | return rolePermissionService.bindingUserWithRoleBatch(rolePermissions); |
| | | } |
| | | |
| | | @GetMapping("permissions") |
| | | @ApiOperation(value = "获取当前用户的权限") |
| | | // @GetMapping("permissions") |
| | | // @ApiOperation(value = "获取当前用户的权限") |
| | | public List<Permission> getPermissions(HttpServletRequest request){ |
| | | User user = CommonUtil.getUser(request); |
| | | //User user = CommonUtil.getUser(request); |
| | | User user = (User) SecurityUtils.getSubject().getPrincipal(); |
| | | return rolePermissionService.getPermissions(user.getId()); |
| | | } |
| | | |
| | | /**==============用户-角色-菜单================**/ |
| | | |
| | | @GetMapping("userMenu") |
| | | @ApiOperation(value = "获取当前用户的菜单") |
| | | @GetMapping("allMenus") |
| | | @ApiOperation(value = "获取所有菜单") |
| | | public List<Menu> getAllMenu(){ |
| | | return roleMenuService.getAllMenus(); |
| | | } |
| | | |
| | | @GetMapping("roleMenu") |
| | | @ApiOperation(value = "获取角色所有菜单") |
| | | public List<Menu> getMenuByRoleId(@RequestParam int roleId){ |
| | | return roleMenuService.getRoleMenu(roleId); |
| | | } |
| | | |
| | | @PutMapping("updateRoleMenu") |
| | | @ApiOperation(value = "更新角色菜单") |
| | | public Response updateRoleMenu(@RequestParam int roleId,@RequestBody int[] menuIds){ |
| | | return roleMenuService.updateRoleMenu(roleId,menuIds); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // @GetMapping("userMenu") |
| | | // @ApiOperation(value = "获取当前用户的菜单") |
| | | public List<Menu> getUserMenu(HttpServletRequest request){ |
| | | //User user = CommonUtil.getUser(request); |
| | | User user = (User) SecurityUtils.getSubject().getPrincipal(); |