package com.luojia_channel.modules.feedback.mq.producer;


import com.luojia_channel.modules.feedback.config.FeedbackRabbitMQConfig;
import com.luojia_channel.modules.feedback.mq.domain.DelayHandleTicketMessage;
import com.luojia_channel.modules.message.mq.AbstractSendProduceTemplate;
import com.luojia_channel.modules.message.mq.BaseSendExtendDTO;
import com.luojia_channel.modules.message.mq.MessageWrapper;
import lombok.RequiredArgsConstructor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class FeedbackMessageProducer extends AbstractSendProduceTemplate<DelayHandleTicketMessage>{

    public FeedbackMessageProducer(@Autowired RabbitTemplate rabbitTemplate){
        super(rabbitTemplate);
    }

    @Override
    protected BaseSendExtendDTO buildBaseSendParam(DelayHandleTicketMessage messageSendEvent) {
        return BaseSendExtendDTO.builder()
                .eventName("DelayHandleTicketMessageEvent")
                .exchange(FeedbackRabbitMQConfig.FEEDBACK_EXCHANGE)
                .routingKey(FeedbackRabbitMQConfig.FEEDBACK_ROUTING_KEY)
                .keys(messageSendEvent.getId().toString())
                .delay(24*60*60*1000L) //延迟消息是1天
                .build();
    }
}
