gasWellWatch/src/main/java/com/isu/gaswellwatch/controller/CommandController.java

40 lines
1.4 KiB
Java

package com.isu.gaswellwatch.controller;
import com.isu.gaswellwatch.annotation.OperationLog;
import com.isu.gaswellwatch.entity.Response;
import com.isu.gaswellwatch.enums.LogType;
import com.isu.gaswellwatch.modbus.CommandService;
import com.isu.gaswellwatch.vo.command.CollectCommand;
import com.isu.gaswellwatch.vo.command.Command;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
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;
/**
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/11/27 0:23
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/command")
public class CommandController {
private final CommandService commandService;
@PostMapping(value = "/control")
@OperationLog(description = "下发控制指令", type = LogType.ADD)
public Response<String> control(@RequestBody @Validated Command command) {
return this.commandService.control(command);
}
@PostMapping(value = "/collect")
@OperationLog(description = "下发采集指令", type = LogType.ADD)
public Response<String> collect(@RequestBody @Validated CollectCommand command) {
return this.commandService.collect(command);
}
}