package com.gic.haoban.manage.service.service.content.message;

import com.alibaba.fastjson.JSON;
import com.gic.haoban.manage.service.pojo.bo.content.message.InteractRecordMessageBO;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.listener.MessageListener;
import org.springframework.stereotype.Component;

/**
 * @Author MUSI
 * @Date 2023/4/5 9:49 PM
 * @Description
 * @Version
 **/
@Slf4j
public class InteractRecordMessageListener implements MessageListener<String, String> {

    @Autowired
    InteractRecordMessageService interactRecordMessageService;

    @Override
    public void onMessage(ConsumerRecord<String, String> consumerRecord) {
        String value = consumerRecord.value();
        InteractRecordMessageBO recordMessageBO = JSON.parseObject(value, InteractRecordMessageBO.class);
        if (recordMessageBO == null) {
            log.info("互动记录解析异常 {}", value);
            return;
        }
        interactRecordMessageService.dealRecord(recordMessageBO);
    }
}
