Merge branch 'master' of http://git.yoho.cn/ops/monitor-ui
Showing
1 changed file
with
32 additions
and
26 deletions
@@ -6,6 +6,8 @@ import com.ui.model.BaseResponse; | @@ -6,6 +6,8 @@ import com.ui.model.BaseResponse; | ||
6 | import com.ui.model.req.AuthModule; | 6 | import com.ui.model.req.AuthModule; |
7 | import com.ui.model.req.User; | 7 | import com.ui.model.req.User; |
8 | import org.apache.commons.lang.StringUtils; | 8 | import org.apache.commons.lang.StringUtils; |
9 | +import org.slf4j.Logger; | ||
10 | +import org.slf4j.LoggerFactory; | ||
9 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
10 | import org.springframework.core.ParameterizedTypeReference; | 12 | import org.springframework.core.ParameterizedTypeReference; |
11 | import org.springframework.scheduling.annotation.Async; | 13 | import org.springframework.scheduling.annotation.Async; |
@@ -22,6 +24,7 @@ import java.util.concurrent.ConcurrentHashMap; | @@ -22,6 +24,7 @@ import java.util.concurrent.ConcurrentHashMap; | ||
22 | @Component | 24 | @Component |
23 | @EnableAsync | 25 | @EnableAsync |
24 | public class UserAuthLocal { | 26 | public class UserAuthLocal { |
27 | + Logger log = LoggerFactory.getLogger(UserAuthLocal.class); | ||
25 | 28 | ||
26 | private static ConcurrentHashMap<String, User> usermap = new ConcurrentHashMap<>(); | 29 | private static ConcurrentHashMap<String, User> usermap = new ConcurrentHashMap<>(); |
27 | 30 | ||
@@ -35,36 +38,39 @@ public class UserAuthLocal { | @@ -35,36 +38,39 @@ public class UserAuthLocal { | ||
35 | 38 | ||
36 | //@PostConstruct | 39 | //@PostConstruct |
37 | public synchronized void init() { | 40 | public synchronized void init() { |
41 | + try{ | ||
42 | + //加载用户信息 | ||
43 | + BaseResponse<List<User>> response = httpRestClient.exchangeForget(HttpUriContants.GET_All_USER, new ParameterizedTypeReference<BaseResponse<List<User>>>() { | ||
44 | + }, null); | ||
45 | + List<User> userlist = response.getData(); | ||
46 | + for (User user : userlist) { | ||
47 | + usermap.put(user.getName(), user); | ||
48 | + } | ||
38 | 49 | ||
39 | - //加载用户信息 | ||
40 | - BaseResponse<List<User>> response = httpRestClient.exchangeForget(HttpUriContants.GET_All_USER, new ParameterizedTypeReference<BaseResponse<List<User>>>() { | ||
41 | - }, null); | ||
42 | - List<User> userlist = response.getData(); | ||
43 | - for (User user : userlist) { | ||
44 | - usermap.put(user.getName(), user); | ||
45 | - } | ||
46 | - | ||
47 | - //加载mudule信息 | ||
48 | - BaseResponse<List<AuthModule>> moduleResponse = httpRestClient.exchangeForget(HttpUriContants.GET_All_MODULE, new ParameterizedTypeReference<BaseResponse<List<AuthModule>>>() { | ||
49 | - }, null); | ||
50 | - List<AuthModule> modulelist = moduleResponse.getData(); | ||
51 | - for (AuthModule module : modulelist) { | ||
52 | - modulemap.put(module.getModuleName(), module); | ||
53 | - } | 50 | + //加载mudule信息 |
51 | + BaseResponse<List<AuthModule>> moduleResponse = httpRestClient.exchangeForget(HttpUriContants.GET_All_MODULE, new ParameterizedTypeReference<BaseResponse<List<AuthModule>>>() { | ||
52 | + }, null); | ||
53 | + List<AuthModule> modulelist = moduleResponse.getData(); | ||
54 | + for (AuthModule module : modulelist) { | ||
55 | + modulemap.put(module.getModuleName(), module); | ||
56 | + } | ||
54 | 57 | ||
55 | - //加载module组信息 | ||
56 | - for (Map.Entry<String,AuthModule> entry : modulemap.entrySet()){ | ||
57 | - AuthModule authModule = entry.getValue(); | ||
58 | - String group = authModule.getModuleGroup(); | ||
59 | - if (StringUtils.isNotBlank(group)){ | ||
60 | - if (moduleGroupmap.containsKey(group)){ | ||
61 | - moduleGroupmap.get(group).add(entry.getKey()); | ||
62 | - }else { | ||
63 | - Set<String> groupSet = new HashSet<>(); | ||
64 | - groupSet.add(entry.getKey()); | ||
65 | - moduleGroupmap.put(group,groupSet); | 58 | + //加载module组信息 |
59 | + for (Map.Entry<String,AuthModule> entry : modulemap.entrySet()){ | ||
60 | + AuthModule authModule = entry.getValue(); | ||
61 | + String group = authModule.getModuleGroup(); | ||
62 | + if (StringUtils.isNotBlank(group)){ | ||
63 | + if (moduleGroupmap.containsKey(group)){ | ||
64 | + moduleGroupmap.get(group).add(entry.getKey()); | ||
65 | + }else { | ||
66 | + Set<String> groupSet = new HashSet<>(); | ||
67 | + groupSet.add(entry.getKey()); | ||
68 | + moduleGroupmap.put(group,groupSet); | ||
69 | + } | ||
66 | } | 70 | } |
67 | } | 71 | } |
72 | + }catch (Exception e){ | ||
73 | + log.error(" - UserAuthLocal - init - error", e); | ||
68 | } | 74 | } |
69 | } | 75 | } |
70 | 76 |
-
Please register or login to post a comment