HealthController.java
1.29 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
package com.iot.scheduler.controller;
import com.iot.scheduler.service.DevicePullService;
import com.iot.scheduler.service.DeviceSearchService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@RestController
public class HealthController {
@Resource
private DevicePullService devicePullService;
@Resource
private DeviceSearchService deviceSearchService;
@GetMapping("/health")
public String health() throws Exception {
devicePullService.pullDeviceAndPushToIot();
return "IoT Scheduler is running...";
}
@GetMapping("/device/list")
public Map<String, Object> deviceList(
@RequestParam(required = false) String deviceName,
@RequestParam(required = false) String lampState,
@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "10") Integer pageSize) {
return deviceSearchService.queryDeviceList(deviceName, lampState, pageNo, pageSize);
}
@GetMapping("/device/stats")
public Map<String, Object> deviceStats() {
return deviceSearchService.queryDeviceStats();
}
}