39 lines
1.5 KiB
Java
39 lines
1.5 KiB
Java
package com.luqj.ec.controller;
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.luqj.ec.domain.dto.EcDeviceHeartbeatDto;
|
|
import com.luqj.ec.domain.dto.EcDeviceReportDto;
|
|
import com.luqj.ec.service.IEcDeviceService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
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;
|
|
|
|
@RestController
|
|
@RequestMapping("/ec/device-api")
|
|
public class EcDeviceApiController extends BaseController {
|
|
|
|
@Autowired
|
|
private IEcDeviceService ecDeviceService;
|
|
|
|
@PostMapping("/report")
|
|
public AjaxResult report(@RequestBody EcDeviceReportDto reportDto) {
|
|
if (reportDto.getDeviceCode() == null || reportDto.getDeviceCode().isEmpty()) {
|
|
return AjaxResult.error("deviceCode不能为空");
|
|
}
|
|
ecDeviceService.reportDevice(reportDto);
|
|
return AjaxResult.success("设备上报成功");
|
|
}
|
|
|
|
@PostMapping("/heartbeat")
|
|
public AjaxResult heartbeat(@RequestBody EcDeviceHeartbeatDto heartbeatDto) {
|
|
if (heartbeatDto.getDeviceCode() == null || heartbeatDto.getDeviceCode().isEmpty()) {
|
|
return AjaxResult.error("deviceCode不能为空");
|
|
}
|
|
ecDeviceService.heartbeat(heartbeatDto);
|
|
return AjaxResult.success("心跳成功");
|
|
}
|
|
}
|