|
|
|
|
@ -1,8 +1,10 @@
|
|
|
|
|
// java/com/campus/water/controller/web/TerminalController.java
|
|
|
|
|
package com.campus.water.controller.web;
|
|
|
|
|
|
|
|
|
|
import com.campus.water.service.DeviceService;
|
|
|
|
|
import com.campus.water.service.TerminalService;
|
|
|
|
|
import com.campus.water.entity.vo.TerminalManageVO;
|
|
|
|
|
import com.campus.water.util.ResultVO;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
import jakarta.validation.Valid;
|
|
|
|
|
@ -23,6 +25,8 @@ import java.util.Map;
|
|
|
|
|
public class TerminalController {
|
|
|
|
|
|
|
|
|
|
private final TerminalService terminalService;
|
|
|
|
|
// 步骤1:添加DeviceService的final成员变量,由Spring自动注入(依赖@RequiredArgsConstructor)
|
|
|
|
|
private final DeviceService deviceService;
|
|
|
|
|
|
|
|
|
|
@PostMapping("/add")
|
|
|
|
|
@PreAuthorize("hasAnyRole('SUPER_ADMIN', 'AREA_ADMIN')")
|
|
|
|
|
@ -101,4 +105,16 @@ public class TerminalController {
|
|
|
|
|
return new ResponseEntity<>(errorMap, HttpStatus.BAD_REQUEST);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@DeleteMapping("/unbind/{terminalId}")
|
|
|
|
|
@PreAuthorize("hasAnyRole('SUPER_ADMIN', 'AREA_ADMIN')")
|
|
|
|
|
public ResultVO<Void> unbindTerminal(@PathVariable String terminalId) {
|
|
|
|
|
try {
|
|
|
|
|
deviceService.unbindTerminal(terminalId);
|
|
|
|
|
return ResultVO.success(null, "终端与设备解除绑定成功");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return ResultVO.error("解除绑定失败: " + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|