修改查询用户集合对外接口改全查

master
zengwh 3 years ago
parent fa670e2f2f
commit 8eb7431071

@ -74,11 +74,10 @@ public class CommomService {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
List<User> userList = (List<User>)request.getSession().getAttribute("USER_LIST");
if(null == userList || userList.isEmpty()){
String userName = (String) request.getSession().getAttribute("userSession");
//调用接口查询
String resultString = "";
// 创建uri
String url = POWER_URLHEAD+"/font/getUserList?userName="+userName;
String url = POWER_URLHEAD+"/font/getUserList?userName=admin";
// 执行请求
CloseableHttpResponse response = HttpClients.createDefault().execute(new HttpGet(url));
// 判断返回状态是否为200
@ -86,12 +85,18 @@ public class CommomService {
resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
}
JSONObject jsonObject = JSONObject.fromObject(resultString);
String extend = jsonObject.getString("extend");
JSONObject extendObject = JSONObject.fromObject(extend);
String userList1 = extendObject.getString("userList");
userList = JSON.parseArray(userList1,User.class);
//设置进session
request.getSession().setAttribute("USER_LIST",userList);
String code = jsonObject.getString("code");
if("500".equals(code)) {
throw new RuntimeException(resultString);
}
if("100".equals(code)) {
String extend = jsonObject.getString("extend");
JSONObject extendObject = JSONObject.fromObject(extend);
String userList1 = extendObject.getString("userList");
userList = JSON.parseArray(userList1, User.class);
//设置进session
request.getSession().setAttribute("USER_LIST", userList);
}
}
return userList;
}

Loading…
Cancel
Save