com.nxyfan.framework.sys.controller.SysRoleController Maven / Gradle / Ivy
package com.nxyfan.framework.sys.controller;
import cn.hutool.core.lang.tree.Tree;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.nxyfan.framework.common.annotation.CommonLog;
import com.nxyfan.framework.common.pojo.CommonResult;
import com.nxyfan.framework.core.entity.SysRole;
import com.nxyfan.framework.core.param.*;
import com.nxyfan.framework.core.result.SysRoleOwnPermissionResult;
import com.nxyfan.framework.core.result.SysRoleOwnResourceResult;
import com.nxyfan.framework.core.service.SysRoleService;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
/**
* 角色控制器
*
* @author xuyuxiang
* @date 2022/4/25 20:19
*/
@Api(tags = "角色控制器")
@ApiSupport(author = "Nxyfan Caoyang", order = 2)
@RestController
@Validated
public class SysRoleController {
@Resource
private SysRoleService sysRoleService;
/**
* 获取角色分页
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 1)
@ApiOperation("获取角色分页")
@PostMapping("/sys/role/page")
public CommonResult> page(@RequestBody SysRolePageParam sysRolePageParam) {
return CommonResult.data(sysRoleService.page(sysRolePageParam));
}
/**
*
* Describe: 保存角色
* Author: amour
* Create Time: 2022年10月29日 下午8:16:02
* @param sysRoleSaveParam
* @return 结果
*/
@ApiOperationSupport(order = 2)
@ApiOperation("保存角色")
@CommonLog("保存角色")
@PostMapping("/sys/role/save")
public CommonResult save(@RequestBody @Valid SysRoleSaveParam sysRoleSaveParam) {
sysRoleService.save(sysRoleSaveParam);
return CommonResult.ok();
}
/**
*
* Describe: 删除角色
* Author: amour
* Create Time: 2022年10月29日 下午8:39:02
* @param sysRoleFlowParam
* @return 结果
*/
@ApiOperationSupport(order = 3)
@ApiOperation("删除角色")
@CommonLog("删除角色")
@PostMapping("/sys/role/delete")
public CommonResult delete(@Valid SysRoleFlowParam sysRoleFlowParam) {
sysRoleService.delete(sysRoleFlowParam);
return CommonResult.ok();
}
/**
* 获取角色详情
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 4)
@ApiOperation("获取角色详情")
@GetMapping("/sys/role/detail")
public CommonResult detail(@Valid SysRoleFlowParam sysRoleIdParam) {
return CommonResult.data(sysRoleService.detail(sysRoleIdParam));
}
/**
*
* Describe: 获取模块菜单授权树
* Author: amour
* Create Time: 2022年10月29日 下午8:48:54
* @param sysRoleFlowParam
* @return 结果
*/
@ApiOperationSupport(order = 5)
@ApiOperation("获取模块菜单授权树")
@GetMapping("/sys/role/moduleTreeSelector")
public CommonResult>> moduleTreeSelector(@Valid SysRoleFlowParam sysRoleFlowParam) {
return CommonResult.data(this.sysRoleService.moduleTreeSelector(sysRoleFlowParam));
}
/**
*
* Describe: 给角色授权模块菜单
* Author: amour
* Create Time: 2022年10月30日 下午2:42:33
* @param sysRoleGrantModuleParam
* @return 结果
*/
@ApiOperationSupport(order = 6)
@ApiOperation("给角色授权模块菜单")
@CommonLog("给角色授权模块菜单")
@PostMapping("/sys/role/grantModule")
public CommonResult grantModule(@RequestBody @Valid SysRoleGrantModuleParam sysRoleGrantModuleParam) {
sysRoleService.grantModule(sysRoleGrantModuleParam);
return CommonResult.ok();
}
/**
* 给角色授权资源
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
@PostMapping("/sys/role/grantResource")
public CommonResult grantResource(@RequestBody @Valid SysRoleGrantResourceParam sysRoleGrantResourceParam) {
sysRoleService.grantResource(sysRoleGrantResourceParam);
return CommonResult.ok();
}
/**
* 获取角色拥有资源
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 7)
@ApiOperation("获取角色拥有资源")
@GetMapping("/sys/role/ownResource")
public CommonResult ownResource(@Valid SysRoleFlowParam sysRoleIdParam) {
return CommonResult.data(sysRoleService.ownResource(sysRoleIdParam));
}
/**
* 获取角色拥有权限
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 8)
@ApiOperation("获取角色拥有权限")
@GetMapping("/sys/role/ownPermission")
public CommonResult ownPermission(@Valid SysRoleFlowParam sysRoleIdParam) {
return CommonResult.data(sysRoleService.ownPermission(sysRoleIdParam));
}
/**
* 给角色授权权限
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 9)
@ApiOperation("给角色授权权限")
@CommonLog("给角色授权权限")
@PostMapping("/sys/role/grantPermission")
public CommonResult grantPermission(@RequestBody @Valid SysRoleGrantPermissionParam sysRoleGrantPermissionParam) {
sysRoleService.grantPermission(sysRoleGrantPermissionParam);
return CommonResult.ok();
}
/**
* 获取角色下的用户
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 10)
@ApiOperation("获取角色下的用户")
@GetMapping("/sys/role/ownUser")
public CommonResult> ownUser(@Valid SysRoleFlowParam sysRoleIdParam) {
return CommonResult.data(sysRoleService.ownUser(sysRoleIdParam));
}
/**
* 给角色授权用户
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 11)
@ApiOperation("给角色授权用户")
@CommonLog("给角色授权用户")
@PostMapping("/sys/role/grantUser")
public CommonResult grantUser(@RequestBody @Valid SysRoleGrantUserParam sysRoleGrantUserParam) {
sysRoleService.grantUser(sysRoleGrantUserParam);
return CommonResult.ok();
}
/* ====角色部分所需要用到的选择器==== */
/**
*
* Describe: 获取权限授权树
* Author: caoyang
* Create Time: 2022年12月8日 上午9:07:46
* @return 结果
*/
@ApiOperationSupport(order = 14)
@ApiOperation("获取权限授权树")
@GetMapping("/sys/role/permissionTreeSelector")
public CommonResult> permissionTreeSelector() {
return CommonResult.data(sysRoleService.permissionTreeSelector());
}
/**
* 获取角色选择器
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 15)
@ApiOperation("获取角色选择器")
@GetMapping("/sys/role/roleSelector")
public CommonResult> roleSelector(SysRoleSelectorRoleParam sysRoleSelectorRoleParam) {
return CommonResult.data(sysRoleService.roleSelector(sysRoleSelectorRoleParam));
}
/**
* 获取用户选择器
*
* @author jax
* @date 2022/10/18 20:00
*/
@ApiOperationSupport(order = 17)
@ApiOperation("获取页面统计数据")
@GetMapping("/sys/role/summary")
public CommonResult summary(SysRolePageParam sysRolePageParam) {
return CommonResult.data(sysRoleService.summary(sysRolePageParam));
}
}