49 lines
1.4 KiB
Java
49 lines
1.4 KiB
Java
package com.bwie.controller;
|
|
|
|
|
|
import com.bwie.admin.Pur;
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import org.springframework.amqp.AmqpException;
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @Author: wangxinyuan
|
|
* @Date: 2024/4/11 下午10:37
|
|
*/
|
|
@RestController
|
|
public class PurController {
|
|
|
|
@Autowired
|
|
private RabbitTemplate rabbitTemplate;
|
|
|
|
@Autowired
|
|
private ObjectMapper objectMapper;
|
|
|
|
|
|
|
|
@GetMapping("/data1")
|
|
@Transactional
|
|
public void sendData1() throws JsonProcessingException {
|
|
Pur pur = new Pur();
|
|
pur.setId("593720128240812819055333");
|
|
pur.setXm("dsc");
|
|
pur.setCard("128963");
|
|
pur.setAge("56");
|
|
pur.setTime("2022-10-10 10:10:11");
|
|
String message = objectMapper.writeValueAsString(pur);
|
|
rabbitTemplate.convertAndSend("data1", "id", message);
|
|
}
|
|
|
|
}
|