Newer
Older
smartwell_demos / src / main / java / com / casic / controller / DeviceDataController.java
chaizhuang on 24 Sep 2022 1 KB 硫化氢新增
package com.casic.controller;

import com.casic.service.DeviceDataService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/device")
public class DeviceDataController {
    private final DeviceDataService deviceDataService;

    public DeviceDataController(DeviceDataService deviceDataService) {
        this.deviceDataService = deviceDataService;
    }

    @RequestMapping("/recent-data")
    public Object getDeviceRecentData(@RequestParam(value = "deviceType", required = true) String deviceType,
                                      @RequestParam(value = "recentNum", required = true) String recentNum,
                                      @RequestParam(value = "devcode", required = false) String devcode) {
        return deviceDataService.getDeviceRecentData(deviceType, recentNum, devcode);
    }

    @RequestMapping("/data/list-page")
    public Object getDeviceListPage(@RequestParam(value = "deviceType", required = true) String deviceType,
                                    @RequestParam(value = "currentIndex", required = true) Integer currentIndex,
                                    @RequestParam(value = "pageSize", required = true) Integer pageSize,
                                    @RequestParam(value = "devcode", required = false) String devcode) {
        return deviceDataService.getDeviceListPage(deviceType, currentIndex, pageSize, devcode);
    }

    @RequestMapping("/level/{deviceType}")
    public Object getLevelList(@PathVariable("deviceType")String deviceType) {
        return deviceDataService.getLevel(deviceType);
    }

}