Commit 04dba454 authored by 陈勇's avatar 陈勇

Merge branch 'saveUserToRedis' into 'master'

验证用户名密码已经查询过用户信息,存入Redis 的用户信息不必重新查询 See merge request common/aserver!13
parents 2700d093 226a9899
...@@ -246,20 +246,22 @@ public class IndexController extends Controller { ...@@ -246,20 +246,22 @@ public class IndexController extends Controller {
/** /**
* 20200706 lidecai 将用户信息保存到Redis start * 20200706 lidecai 将用户信息保存到Redis start
*/ */
Map<String, Object> columns = Db.findById("AS_USER", "USERNAME", username).getColumns();
Map<Object, Object> userInfo = new HashMap<>(); Map<Object, Object> userInfo = new HashMap<>();
userInfo.putAll(columns); Iterator<Entry<String, Object>> userIterator = user._getAttrsEntrySet().iterator();
Entry<String, Object> nextAttr = null;
while(userIterator.hasNext()) {
nextAttr = userIterator.next();
userInfo.put(nextAttr.getKey().trim().toLowerCase(), nextAttr.getValue());
}
try { try {
Redis.use().hmset(username + "_INFO", userInfo); Redis.use().hmset(username + "_INFO", userInfo);
// 设置过期时间 // 设置过期时间
Redis.use().expire(username, 60 * 60 * 24); Redis.use().expire(username, 60 * 60 * 24);
}catch (Exception e) { }catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
}finally { }
this.renderJson(Ret.ok("token", jws).set("callback", callback)); this.renderJson(Ret.ok("token", jws).set("callback", callback));
logService.saveAsLog("login", username, JwtInterceptor.getIpAddr(getRequest()), logService.saveAsLog("login", username, JwtInterceptor.getIpAddr(getRequest()), username + "登录" + app + "成功", app);
username + "登录" + app + "成功", app);
}
/** /**
* 20200706 lidecai 将用户信息保存到Redis end * 20200706 lidecai 将用户信息保存到Redis end
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment