Commit 455b3cb6 authored by zhouqian's avatar zhouqian

Merge branch 'master' of http://gitabc.xyqb.com/head_group/xyqb-user2

# Conflicts:
#	src/main/java/cn/quantgroup/xyqb/Constants.java
parents abb505cc dacfaa5e
......@@ -45,4 +45,9 @@ public interface Constants {
String LKB_CODE = "0002"; // 量化派channnel_code
}
interface Session{
String USERS_ESSIONID_CACHE = "userid-sessionvalue:cache:";
Long ONE_DAY = 24 * 60 * 60L;
}
}
package cn.quantgroup.xyqb.model.session;
import java.io.Serializable;
/**
* Created by Miraculous on 2016/12/28.
*/
public class XyqbSession implements Serializable {
private static final long serialVersionUID = -1L;
}
......@@ -2,7 +2,6 @@ package cn.quantgroup.xyqb.service.session.impl;
import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.model.session.SessionStruct;
import cn.quantgroup.xyqb.model.session.SessionValue;
import cn.quantgroup.xyqb.service.session.ISessionService;
......@@ -25,8 +24,6 @@ import java.util.UUID;
@Service
public class SessionServiceImpl implements ISessionService{
private static final Long ONE_DAY = 24 * 60 * 60L;
@Autowired
@Qualifier("stringRedisTemplate")
private RedisTemplate<String, String> stringRedisTemplate;
......@@ -53,13 +50,12 @@ public class SessionServiceImpl implements ISessionService{
@Override
public String findSessionIdByUserId(Long userId) {
//TODO 暂时写死
return stringRedisTemplate.opsForValue().get("userid-sessionvalue:cache:" + userId.toString());
return stringRedisTemplate.opsForValue().get(Constants.Session.USERS_ESSIONID_CACHE + userId.toString());
}
@Override
public String findSessionValueBySessionId(String sessionId){
String result = stringRedisTemplate.opsForValue().get("userid-sessionvalue:cache:" + sessionId);
String result = stringRedisTemplate.opsForValue().get(Constants.Session.USERS_ESSIONID_CACHE + sessionId);
return StringUtils.defaultString(result, "");
}
......@@ -82,9 +78,7 @@ public class SessionServiceImpl implements ISessionService{
public void PersistSession(String token, SessionValue sessionValue){
Timestamp current = new Timestamp(System.currentTimeMillis());
sessionValue.setLastAccessTime(current);
// todo: session转换
String json = JSON.toJSONString(sessionValue);
// String json = Constants.GSON.toJson(sessionValue);
stringRedisTemplate.opsForValue().set("userid-sessionvalue:cache:" + token, json, ONE_DAY);
stringRedisTemplate.opsForValue().set(Constants.Session.USERS_ESSIONID_CACHE + token, json, Constants.Session.ONE_DAY);
}
}
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