MqttController.java
1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package vion.controller.mqtt;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vion.dto.monitor.MqttAuthDTO;
import vion.service.monitor.IAgentService;
/**
* 与 mqtt server 交互调用的接口
*/
@Slf4j
@RestController
@RequestMapping("/api/mqtt")
@RequiredArgsConstructor
public class MqttController {
private final IAgentService agentService;
@PostMapping("/auth")
public ObjectNode auth(@RequestBody MqttAuthDTO dto) {
return agentService.auth(dto);
}
@PostMapping("/webhook/connected")
public void connected(@RequestBody JsonNode connectedInfo) {
agentService.connected(connectedInfo);
}
@PostMapping("/webhook/disconnect")
public void disconnect(@RequestBody JsonNode disconnectInfo) {
agentService.disconnect(disconnectInfo);
}
}