Commit ab4d1bed by fukai

增加userinr至redisinfo。支持登出

parent decb74c4
...@@ -5,6 +5,7 @@ import log.LogFactory; ...@@ -5,6 +5,7 @@ import log.LogFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.sss.common.model.IDatafield;
import org.sss.common.model.ILoginContext; import org.sss.common.model.ILoginContext;
import org.sss.common.model.IMenuItem; import org.sss.common.model.IMenuItem;
import org.sss.presentation.noui.api.model.Menu; import org.sss.presentation.noui.api.model.Menu;
...@@ -89,7 +90,11 @@ public class LoginController { ...@@ -89,7 +90,11 @@ public class LoginController {
context.getSession().chain(true, "office"); context.getSession().chain(true, "office");
byte[] sysmodBytes = NoUiPresentationUtil.sysmodToBytes(context); byte[] sysmodBytes = NoUiPresentationUtil.sysmodToBytes(context);
// redis中存储用户相关信息 // redis中存储用户相关信息
IDatafield inridf = (IDatafield)context.getSession().getBaseObject(context.getRoot(),"sysmod\\usr\\inr");
RedisLoginInfo redisLoginInfo = new RedisLoginInfo(userId, token, NumericUtil.sessionTimeOut(), sysmodBytes, noUiRequest.getTerminalType()); RedisLoginInfo redisLoginInfo = new RedisLoginInfo(userId, token, NumericUtil.sessionTimeOut(), sysmodBytes, noUiRequest.getTerminalType());
redisLoginInfo.setUserInr((String)inridf.getValue()); //设置当前用户主键
RedisUtil.set(StringUtil.userUniqueId(noUiRequest), redisLoginInfo); RedisUtil.set(StringUtil.userUniqueId(noUiRequest), redisLoginInfo);
//解决初次登陆,超期限登陆 //解决初次登陆,超期限登陆
...@@ -147,10 +152,17 @@ public class LoginController { ...@@ -147,10 +152,17 @@ public class LoginController {
@ResponseBody @ResponseBody
@RequestMapping(value = "/logout", method = RequestMethod.POST) @RequestMapping(value = "/logout", method = RequestMethod.POST)
public Object logout(@RequestBody Map<String, Object> dataMap, HttpServletRequest request, HttpSession session) { public Object logout(HttpServletRequest request, HttpSession session) {
try {
NoUiRequest noUiRequest = new NoUiRequest(request, "", null);
RedisUtil.delete(StringUtil.userUniqueId(noUiRequest));
return ResultUtil.result(ErrorCodes.SUCCESS,"退出成功",null);
}catch (Exception e)
{
return "ok"; }
return ResultUtil.result(ErrorCodes.ERROR,"退出失败",null);
} }
} }
...@@ -10,6 +10,10 @@ public class RedisLoginInfo implements Serializable { ...@@ -10,6 +10,10 @@ public class RedisLoginInfo implements Serializable {
*/ */
private static final long serialVersionUID = 8116817810829835862L; private static final long serialVersionUID = 8116817810829835862L;
private String userInr;
/** /**
* 用户id * 用户id
*/ */
...@@ -91,4 +95,11 @@ public class RedisLoginInfo implements Serializable { ...@@ -91,4 +95,11 @@ public class RedisLoginInfo implements Serializable {
public void setTerminalType(String terminalType) { public void setTerminalType(String terminalType) {
this.terminalType = terminalType; this.terminalType = terminalType;
} }
public void setUserInr(String value) {
this.userInr = value;
}
public String getUserInr() {
return userInr;
}
} }
\ No newline at end of file
...@@ -153,7 +153,7 @@ public class NoUiUtils { ...@@ -153,7 +153,7 @@ public class NoUiUtils {
public static String genSafeCode(String[] keyParams) public static String genSafeCode(String[] keyParams)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb = sb.append(tl.get().getUserId()).reverse(); sb = sb.append(tl.get().getUserInr()).reverse();
for(String item : keyParams) for(String item : keyParams)
{ {
sb.append(item); sb.append(item);
......
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