package com.njcn.mq.template;

import com.google.gson.Gson;
import com.njcn.middle.rocket.domain.BaseMessage;
import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate;
import com.njcn.mq.constant.BusinessResource;
import com.njcn.mq.constant.BusinessTopic;
import com.njcn.mq.message.CloudTopicMessage;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.stereotype.Component;

/**
 * 类的介绍：读取装置版本配置信息
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2026/7/15
 */
@Component
public class CloudTopicMessageTemplate extends RocketMQEnhanceTemplate {

    public CloudTopicMessageTemplate(RocketMQTemplate template) {
        super(template);
    }

    public SendResult sendMember(CloudTopicMessage message, String tag) {
        BaseMessage baseMessage = new BaseMessage();
        baseMessage.setSource(BusinessResource.WEB_RESOURCE);
        baseMessage.setMessageBody(new Gson().toJson(message));
        return send(BusinessTopic.CLOUD_TOPIC,tag,baseMessage);
    }
}
