feat(商城): 代码优化
parent
400b8cc3bb
commit
7bdb327605
@ -1,55 +0,0 @@
|
||||
package com.wayn.admin.framework.security.service;
|
||||
|
||||
import com.wayn.common.core.domain.system.User;
|
||||
import com.wayn.common.core.service.system.IMenuService;
|
||||
import com.wayn.common.core.service.system.IRoleService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 用户权限处理
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class SysPermissionService {
|
||||
private IRoleService roleService;
|
||||
|
||||
private IMenuService menuService;
|
||||
|
||||
/**
|
||||
* 获取角色数据权限
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 角色权限信息
|
||||
*/
|
||||
public Set<String> getRolePermission(User user) {
|
||||
Set<String> roles = new HashSet<>();
|
||||
// 管理员拥有所有权限
|
||||
if (user.isAdmin()) {
|
||||
roles.add("admin");
|
||||
} else {
|
||||
roles.addAll(roleService.selectRoleByUserId(user.getUserId()));
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单数据权限
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 菜单权限信息
|
||||
*/
|
||||
public Set<String> getMenuPermission(User user) {
|
||||
Set<String> perms = new HashSet<>();
|
||||
// 管理员拥有所有权限
|
||||
if (user.isAdmin()) {
|
||||
perms.add("*:*:*");
|
||||
} else {
|
||||
perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId()));
|
||||
}
|
||||
return perms;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue