Commit 5554fd61 authored by 技术部-任文超's avatar 技术部-任文超

优化登录的消息推送kafka

parent 42acd470
......@@ -19,9 +19,9 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import com.alibaba.fastjson.JSON;
import cn.quantgroup.acolyte.buddhistscriptures.pojo.Login;
import lombok.extern.slf4j.Slf4j;
import cn.quantgroup.acolyte.buddhistscriptures.pojo.Login;
import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.event.StatisticsEvent;
......@@ -98,19 +98,6 @@ public class SessionServiceImpl implements ISessionService {
} else {
sessionStruct = newSession(user, properties);
persistSession(sessionStruct.getSid(), sessionStruct.getValues());
// 发送登陆成功统计消息
/*
* 部分免密渠道登录统计,用户中心不需识别,由统计平台来过滤
* 贷款导航(84660);壹账通H5(159384)
*/
user.setRegisteredFrom(properties.getCreatedFrom());
UserStatistics statistics = new UserStatistics(user, null, properties.getAction(), properties.getChannelId());
// 推送老的登陆统计信息
MqUtils.sendLoanVest(statistics);
// 发布新的登录统计信息事件
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
Login login = new Login(user.getId(), properties.getCreatedFrom(), properties.getChannelId(), IPUtil.getRemoteIP(request), properties.getAction(), System.currentTimeMillis());
applicationEventPublisher.publishEvent(new StatisticsEvent(this, login));
}
return sessionStruct;
}
......@@ -132,7 +119,7 @@ public class SessionServiceImpl implements ISessionService {
return StringUtils.defaultString(result, "");
}
private SessionStruct newSession(User user, LoginProperties loginProperties) {
private SessionStruct newSession(User user, LoginProperties properties) {
Timestamp now = new Timestamp(System.currentTimeMillis());
SessionStruct sessionStruct = new SessionStruct();
SessionValue sessionValue = new SessionValue();
......@@ -140,10 +127,23 @@ public class SessionServiceImpl implements ISessionService {
sessionValue.setCreatedAt(now);
sessionValue.setLastAccessTime(now);
sessionValue.setUser(user);
sessionValue.setLoginProperties(loginProperties);
sessionValue.setLoginProperties(properties);
Map<String, String> values = new HashMap<>();
sessionValue.setValues(values);
sessionStruct.setValues(sessionValue);
// 发送登陆成功统计消息
/*
* 部分免密渠道登录统计,用户中心不需识别,由统计平台来过滤
* 贷款导航(84660);壹账通H5(159384)
*/
user.setRegisteredFrom(properties.getCreatedFrom());
UserStatistics statistics = new UserStatistics(user, null, properties.getAction(), properties.getChannelId());
// 推送老的登陆统计信息
MqUtils.sendLoanVest(statistics);
// 发布新的登录统计信息事件
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
Login login = new Login(user.getId(), properties.getCreatedFrom(), properties.getChannelId(), IPUtil.getRemoteIP(request), properties.getAction(), System.currentTimeMillis());
applicationEventPublisher.publishEvent(new StatisticsEvent(this, login));
return sessionStruct;
}
......
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