Commit 21413db6 authored by 董建华's avatar 董建华

监听用户事件

parent 7c328d51
......@@ -53,6 +53,7 @@ public class UserDetailUpdateEventListener implements ApplicationListener<UserDe
baseInfoBuilder.userUuid(user.getUuid());
builder.businessEventBaseInfo(baseInfoBuilder.build());
builder.subEventType(UserBaseInfoEvent.SubEventType.user_certification);
UserEventCollectingUtil.addEvent(builder.build());
log.info("用户实名认证事件监听结束userId:{}",userDetail.getUserId());
......
package cn.quantgroup.xyqb.event;
import cn.qg.ec.model.base.BusinessEventBaseInfo;
import cn.qg.ec.model.base.EventInfo;
import cn.qg.ec.model.user.UserBaseInfoEvent;
import cn.quantgroup.user.enums.EducationEnum;
import cn.quantgroup.user.enums.IncomeRangeEnum;
......@@ -41,30 +42,52 @@ public class UserExtInfoSaveEventListener implements ApplicationListener<UserExt
MaritalStatus marryStatus = userExtInfo.getMarryStatus();
OccupationEnum occupationEnum = userExtInfo.getOccupationEnum();
UserBaseInfoEvent.UserBaseInfoEventBuilder builder = UserBaseInfoEvent.builder();
builder.subEventType(UserBaseInfoEvent.SubEventType.user_occupation);
User user = userService.findById(userExtInfo.getUserId());
if (null == user) {
log.error("没找到用户,应该不存在这种情况");
return;
}
String uuid = user.getUuid();
if (null != educationEnum) {
builder.education(String.valueOf(educationEnum.ordinal()));
send(UserBaseInfoEvent.SubEventType.user_education, uuid, String.valueOf(educationEnum.ordinal()));
}
if (null != incomeRangeEnum) {
builder.income(String.valueOf(incomeRangeEnum.ordinal()));
send(UserBaseInfoEvent.SubEventType.user_income, uuid, String.valueOf(incomeRangeEnum.ordinal()));
}
if (null != marryStatus) {
builder.maritalStatus(String.valueOf(marryStatus.ordinal()));
send(UserBaseInfoEvent.SubEventType.user_marital_status, uuid, String.valueOf(marryStatus.ordinal()));
}
if (null != occupationEnum) {
builder.occupation(String.valueOf(occupationEnum.ordinal()));
send(UserBaseInfoEvent.SubEventType.user_occupation, uuid, String.valueOf(occupationEnum.ordinal()));
}
}
private void send(UserBaseInfoEvent.SubEventType eventType, String uuid, String val) {
UserBaseInfoEvent.UserBaseInfoEventBuilder builder = UserBaseInfoEvent.builder();
BusinessEventBaseInfo.BusinessEventBaseInfoBuilder baseInfoBuilder = BusinessEventBaseInfo.builder();
baseInfoBuilder.userId(uuid);
User user = userService.findById(userExtInfo.getUserId());
if (null == user) {
log.error("没找到用户,应该不存在这种情况");
}
baseInfoBuilder.userId(user.getUuid());
builder.businessEventBaseInfo(baseInfoBuilder.build());
builder.subEventType(eventType);
switch (eventType) {
case user_education:
builder.education(val);
break;
case user_income:
builder.income(val);
break;
case user_marital_status:
builder.maritalStatus(val);
break;
case user_occupation:
builder.occupation(val);
break;
default:
log.warn("没有这个类型");
return;
}
UserEventCollectingUtil.addEvent(builder.build());
}
}
......@@ -2,6 +2,7 @@ package cn.quantgroup.xyqb.risk.uereventcollecting;
import cn.qg.ec.kinesis.KinesisProducerClient;
import cn.qg.ec.model.base.EventInfo;
import cn.qg.ec.model.user.UserLoginRegEvent;
import com.alibaba.fastjson.JSON;
import com.amazonaws.services.kinesis.producer.UserRecordResult;
import com.google.common.util.concurrent.FutureCallback;
......@@ -29,7 +30,6 @@ public class UserEventCollectingUtil {
try {
ListenableFuture<UserRecordResult> future = client.SendRecord(eventInfo);
Futures.addCallback(future, CALL_BACK);
} catch (UnsupportedEncodingException e) {
log.error("发送事件异常UnsupportedEncodingException:{}", e);
} catch (Exception e) {
......
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