审查视图

src/main/java/com/tianbo/messagebus/controller/HeartbeatController.java 2.7 KB
朱兆平 authored
1 2 3 4
package com.tianbo.messagebus.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
5
import com.tianbo.messagebus.controller.response.ResultJson;
6 7
import com.tianbo.messagebus.dao.CUSTOM_RESPONSEMapper;
import com.tianbo.messagebus.model.CUSTOM_RESPONSE;
8 9 10 11 12
import com.tianbo.messagebus.model.HEADER;
import com.tianbo.messagebus.model.MSG;
import com.tianbo.messagebus.model.MSGS;
import com.tianbo.messagebus.myinterface.KafkaReciveApi;
import com.tianbo.messagebus.myinterface.KafkaSendApi;
朱兆平 authored
13
import com.tianbo.messagebus.service.MessageBusProcessor;
朱兆平 authored
14
import lombok.extern.slf4j.Slf4j;
朱兆平 authored
15 16
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
17 18
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;
朱兆平 authored
19 20 21 22 23 24 25 26

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;
import java.util.Date;

@RestController()
朱兆平 authored
27
@Slf4j
朱兆平 authored
28 29 30 31
@RequestMapping("/")
public class HeartbeatController implements Serializable {
    private static final long serialVersionUID = 1L;
32 33 34
    @Autowired
    KafkaReciveApi kafkaReciveApi;
35 36 37
    @Resource
    public CUSTOM_RESPONSEMapper custom_responseMapper_nmms20;
38 39
    @Autowired
    KafkaSendApi kafkaSendApi;
朱兆平 authored
40
41 42 43
    @Resource
    CUSTOM_RESPONSEMapper custom_responseMapper;
朱兆平 authored
44 45 46 47
    @Autowired
    private HttpServletRequest request;

    @Autowired
48
    MessageBusProcessor messageBusProcessor;
朱兆平 authored
49 50 51

    @PostMapping("login")
    public void login(){
52
        messageBusProcessor.login();
朱兆平 authored
53 54 55 56
    }

    @PostMapping("getmsg")
    public void getmsg(){
朱兆平 authored
57
        log.error("for test");
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
        messageBusProcessor.getMsg();
    }

    @GetMapping("getOneMsg")
    public void getonemsg(@RequestParam(value = "username") String username){
        ResultJson resultJson=  kafkaReciveApi.recive(username);
        log.info("收到结果为:{}",resultJson.toString());
    }

    @PostMapping("send")
    public void sendMsg(@RequestParam("msg") String msgBody){
        MSGS msgs = new MSGS();
        MSG msg = new MSG();

        HEADER header = new HEADER();
        header.setSNDR("TXD");
        header.setDDTM("20210429103322081");
        header.setSEQNO(2021042910);
        header.setTYPE("HYXX");
        header.setSTYPE("ISLI");



        msg.setHEADER(header);
        msg.setBODY(msgBody);




        msgs.setMSG(msg);

        ResultJson response = kafkaSendApi.send(msgs);
        log.info(response.toString());
朱兆平 authored
91 92
    }
93 94 95 96 97 98

    @PostMapping("parse")
    public void  parse(@RequestBody CUSTOM_RESPONSE custom_response){
      int  i = custom_responseMapper.insertSelective(custom_response);
      log.info("插入数据为{}",i);
    }
朱兆平 authored
99
}