feat:() 测试数据库添加事件
parent
72ac72330e
commit
ad0460a90b
|
@ -3,8 +3,13 @@ package com.muyu.processing.listener;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.muyu.processing.basic.EventCustom;
|
||||
import com.muyu.processing.basic.EventListener;
|
||||
import com.muyu.processing.utils.CacheUtil;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.apache.kafka.common.protocol.types.Field;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 添加数据库事件
|
||||
|
@ -14,10 +19,21 @@ import java.util.ArrayList;
|
|||
* @name:AddDatabaseListener
|
||||
* @Date:2024/9/29 22:25
|
||||
*/
|
||||
@Log4j2
|
||||
public class AddDatabaseListener implements EventListener {
|
||||
|
||||
@Resource
|
||||
private CacheUtil cacheUtil;
|
||||
|
||||
@Override
|
||||
public void onEvent(EventCustom event) {
|
||||
log.info("数据库添加");
|
||||
log.info("数据为: {}",event.getData());
|
||||
JSONObject jsonObject = event.getData();
|
||||
String vin = (String) jsonObject.get("vin");
|
||||
Map<String, Object> map = (Map<String, Object>) cacheUtil.get(vin);
|
||||
if (map != null){
|
||||
log.info("本地缓存数据为: {}",map);
|
||||
ArrayList<Object> keys = new ArrayList<>();
|
||||
ArrayList<Object> values = new ArrayList<>();
|
||||
jsonObject.forEach((key, value) ->{
|
||||
|
@ -26,6 +42,7 @@ public class AddDatabaseListener implements EventListener {
|
|||
});
|
||||
// 添加数据库
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(EventCustom event) {
|
||||
|
|
Loading…
Reference in New Issue