格式化
This commit is contained in:
parent
89840aa576
commit
7b0d497748
|
@ -9,10 +9,10 @@ import net.maku.framework.security.user.SecurityUser;
|
|||
import net.maku.framework.security.user.UserDetail;
|
||||
import net.maku.system.convert.SysRoleConvert;
|
||||
import net.maku.system.entity.SysRoleEntity;
|
||||
import net.maku.system.query.SysRoleQuery;
|
||||
import net.maku.system.query.SysRoleUserQuery;
|
||||
import net.maku.system.service.*;
|
||||
import net.maku.system.vo.SysMenuVO;
|
||||
import net.maku.system.query.SysRoleQuery;
|
||||
import net.maku.system.vo.SysRoleDataScopeVO;
|
||||
import net.maku.system.vo.SysRoleVO;
|
||||
import net.maku.system.vo.SysUserVO;
|
||||
|
@ -24,129 +24,129 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 角色管理
|
||||
*
|
||||
*
|
||||
* @author 阿沐 babamu@126.com
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("sys/role")
|
||||
@Tag(name="角色管理")
|
||||
@Tag(name = "角色管理")
|
||||
@AllArgsConstructor
|
||||
public class SysRoleController {
|
||||
private final SysRoleService sysRoleService;
|
||||
private final SysUserService sysUserService;
|
||||
private final SysRoleMenuService sysRoleMenuService;
|
||||
private final SysRoleDataScopeService sysRoleDataScopeService;
|
||||
private final SysMenuService sysMenuService;
|
||||
private final SysUserRoleService sysUserRoleService;
|
||||
private final SysRoleService sysRoleService;
|
||||
private final SysUserService sysUserService;
|
||||
private final SysRoleMenuService sysRoleMenuService;
|
||||
private final SysRoleDataScopeService sysRoleDataScopeService;
|
||||
private final SysMenuService sysMenuService;
|
||||
private final SysUserRoleService sysUserRoleService;
|
||||
|
||||
@GetMapping("page")
|
||||
@Operation(summary = "分页")
|
||||
@PreAuthorize("hasAuthority('sys:role:page')")
|
||||
public Result<PageResult<SysRoleVO>> page(@Valid SysRoleQuery query){
|
||||
PageResult<SysRoleVO> page = sysRoleService.page(query);
|
||||
@GetMapping("page")
|
||||
@Operation(summary = "分页")
|
||||
@PreAuthorize("hasAuthority('sys:role:page')")
|
||||
public Result<PageResult<SysRoleVO>> page(@Valid SysRoleQuery query) {
|
||||
PageResult<SysRoleVO> page = sysRoleService.page(query);
|
||||
|
||||
return Result.ok(page);
|
||||
}
|
||||
return Result.ok(page);
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
@Operation(summary = "列表")
|
||||
@PreAuthorize("hasAuthority('sys:role:list')")
|
||||
public Result<List<SysRoleVO>> list(){
|
||||
List<SysRoleVO> list = sysRoleService.getList(new SysRoleQuery());
|
||||
@GetMapping("list")
|
||||
@Operation(summary = "列表")
|
||||
@PreAuthorize("hasAuthority('sys:role:list')")
|
||||
public Result<List<SysRoleVO>> list() {
|
||||
List<SysRoleVO> list = sysRoleService.getList(new SysRoleQuery());
|
||||
|
||||
return Result.ok(list);
|
||||
}
|
||||
return Result.ok(list);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@Operation(summary = "信息")
|
||||
@PreAuthorize("hasAuthority('sys:role:info')")
|
||||
public Result<SysRoleVO> get(@PathVariable("id") Long id){
|
||||
SysRoleEntity entity = sysRoleService.getById(id);
|
||||
@GetMapping("{id}")
|
||||
@Operation(summary = "信息")
|
||||
@PreAuthorize("hasAuthority('sys:role:info')")
|
||||
public Result<SysRoleVO> get(@PathVariable("id") Long id) {
|
||||
SysRoleEntity entity = sysRoleService.getById(id);
|
||||
|
||||
// 转换对象
|
||||
SysRoleVO role = SysRoleConvert.INSTANCE.convert(entity);
|
||||
// 转换对象
|
||||
SysRoleVO role = SysRoleConvert.INSTANCE.convert(entity);
|
||||
|
||||
// 查询角色对应的菜单
|
||||
List<Long> menuIdList = sysRoleMenuService.getMenuIdList(id);
|
||||
role.setMenuIdList(menuIdList);
|
||||
// 查询角色对应的菜单
|
||||
List<Long> menuIdList = sysRoleMenuService.getMenuIdList(id);
|
||||
role.setMenuIdList(menuIdList);
|
||||
|
||||
// 查询角色对应的数据权限
|
||||
List<Long> orgIdList = sysRoleDataScopeService.getOrgIdList(id);
|
||||
role.setOrgIdList(orgIdList);
|
||||
// 查询角色对应的数据权限
|
||||
List<Long> orgIdList = sysRoleDataScopeService.getOrgIdList(id);
|
||||
role.setOrgIdList(orgIdList);
|
||||
|
||||
return Result.ok(role);
|
||||
}
|
||||
return Result.ok(role);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "保存", hidden = true)
|
||||
@PreAuthorize("hasAuthority('sys:role:save')")
|
||||
public Result<String> save(@RequestBody @Valid SysRoleVO vo){
|
||||
sysRoleService.save(vo);
|
||||
@PostMapping
|
||||
@Operation(summary = "保存")
|
||||
@PreAuthorize("hasAuthority('sys:role:save')")
|
||||
public Result<String> save(@RequestBody @Valid SysRoleVO vo) {
|
||||
sysRoleService.save(vo);
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Operation(summary = "修改")
|
||||
@PreAuthorize("hasAuthority('sys:role:update')")
|
||||
public Result<String> update(@RequestBody @Valid SysRoleVO vo){
|
||||
sysRoleService.update(vo);
|
||||
@PutMapping
|
||||
@Operation(summary = "修改")
|
||||
@PreAuthorize("hasAuthority('sys:role:update')")
|
||||
public Result<String> update(@RequestBody @Valid SysRoleVO vo) {
|
||||
sysRoleService.update(vo);
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@PutMapping("data-scope")
|
||||
@Operation(summary = "数据权限")
|
||||
@PreAuthorize("hasAuthority('sys:role:update')")
|
||||
public Result<String> dataScope(@RequestBody @Valid SysRoleDataScopeVO vo){
|
||||
sysRoleService.dataScope(vo);
|
||||
@PutMapping("data-scope")
|
||||
@Operation(summary = "数据权限")
|
||||
@PreAuthorize("hasAuthority('sys:role:update')")
|
||||
public Result<String> dataScope(@RequestBody @Valid SysRoleDataScopeVO vo) {
|
||||
sysRoleService.dataScope(vo);
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Operation(summary = "删除")
|
||||
@PreAuthorize("hasAuthority('sys:role:delete')")
|
||||
public Result<String> delete(@RequestBody List<Long> idList){
|
||||
sysRoleService.delete(idList);
|
||||
@DeleteMapping
|
||||
@Operation(summary = "删除")
|
||||
@PreAuthorize("hasAuthority('sys:role:delete')")
|
||||
public Result<String> delete(@RequestBody List<Long> idList) {
|
||||
sysRoleService.delete(idList);
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@GetMapping("menu")
|
||||
@Operation(summary = "角色菜单")
|
||||
@PreAuthorize("hasAuthority('sys:role:menu')")
|
||||
public Result<List<SysMenuVO>> menu(){
|
||||
UserDetail user = SecurityUser.getUser();
|
||||
List<SysMenuVO> list = sysMenuService.getUserMenuList(user, null);
|
||||
@GetMapping("menu")
|
||||
@Operation(summary = "角色菜单")
|
||||
@PreAuthorize("hasAuthority('sys:role:menu')")
|
||||
public Result<List<SysMenuVO>> menu() {
|
||||
UserDetail user = SecurityUser.getUser();
|
||||
List<SysMenuVO> list = sysMenuService.getUserMenuList(user, null);
|
||||
|
||||
return Result.ok(list);
|
||||
}
|
||||
return Result.ok(list);
|
||||
}
|
||||
|
||||
@GetMapping("user/page")
|
||||
@Operation(summary = "角色用户-分页")
|
||||
@PreAuthorize("hasAuthority('sys:role:update')")
|
||||
public Result<PageResult<SysUserVO>> userPage(@Valid SysRoleUserQuery query){
|
||||
PageResult<SysUserVO> page = sysUserService.roleUserPage(query);
|
||||
@GetMapping("user/page")
|
||||
@Operation(summary = "角色用户-分页")
|
||||
@PreAuthorize("hasAuthority('sys:role:update')")
|
||||
public Result<PageResult<SysUserVO>> userPage(@Valid SysRoleUserQuery query) {
|
||||
PageResult<SysUserVO> page = sysUserService.roleUserPage(query);
|
||||
|
||||
return Result.ok(page);
|
||||
}
|
||||
return Result.ok(page);
|
||||
}
|
||||
|
||||
@DeleteMapping("user/{roleId}")
|
||||
@Operation(summary = "删除角色用户")
|
||||
@PreAuthorize("hasAuthority('sys:role:update')")
|
||||
public Result<String> userDelete(@PathVariable("roleId") Long roleId, @RequestBody List<Long> userIdList){
|
||||
sysUserRoleService.deleteByUserIdList(roleId, userIdList);
|
||||
@DeleteMapping("user/{roleId}")
|
||||
@Operation(summary = "删除角色用户")
|
||||
@PreAuthorize("hasAuthority('sys:role:update')")
|
||||
public Result<String> userDelete(@PathVariable("roleId") Long roleId, @RequestBody List<Long> userIdList) {
|
||||
sysUserRoleService.deleteByUserIdList(roleId, userIdList);
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@PostMapping("user/{roleId}")
|
||||
@Operation(summary = "分配角色给用户列表")
|
||||
@PreAuthorize("hasAuthority('sys:role:update')")
|
||||
public Result<String> userSave(@PathVariable("roleId") Long roleId, @RequestBody List<Long> userIdList){
|
||||
sysUserRoleService.saveUserList(roleId, userIdList);
|
||||
@PostMapping("user/{roleId}")
|
||||
@Operation(summary = "分配角色给用户列表")
|
||||
@PreAuthorize("hasAuthority('sys:role:update')")
|
||||
public Result<String> userSave(@PathVariable("roleId") Long roleId, @RequestBody List<Long> userIdList) {
|
||||
sysUserRoleService.saveUserList(roleId, userIdList);
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
return Result.ok();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user