登录权限获取问题、头像名字居中

This commit is contained in:
lyd
2022-09-29 09:31:12 +08:00
parent 25a336fe72
commit a2a9e94745
5 changed files with 21 additions and 22 deletions

View File

@@ -93,7 +93,7 @@ public class AuthorizationController {
}
// 获取权限列表 - 登录查找权限
List<String> permissionList = roleService.getPermissionList(userDto.getId().toString());
List<String> permissionList = roleService.getPermissionList(userDto);
// 保存用户信息到session - 登录输入,登出删除
CurrentUser user = new CurrentUser();

View File

@@ -19,6 +19,7 @@ import org.nl.modules.system.domain.Role;
import org.nl.modules.system.service.dto.RoleDto;
import org.nl.modules.system.service.dto.RoleQueryCriteria;
import org.nl.modules.system.service.dto.RoleSmallDto;
import org.nl.modules.system.service.dto.UserDto;
import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse;
@@ -122,10 +123,10 @@ public interface RoleService {
/**
* 通过id获取用户的权限
* @param id
* @param userDto
* @return
*/
List<String> getPermissionList(String id);
List<String> getPermissionList(UserDto userDto);
/**
* 验证是否被用户关联

View File

@@ -15,7 +15,6 @@
*/
package org.nl.modules.system.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -162,17 +161,16 @@ public class RoleServiceImpl implements RoleService {
}
@Override
@Cacheable(key = "'auth:' + #p0")
public List<String> getPermissionList(String id) {
@Cacheable(key = "'auth:' + #p0.id")
public List<String> getPermissionList(UserDto userDto) {
List<String> permission = new LinkedList<>();
// 查看是否为管理员
UserDto user = (UserDto) StpUtil.getSession().get("UserDto");
if (user.getIsAdmin()) { // 是管理员
if (userDto.getIsAdmin()) { // 是管理员
permission.add("admin");
}
HashMap<String, String> map = new HashMap<>();
map.put("flag", "1");
map.put("user_id", id);
map.put("user_id", userDto.getId().toString());
JSONArray rows = WQL.getWO("SYS_MENU").addParamMap(map).process().getResultJSONArray(0);
for (int i = 0; i < rows.size(); i++) {
JSONObject jsonObject = rows.getJSONObject(i);