|
|
@@ -3,12 +3,13 @@ package com.usoftchina.bi.server.service.user;
|
|
|
import com.usoftchina.bi.core.base.BaseContextHolder;
|
|
|
import com.usoftchina.bi.core.base.RepCode;
|
|
|
import com.usoftchina.bi.core.base.RepEntity;
|
|
|
+import com.usoftchina.bi.core.base.RoleConstant;
|
|
|
import com.usoftchina.bi.core.exception.MyException;
|
|
|
import com.usoftchina.bi.core.jdbc.DynamicDataSourceContextHolder;
|
|
|
import com.usoftchina.bi.core.utils.EncryUtil;
|
|
|
+import com.usoftchina.bi.core.utils.GetTokenDataUtil;
|
|
|
import com.usoftchina.bi.server.aspect.JwtTokenAspect;
|
|
|
import com.usoftchina.bi.server.dao.user.UserMapper;
|
|
|
-import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.usoftchina.bi.server.model.po.MessageLog;
|
|
|
import com.usoftchina.bi.server.model.po.TokenData;
|
|
|
import com.usoftchina.bi.server.model.po.User;
|
|
|
@@ -23,9 +24,10 @@ import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@@ -158,8 +160,13 @@ public class UserService {
|
|
|
查询用户列表
|
|
|
*/
|
|
|
@Cacheable(value = "userList")
|
|
|
- public RepEntity getUserList(){
|
|
|
- List<User> userList = userMapper.getUserList();
|
|
|
+ public RepEntity getUserList(String token){
|
|
|
+ Map<String, String> resultMap = GetTokenDataUtil.getTokenData(token);
|
|
|
+ String role = resultMap.get("role");
|
|
|
+ List<User> userList = new ArrayList<>();
|
|
|
+ if (RoleConstant.SUPER_ADMIN.getRole().equals(role)){
|
|
|
+ userList = userMapper.getUserList();
|
|
|
+ }
|
|
|
return new RepEntity(RepCode.success, userList);
|
|
|
}
|
|
|
|
|
|
@@ -207,8 +214,13 @@ public class UserService {
|
|
|
/*
|
|
|
查询用户组
|
|
|
*/
|
|
|
- public RepEntity getUserGroup(){
|
|
|
- List<UserGroup> userGroup= userMapper.getUserGroupList();
|
|
|
+ public RepEntity getUserGroup(String token){
|
|
|
+ Map<String, String> resultMap = GetTokenDataUtil.getTokenData(token);
|
|
|
+ String role = resultMap.get("role");
|
|
|
+ List<UserGroup> userGroup= new ArrayList<>();
|
|
|
+ if (RoleConstant.SUPER_ADMIN.getRole().equals(role)) {
|
|
|
+ userGroup= userMapper.getUserGroupList();
|
|
|
+ }
|
|
|
return new RepEntity(RepCode.success, userGroup);
|
|
|
}
|
|
|
|