package com.gz.controller;

import com.alibaba.fastjson.JSON;
import com.gz.core.annotation.Controller;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LiuchangLan
 * @date 2021/4/19 10:05
 */
@RestController
@RequestMapping("rabbit")
public class RabbitMqTestController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Value("${rabbitmq.data-exchange}")
    private String dataExchangeName;

    @Value("${rabbitmq.ocr.queue-binding-key}")
    private String ocrBindingKey;

    @Value("${upload-file.server-file-url-prefix}")
    private String serverFileUrlPrefix;

    @GetMapping("test")
    public void test(){
        rabbitTemplate.convertAndSend(dataExchangeName, ocrBindingKey, JSON.toJSONString("{\"bgqx\":\"001\",\"createTime\":\"2021-03-04 15:15:51\",\"dagdm\":\"432003\",\"deleted\":0,\"dh\":\"5098201800100000016\",\"fileUrl\":\"https://www.aifyun.com/api/v3/file/get/740/Hibernate%E9%9D%A2%E8%AF%95%E9%A2%98%E5%88%86%E6%9E%90_%E5%B0%9A%E7%A1%85%E8%B0%B7_%E4%BD%9F%E5%88%9A.pdf?sign=cYEvAmNEvLvfzL2l7axdstyIQfcMAJ5BBMeoGvzojSA%3D%3A0\",\"gdnd\":\"2018\",\"id\":834,\"mj\":\"GONGKAI\",\"ml\":\"WS\",\"mlh\":\"\",\"qzh\":\"5098\",\"tm\":\"对市十六届人大一次会议第0307号建议的答复（关于加快棚户区改造，节约土地并促进土地复合利用的建议）\",\"updateTime\":\"2021-03-10 09:34:41\",\"wjbh\":\"宁规案字[2018]117号\",\"wjdqsj\":\"\",\"wjxcsj\":\"2018-09-06\",\"zrz\":\"市规划局\",\"ztsl\":52}"));
    }

}
