151 lines
5.7 KiB
Java
151 lines
5.7 KiB
Java
package com.youlai.boot.device.controller;
|
|
|
|
import com.youlai.boot.common.annotation.Log;
|
|
import com.youlai.boot.common.enums.ActionTypeEnum;
|
|
import com.youlai.boot.common.enums.LogModuleEnum;
|
|
import com.youlai.boot.common.result.PageResult;
|
|
import com.youlai.boot.common.result.Result;
|
|
import com.youlai.boot.device.model.entity.SnDeviceInfo;
|
|
import com.youlai.boot.device.model.form.DeveloperForm;
|
|
import com.youlai.boot.device.model.query.DeviceQuery;
|
|
import com.youlai.boot.device.model.vo.DeviceHardwareVO;
|
|
import com.youlai.boot.device.model.vo.DevicePageVO;
|
|
import com.youlai.boot.device.service.DeviceService;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import jakarta.validation.Valid;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
/**
|
|
* 设备控制层
|
|
* @author TTSTD
|
|
* @since 2026/04/05
|
|
*/
|
|
@Tag(name = "15.SN管理")
|
|
@RestController
|
|
@RequestMapping("/api/v1/device")
|
|
@RequiredArgsConstructor
|
|
public class DeviceController {
|
|
private final DeviceService deviceService;
|
|
|
|
@Operation(summary = "SN列表")
|
|
@GetMapping
|
|
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.LIST)
|
|
public PageResult<DevicePageVO> getSnList(@Valid DeviceQuery deviceQuery) {
|
|
return PageResult.success(deviceService.getSnPage(deviceQuery));
|
|
}
|
|
|
|
@Operation(summary = "获取SN绑定激活信息")
|
|
@GetMapping("/{sn}/info")
|
|
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.VIEW)
|
|
// @PreAuthorize("@ss.hasPerm('sys:sn:view')")
|
|
public Result<DevicePageVO> getSnBindInfo(@PathVariable String sn) {
|
|
DevicePageVO detail = deviceService.getSnBindInfo(sn);
|
|
return Result.success(detail);
|
|
}
|
|
|
|
@Operation(summary = "获取SN基础信息")
|
|
@GetMapping("/{sn}/hardware_info")
|
|
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.VIEW)
|
|
// @PreAuthorize("@ss.hasPerm('sys:sn:view')")
|
|
public Result<DeviceHardwareVO> getSnHardwareInfo(@PathVariable String sn) {
|
|
DeviceHardwareVO info = deviceService.getSnHardwareInfo(sn);
|
|
return Result.success(info);
|
|
}
|
|
|
|
@Operation(summary = "新增SN")
|
|
@PostMapping("/add")
|
|
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.INSERT)
|
|
// @PreAuthorize("@ss.hasPerm('sys:sn:create')")
|
|
public Result<Void> addSn(@RequestBody SnDeviceInfo snDeviceInfo) {
|
|
deviceService.addSn(snDeviceInfo);
|
|
return Result.success();
|
|
}
|
|
|
|
@Operation(summary = "删除SN")
|
|
@DeleteMapping("/{sn}")
|
|
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.DELETE)
|
|
@PreAuthorize("@ss.hasPerm('sys:sn:delete')")
|
|
public Result<Void> deleteSn(@PathVariable String sn) {
|
|
deviceService.deleteSn(sn);
|
|
return Result.success();
|
|
}
|
|
|
|
@Operation(summary = "设备刷新")
|
|
@PostMapping("/refresh")
|
|
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.REFRESH)
|
|
public Result<?> devicerefresh(@RequestParam String sn) {
|
|
boolean result = deviceService.deviceRefresh(sn);
|
|
return Result.judge(result);
|
|
}
|
|
|
|
@Operation(summary = "设备截图")
|
|
@PostMapping("/screenshot")
|
|
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.SCREENSHOT)
|
|
public Result<?> screenSnapshot(@RequestParam String sn) {
|
|
boolean result = deviceService.screenSnapshot(sn);
|
|
return Result.judge(result);
|
|
}
|
|
|
|
@Operation(summary = "设备重启")
|
|
@PostMapping("/reboot")
|
|
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.REBOOT)
|
|
public Result<?> reboot(@RequestParam String sn) {
|
|
boolean result = deviceService.deviceReboot(sn);
|
|
return Result.judge(result);
|
|
}
|
|
|
|
@Operation(summary = "设备关机")
|
|
@PostMapping("/shutdown")
|
|
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.SHUTDOWN)
|
|
public Result<?> shutdown(@RequestParam String sn) {
|
|
boolean result = deviceService.deviceShutdown(sn);
|
|
return Result.judge(result);
|
|
}
|
|
|
|
@Operation(summary = "设备定位")
|
|
@PostMapping("/locate")
|
|
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.LOCATE)
|
|
public Result<?> deviceLocate(@RequestParam String sn) {
|
|
boolean result = deviceService.deviceLocate(sn);
|
|
return Result.judge(result);
|
|
}
|
|
|
|
@Operation(summary = "设备重置")
|
|
@PostMapping("/restore")
|
|
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.RESTORE)
|
|
public Result<?> deviceRestore(@RequestParam String sn) {
|
|
boolean result = deviceService.restore(sn);
|
|
return Result.judge(result);
|
|
}
|
|
|
|
@Operation(summary = "开发者模式")
|
|
@PostMapping("/developer")
|
|
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.DEVELOPER)
|
|
public Result<?> deviceDeveloper(@RequestParam String sn) {
|
|
boolean result = deviceService.setDeviceDeveloper(sn);
|
|
return Result.judge(result);
|
|
}
|
|
|
|
@Operation(summary = "新增开发者选项配置")
|
|
@PostMapping("/developer/config")
|
|
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.INSERT)
|
|
public Result<Void> addDeveloperConfig(@Valid @RequestBody DeveloperForm developerForm) {
|
|
boolean result = deviceService.addDeveloperConfig(
|
|
developerForm.getSn(),
|
|
developerForm.getDeveloperOptions()
|
|
);
|
|
return Result.judge(result);
|
|
}
|
|
|
|
@Operation(summary = "删除开发者选项配置")
|
|
@DeleteMapping("/developer/config")
|
|
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.DELETE)
|
|
public Result<Void> deleteDeveloperConfig(@RequestParam String sn) {
|
|
boolean result = deviceService.deleteDeveloperConfig(sn);
|
|
return Result.judge(result);
|
|
}
|
|
}
|