¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.web.service; |
| | | |
| | | import java.util.HashSet; |
| | | import java.util.Set; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | |
| | | /** |
| | | * ç¨æ·æéå¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class SysPermissionService |
| | | { |
| | | @Autowired |
| | | private ISysRoleService roleService; |
| | | |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | |
| | | /** |
| | | * è·åè§è²æ°æ®æé |
| | | * |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return è§è²æéä¿¡æ¯ |
| | | */ |
| | | public Set<String> getRolePermission(SysUser user) |
| | | { |
| | | Set<String> roles = new HashSet<String>(); |
| | | // 管çåæ¥ææææé |
| | | if (user.isAdmin()) |
| | | { |
| | | roles.add("admin"); |
| | | } |
| | | else |
| | | { |
| | | roles.addAll(roleService.selectRolePermissionByUserId(user.getUserId())); |
| | | } |
| | | return roles; |
| | | } |
| | | |
| | | /** |
| | | * è·åèåæ°æ®æé |
| | | * |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return èåæéä¿¡æ¯ |
| | | */ |
| | | public Set<String> getMenuPermission(SysUser user) |
| | | { |
| | | Set<String> perms = new HashSet<String>(); |
| | | // 管çåæ¥ææææé |
| | | if (user.isAdmin()) |
| | | { |
| | | perms.add("*:*:*"); |
| | | } |
| | | else |
| | | { |
| | | perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId())); |
| | | } |
| | | return perms; |
| | | } |
| | | } |