32 lines
1023 B
Java
32 lines
1023 B
Java
package com.whdc.controller;
|
|
|
|
import com.whdc.service.impl.VehicleDetectionService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
@RestController
|
|
@RequestMapping("/api/detection")
|
|
public class VehicleDetectionController {
|
|
|
|
@Autowired
|
|
private VehicleDetectionService vehicleDetectionService;
|
|
|
|
@PostMapping("/start")
|
|
public ResponseEntity<String> startDetection() {
|
|
vehicleDetectionService.startDetection();
|
|
return ResponseEntity.ok("车辆检测已启动");
|
|
}
|
|
|
|
@PostMapping("/stop")
|
|
public ResponseEntity<String> stopDetection() {
|
|
vehicleDetectionService.stopDetection();
|
|
return ResponseEntity.ok("车辆检测已停止");
|
|
}
|
|
|
|
@GetMapping("/status")
|
|
public ResponseEntity<Boolean> getDetectionStatus() {
|
|
boolean isRunning = vehicleDetectionService.isRunning();
|
|
return ResponseEntity.ok(isRunning);
|
|
}
|
|
} |