first commit
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package com.qingyun.system.service;
|
||||
|
||||
import com.qingyun.common.constant.TenantConstants;
|
||||
import com.qingyun.common.core.domain.entity.SysUser;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 用户权限处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysPermissionService {
|
||||
|
||||
private final ISysRoleService roleService;
|
||||
private final ISysMenuService menuService;
|
||||
|
||||
/**
|
||||
* 获取角色数据权限
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 角色权限信息
|
||||
*/
|
||||
public Set<String> getRolePermission(SysUser user) {
|
||||
Set<String> roles = new HashSet<>();
|
||||
// 管理员拥有所有权限
|
||||
if (user.isAdmin()) {
|
||||
roles.add(TenantConstants.SUPER_ADMIN_ROLE_KEY);
|
||||
} else {
|
||||
roles.addAll(roleService.selectRolePermissionByUserId(user.getUserId()));
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单数据权限
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 菜单权限信息
|
||||
*/
|
||||
public Set<String> getMenuPermission(SysUser user) {
|
||||
Set<String> perms = new HashSet<>();
|
||||
// 管理员拥有所有权限
|
||||
if (user.isAdmin()) {
|
||||
perms.add("*:*:*");
|
||||
} else {
|
||||
perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId()));
|
||||
}
|
||||
return perms;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user