Commit 28890c05 authored by zhouqian's avatar zhouqian

登录增加系统key

parent c6910d8c
......@@ -7,6 +7,7 @@ import cn.quantgroup.xyqb.repository.IMerchantRepository;
import cn.quantgroup.xyqb.service.merchant.IMerchantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.PostConstruct;
import java.util.List;
......@@ -53,6 +54,9 @@ public class MerchantServiceImpl implements IMerchantService {
@Override
public Merchant findMerchantByName(String name) {
if (StringUtils.isEmpty(name)) {
return null;
}
return MERCHANT_NAME_MAP.containsKey(name) ? MERCHANT_NAME_MAP.get(name) : null;
}
......
......@@ -17,7 +17,7 @@ public interface ISessionService {
String findSessionIdByUserIdAndMerchant(Long userId, Merchant merchant);
String findSessionValueBySessionId(String sessionId);
SessionStruct newSession(User user);
SessionStruct newSession(User user, Merchant merchant);
void persistSession(String token, SessionValue sessionValue);
SessionStruct findSessionBySessionId(String sessionId);
......
......@@ -45,7 +45,7 @@ public class SessionServiceImpl implements ISessionService{
sessionStruct = new SessionStruct();
String sessionValue = findSessionValueBySessionId(sessionId);
if(StringUtils.isEmpty(sessionValue)) {
sessionStruct = newSession(user);
sessionStruct = newSession(user, merchant);
if (beforPersist != null) {
beforPersist.apply(sessionStruct);
}
......@@ -53,7 +53,7 @@ public class SessionServiceImpl implements ISessionService{
}
sessionStruct.setSid(sessionId);
}else {
sessionStruct = newSession(user);
sessionStruct = newSession(user, merchant);
if (beforPersist != null) {
beforPersist.apply(sessionStruct);
}
......@@ -74,7 +74,7 @@ public class SessionServiceImpl implements ISessionService{
}
@Override
public SessionStruct newSession(User user){
public SessionStruct newSession(User user, Merchant merchant){
Timestamp now = new Timestamp(System.currentTimeMillis());
SessionStruct sessionStruct = new SessionStruct();
SessionValue sessionValue = new SessionValue();
......@@ -82,6 +82,7 @@ public class SessionServiceImpl implements ISessionService{
sessionValue.setCreatedAt(now);
sessionValue.setLastAccessTime(now);
sessionValue.setUser(user);
sessionValue.setMerchantName(merchant.getName());
Map<String, String> values = new HashMap<>();
sessionValue.setValues(values);
sessionStruct.setValues(sessionValue);
......
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