|
@@ -1,5 +1,6 @@
|
|
package com.gis.admin.controller;
|
|
package com.gis.admin.controller;
|
|
|
|
|
|
|
|
+import com.gis.admin.entity.po.SysRoleEntity;
|
|
import com.gis.common.base.entity.po.LogEntity;
|
|
import com.gis.common.base.entity.po.LogEntity;
|
|
import com.gis.common.base.service.LogService;
|
|
import com.gis.common.base.service.LogService;
|
|
import com.gis.common.constant.ConfigConstant;
|
|
import com.gis.common.constant.ConfigConstant;
|
|
@@ -88,10 +89,12 @@ public class LoginController {
|
|
}
|
|
}
|
|
|
|
|
|
Long userId = entity.getId();
|
|
Long userId = entity.getId();
|
|
- Object role = getRole(userId);
|
|
|
|
|
|
+// Object role = getRole(userId);
|
|
|
|
+ SysRoleEntity role = getRole(userId);
|
|
log.info("role: {}", role);
|
|
log.info("role: {}", role);
|
|
|
|
+ String roleKey = role.getRoleKey();
|
|
|
|
|
|
- if ("cms".equals(from) && ((Set) role).contains("sys_visitor")) {
|
|
|
|
|
|
+ if ("cms".equals(from) && roleKey.contains("sys_visitor")) {
|
|
log.error("游客不能登录管理后台");
|
|
log.error("游客不能登录管理后台");
|
|
return Result.failure("非法用户");
|
|
return Result.failure("非法用户");
|
|
}
|
|
}
|
|
@@ -113,7 +116,7 @@ public class LoginController {
|
|
HashMap<String, Object> tokenMap = new HashMap<>();
|
|
HashMap<String, Object> tokenMap = new HashMap<>();
|
|
tokenMap.put("userName", entity.getUserName());
|
|
tokenMap.put("userName", entity.getUserName());
|
|
tokenMap.put("id", userId);
|
|
tokenMap.put("id", userId);
|
|
- tokenMap.put("role", role);
|
|
|
|
|
|
+ tokenMap.put("role", getRoleKey(userId));
|
|
|
|
|
|
String token = JwtUtil.createJWT(TOKEN_EXPIRE, tokenMap);
|
|
String token = JwtUtil.createJWT(TOKEN_EXPIRE, tokenMap);
|
|
|
|
|
|
@@ -122,7 +125,8 @@ public class LoginController {
|
|
result.put("user", entity);
|
|
result.put("user", entity);
|
|
result.put("token", token);
|
|
result.put("token", token);
|
|
// 角色控制系统管理(sys_admin)、内容管理
|
|
// 角色控制系统管理(sys_admin)、内容管理
|
|
- result.put("role", role);
|
|
|
|
|
|
+ result.put("role", roleKey);
|
|
|
|
+ result.put("roleName", role.getRoleName());
|
|
|
|
|
|
|
|
|
|
// 保存操作日志
|
|
// 保存操作日志
|
|
@@ -177,10 +181,14 @@ public class LoginController {
|
|
* @param userId
|
|
* @param userId
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private Set<String> getRole(Long userId){
|
|
|
|
|
|
+ private Set<String> getRoleKey(Long userId){
|
|
Set<String> roleKeys = sysRoleService.findRoleKeyByUserId(userId);
|
|
Set<String> roleKeys = sysRoleService.findRoleKeyByUserId(userId);
|
|
return roleKeys;
|
|
return roleKeys;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private SysRoleEntity getRole(Long userId){
|
|
|
|
+ return sysRoleService.findByUserId(userId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|