You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.5 KiB
47 lines
1.5 KiB
package com.iflytop.gd.app.controller;
|
|
|
|
import com.iflytop.gd.app.model.bo.status.device.DeviceState;
|
|
import com.iflytop.gd.app.model.dto.SetSystemDatetimeDTO;
|
|
import com.iflytop.gd.app.service.device.DeviceStateService;
|
|
import com.iflytop.gd.app.service.api.SystemConfigService;
|
|
import com.iflytop.gd.common.result.Result;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import jakarta.validation.Valid;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.time.Instant;
|
|
import java.time.LocalDateTime;
|
|
|
|
@Tag(name = "系统")
|
|
@RestController
|
|
@RequestMapping("/api/sys")
|
|
@RequiredArgsConstructor
|
|
@Slf4j
|
|
public class SystemController {
|
|
private final SystemConfigService systemConfigService;
|
|
private final DeviceStateService deviceStateService;
|
|
|
|
|
|
@Operation(summary = "系统状态")
|
|
@GetMapping("/device-status")
|
|
public Result<DeviceState> getDeviceStatus() {
|
|
return Result.success(deviceStateService.getDeviceState());
|
|
}
|
|
|
|
@Operation(summary = "设置系统时间")
|
|
@PostMapping("/datetime")
|
|
public Result<?> setDatetime(@Valid @RequestBody SetSystemDatetimeDTO setSystemDatetimeDTO) {
|
|
systemConfigService.setDatetime(setSystemDatetimeDTO.getDatetime());
|
|
return Result.success();
|
|
}
|
|
|
|
@Operation(summary = "获取系统时间")
|
|
@GetMapping("/datetime")
|
|
public Result<?> getDatetime() {
|
|
return Result.success(Instant.now().toEpochMilli());
|
|
}
|
|
|
|
}
|