| | |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.secure.annotation.PreAuth; |
| | | import org.springblade.core.secure.constant.AuthConstant; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | |
| | | @AllArgsConstructor |
| | | @RequestMapping("/role") |
| | | @Api(value = "角色", tags = "角色") |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | //@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public class RoleController extends BladeController { |
| | | |
| | | private final IRoleService roleService; |
| | |
| | | @ApiOperation(value = "列表", notes = "传入role") |
| | | public R<List<RoleVO>> list(@ApiIgnore @RequestParam Map<String, Object> role, BladeUser bladeUser) { |
| | | QueryWrapper<Role> queryWrapper = Condition.getQueryWrapper(role, Role.class); |
| | | // 不是超级管理员,排除超级管理员查询 |
| | | if (!AuthUtil.isAdministrator()){ |
| | | queryWrapper.ne("ROLE_ALIAS", "administrator"); |
| | | } |
| | | List<Role> list = roleService.list((!bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)) ? queryWrapper.lambda().eq(Role::getTenantId, bladeUser.getTenantId()) : queryWrapper); |
| | | return R.data(RoleWrapper.build().listNodeVO(list)); |
| | | } |
| | |
| | | return R.data(tree); |
| | | } |
| | | |
| | | @GetMapping("/treeByParentId") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "树形结构", notes = "树形结构") |
| | | public R<List<RoleVO>> treeByParentId(String parentId) { |
| | | List<RoleVO> tree = roleService.treeByParentId(parentId); |
| | | return R.data(tree); |
| | | } |
| | | |
| | | /** |
| | | * 根据父级角色查询子角色 |
| | | * @param parentId |
| | | * @return |
| | | */ |
| | | @GetMapping("/treeByParentIdNew") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "树形结构", notes = "树形结构") |
| | | public R<List<RoleVO>> treeByParentIdNew(String parentId) { |
| | | List<RoleVO> tree = roleService.treeByParentIdNew(parentId); |
| | | return R.data(tree); |
| | | } |
| | | /** |
| | | * 获取指定角色树形结构 |
| | | */ |
| | |
| | | @PostMapping("/grant") |
| | | @ApiOperationSupport(order = 7) |
| | | @ApiOperation(value = "权限设置", notes = "传入roleId集合以及menuId集合") |
| | | // @PreAuth(AuthConstant.HAS_ROLE_ADMIN) |
| | | public R grant(@RequestBody GrantVO grantVO) { |
| | | CacheUtil.clear(SYS_CACHE); |
| | | CacheUtil.clear(SYS_CACHE, Boolean.FALSE); |