package com.xhkjedu.sapi.listener;

import com.alibaba.fastjson.JSON;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author ywx
 * @className MessageSender
 * @description
 * @date 2021/10/25 14:28
 **/
@Component
public class MessageSender {
    @Autowired
    private AmqpTemplate rabbitTemplate;
    @Value("${rabbitmq.researchTransferQueue}")
    private String researchTransferQueue;
    @Value("${rabbitmq.resourceDelQueue}")
    private String resourceDelQueue;

    //教研视频转换mq
    public void convertVideo(Integer resourceid, String resourceurl) {
        Map map = new HashMap();
        map.put("resourceid",resourceid);
        map.put("resourceurl",resourceurl);
        rabbitTemplate.convertAndSend(researchTransferQueue, JSON.toJSONString(map));
    }

    //资源删除mq
    public void resourceDel(List<String> resourceurls) {
        rabbitTemplate.convertAndSend(resourceDelQueue,JSON.toJSONString(resourceurls));
    }
}
