package com.fs.app.mq;


import com.alibaba.fastjson.JSON;
import com.fs.course.domain.FsCourseWatchLog;
import com.fs.course.service.IFsCourseFinishTempService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@AllArgsConstructor
@RocketMQMessageListener(topic = "course-finish-notes", consumerGroup = "course-finish-group")
public class RocketMQConsumerCourseFinishService implements RocketMQListener<String> {

    private final IFsCourseFinishTempService courseFinishTempService;

    @Override
    public void onMessage(String message) {


        log.info("收到消息1：" + message);

        FsCourseWatchLog watchLog = JSON.parseObject(message, FsCourseWatchLog.class);
        if (watchLog == null || watchLog.getQwExternalContactId() == null) {
            return;
        }
        courseFinishTempService.finishCourseExtContactIdByRemark(watchLog);

    }
}
