|
@@ -1,30 +1,79 @@
|
|
|
package com.cxzx.taide;
|
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
import com.cxzx.config.KafkaConfig;
|
|
|
-import com.cxzx.db.KafkaData;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import lombok.Cleanup;
|
|
|
+import lombok.SneakyThrows;
|
|
|
import org.apache.kafka.clients.producer.KafkaProducer;
|
|
|
import org.apache.kafka.clients.producer.ProducerRecord;
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
-import static com.cxzx.db.Tidb.articleData;
|
|
|
-
|
|
|
public class PushTestData {
|
|
|
+ private static final ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+
|
|
|
+ @SneakyThrows
|
|
|
public static void main(String[] args) {
|
|
|
@Cleanup
|
|
|
var producer = new KafkaProducer<String, String>(KafkaConfig.getKafkaProducerProperties());
|
|
|
- long offset = 0;
|
|
|
+ var snowflake = IdUtil.getSnowflake();
|
|
|
+
|
|
|
+ var create = newDefaultCreate();
|
|
|
+ var publishOri = newDefaultPublish();
|
|
|
+ var publishRef = newDefaultPublish();
|
|
|
+ var reference = newDefaultReference();
|
|
|
while (true) {
|
|
|
- var articleDataList = articleData(offset, 1000);
|
|
|
- if (articleDataList.size() == 0) {
|
|
|
- break;
|
|
|
- }
|
|
|
- for (KafkaData data : articleDataList) {
|
|
|
- producer.send(new ProducerRecord<>("article_test", 0, new Date().getTime(), "", data.getData()));
|
|
|
- offset = data.getOffset();
|
|
|
- }
|
|
|
+ var time = new DateTime().toString();
|
|
|
+ var fuseId = snowflake.nextId();
|
|
|
+ var newFuseId = snowflake.nextId();
|
|
|
+
|
|
|
+ // 原稿
|
|
|
+ create.getData().setFuseId(fuseId);
|
|
|
+ create.getData().setTitle("张云翔测试 "+time);
|
|
|
+ producer.send(new ProducerRecord<>("article_test", 0, new Date().getTime(), "", objectMapper.writeValueAsString(create)));
|
|
|
+
|
|
|
+ // 引用稿
|
|
|
+ var referenceData = reference.getData();
|
|
|
+ referenceData.setFuseId(fuseId);
|
|
|
+ referenceData.setNewFuseId(newFuseId);
|
|
|
+ producer.send(new ProducerRecord<>("article_test", 0, new Date().getTime(), "", objectMapper.writeValueAsString(reference)));
|
|
|
+
|
|
|
+ // 发布原稿
|
|
|
+ publishOri.getData().setFuseId(fuseId);
|
|
|
+ producer.send(new ProducerRecord<>("article_test", 0, new Date().getTime(), "", objectMapper.writeValueAsString(publishOri)));
|
|
|
+
|
|
|
+ // 发布引用稿
|
|
|
+ var publishRefData = publishRef.getData();
|
|
|
+ publishRefData.setFuseId(newFuseId);
|
|
|
+ publishRefData.setChannelID(referenceData.getRecommendChannel());
|
|
|
+ producer.send(new ProducerRecord<>("article_test", 0, new Date().getTime(), "", objectMapper.writeValueAsString(publishRef)));
|
|
|
+ Thread.sleep(500);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ @SneakyThrows
|
|
|
+ private static CreateAction newDefaultCreate() {
|
|
|
+ return objectMapper.readValue("""
|
|
|
+ {"data":{"itemType":2,"playTimes":1,"publishDate":"2023-02-02 10:08:05","recommend":1,"title":"都市热线(2023-02-01)","content":"<!--PLAYERCODESTART--><script type=\\"text/javascript\\" src=\\"https://vmsplayer.chinamcloud.com/cmcMediaPlayer.js\\"></script><div id=\\"db893a34802a4318a915c0b095e22ec9\\"></div><script type=\\"text/javascript\\"> var uuid=\\"db893a34802a4318a915c0b095e22ec9\\"; var options = {}; options.url=\\"https://cdn-ronghe.sxtvs.com.cn/cr/video/xbw-20230202101150-9D28MfmBPi.mp4\\"; options.mediaType=\\"5\\"; options.fileHost=\\"https://vmsplayer.chinamcloud.com/\\"; options.playerMode=\\"default\\"; options.width=\\"650\\"; options.height=\\"485\\"; options.autoPlay=false; options.loadInfo=false; options.skin=\\"blue\\"; options.cross=false; var cmcMediaPlayer = new CmcMediaPlayer(uuid, options);</script><!--PLAYERCODEEND-->","photo4":"https://cdn-ronghe.sxtvs.com.cn/cr/img/xbw-20230202101150-9D28MfmBPi.jpg","duration":"2813110","idaasGroupId":"843ea558d5ef41a1877584c62762632d","videoUrl":"https://cdn-ronghe.sxtvs.com.cn/cr/video/xbw-20230202101150-9D28MfmBPi.mp4","handlerPhone":"18720000037","appId":"0","likeShare":1,"action":7,"tag":"都市热线","keyword":"都市热线","contentType":"","docZan":1,"author":"都市热线","docType":1,"fuseId":663092,"allowComment":1,"token":"62b214606c4411b67fc399d7b76ca69b","docFrom":"都市热线","allowAdvert":1,"isAudio":2,"showAvatar":1,"channelID":1385,"showRead":1},"eventType":"article"}
|
|
|
+ """, CreateAction.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @SneakyThrows
|
|
|
+ private static PublishAction newDefaultPublish() {
|
|
|
+ return objectMapper.readValue("""
|
|
|
+ {"data":{"idaasGroupId":"843ea558d5ef41a1877584c62762632d","appId":"0","fuseId":663118,"action":4,"channelID":1385,"token":"62b214606c4411b67fc399d7b76ca69b"},"eventType":"article"}
|
|
|
+ """, PublishAction.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @SneakyThrows
|
|
|
+ private static ReferenceAction newDefaultReference() {
|
|
|
+ return objectMapper.readValue("""
|
|
|
+ {"data":{"auditFlag":0,"newFuseId":663094,"idaasGroupId":"843ea558d5ef41a1877584c62762632d","handlerPhone":"18720000037","appId":"0","fuseId":663092,"action":9,"recommendChannel":292,"token":"62b214606c4411b67fc399d7b76ca69b"},"eventType":"article"}
|
|
|
+ """, ReferenceAction.class);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|