You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.4 KiB
Java
49 lines
1.4 KiB
Java
package com.example.lxcameraapi.controller;
|
|
|
|
import com.example.lxcameraapi.service.light.LightService;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
/**
|
|
* 灯源控制器
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/light")
|
|
@RequiredArgsConstructor
|
|
public class LightController {
|
|
|
|
private final LightService lightService;
|
|
|
|
/**
|
|
* 触发灯源(导通)
|
|
*/
|
|
@GetMapping("/trigger")
|
|
@Operation(summary = "触发灯源", description = "触发指定地址的灯源导通")
|
|
public boolean trigger(
|
|
@RequestParam(defaultValue = "1") int address,
|
|
@RequestParam(required = false) Integer duration) {
|
|
if (duration != null) {
|
|
return lightService.trigger(address, duration);
|
|
}
|
|
return lightService.trigger(address);
|
|
}
|
|
|
|
/**
|
|
* 触发灯源(导通)
|
|
*/
|
|
@GetMapping("/triggerD")
|
|
@Operation(summary = "触发灯源", description = "触发指定地址的灯源导通")
|
|
public boolean triggerD() {
|
|
return lightService.defaultTrigger(1);
|
|
}
|
|
|
|
/**
|
|
* 断开灯源
|
|
*/
|
|
@GetMapping("/off")
|
|
@Operation(summary = "断开灯源", description = "断开指定地址的灯源")
|
|
public boolean off(@RequestParam(defaultValue = "1") int address) {
|
|
return lightService.off(address);
|
|
}
|
|
} |