Commit 28890c05 authored by zhouqian's avatar zhouqian

登录增加系统key

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