Authored by xuhui

Merge branch 'master' of http://git.yoho.cn/ops/monitor-ui

... ... @@ -6,6 +6,8 @@ import com.ui.model.BaseResponse;
import com.ui.model.req.AuthModule;
import com.ui.model.req.User;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.scheduling.annotation.Async;
... ... @@ -22,6 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
@Component
@EnableAsync
public class UserAuthLocal {
Logger log = LoggerFactory.getLogger(UserAuthLocal.class);
private static ConcurrentHashMap<String, User> usermap = new ConcurrentHashMap<>();
... ... @@ -35,36 +38,39 @@ public class UserAuthLocal {
//@PostConstruct
public synchronized void init() {
try{
//加载用户信息
BaseResponse<List<User>> response = httpRestClient.exchangeForget(HttpUriContants.GET_All_USER, new ParameterizedTypeReference<BaseResponse<List<User>>>() {
}, null);
List<User> userlist = response.getData();
for (User user : userlist) {
usermap.put(user.getName(), user);
}
//加载用户信息
BaseResponse<List<User>> response = httpRestClient.exchangeForget(HttpUriContants.GET_All_USER, new ParameterizedTypeReference<BaseResponse<List<User>>>() {
}, null);
List<User> userlist = response.getData();
for (User user : userlist) {
usermap.put(user.getName(), user);
}
//加载mudule信息
BaseResponse<List<AuthModule>> moduleResponse = httpRestClient.exchangeForget(HttpUriContants.GET_All_MODULE, new ParameterizedTypeReference<BaseResponse<List<AuthModule>>>() {
}, null);
List<AuthModule> modulelist = moduleResponse.getData();
for (AuthModule module : modulelist) {
modulemap.put(module.getModuleName(), module);
}
//加载mudule信息
BaseResponse<List<AuthModule>> moduleResponse = httpRestClient.exchangeForget(HttpUriContants.GET_All_MODULE, new ParameterizedTypeReference<BaseResponse<List<AuthModule>>>() {
}, null);
List<AuthModule> modulelist = moduleResponse.getData();
for (AuthModule module : modulelist) {
modulemap.put(module.getModuleName(), module);
}
//加载module组信息
for (Map.Entry<String,AuthModule> entry : modulemap.entrySet()){
AuthModule authModule = entry.getValue();
String group = authModule.getModuleGroup();
if (StringUtils.isNotBlank(group)){
if (moduleGroupmap.containsKey(group)){
moduleGroupmap.get(group).add(entry.getKey());
}else {
Set<String> groupSet = new HashSet<>();
groupSet.add(entry.getKey());
moduleGroupmap.put(group,groupSet);
//加载module组信息
for (Map.Entry<String,AuthModule> entry : modulemap.entrySet()){
AuthModule authModule = entry.getValue();
String group = authModule.getModuleGroup();
if (StringUtils.isNotBlank(group)){
if (moduleGroupmap.containsKey(group)){
moduleGroupmap.get(group).add(entry.getKey());
}else {
Set<String> groupSet = new HashSet<>();
groupSet.add(entry.getKey());
moduleGroupmap.put(group,groupSet);
}
}
}
}catch (Exception e){
log.error(" - UserAuthLocal - init - error", e);
}
}
... ...