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.
45 lines
1.5 KiB
45 lines
1.5 KiB
package com.iflytop.handacid.app.controller;
|
|
|
|
import com.iflytop.handacid.app.core.state.DeviceState;
|
|
import com.iflytop.handacid.app.model.dto.TimeSetDTO;
|
|
import com.iflytop.handacid.app.model.vo.TimeResponseVO;
|
|
import com.iflytop.handacid.app.service.SystemService;
|
|
import com.iflytop.handacid.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;
|
|
|
|
@Tag(name = "⚙\uFE0F系统")
|
|
@RestController
|
|
@RequestMapping("/api/sys")
|
|
@RequiredArgsConstructor
|
|
@Slf4j
|
|
public class SystemController {
|
|
private final SystemService systemService;
|
|
private final DeviceState deviceState;
|
|
|
|
@Operation(summary = "获取当前设备状态")
|
|
@GetMapping("/device-status")
|
|
public Result<?> getDeviceStatus() {
|
|
return Result.success(deviceState.toJSON());
|
|
}
|
|
|
|
@Operation(summary = "设置系统时间")
|
|
@PostMapping("/set-datetime")
|
|
public Result<?> setDatetime(@Valid @RequestBody TimeSetDTO timeSetDTO) {
|
|
systemService.setSystemTime(timeSetDTO.getEpochMilli());
|
|
return Result.success();
|
|
}
|
|
|
|
@Operation(summary = "获取当前系统时间")
|
|
@GetMapping("/get-datetime")
|
|
public Result<TimeResponseVO> getDatetime() {
|
|
return Result.success(new TimeResponseVO(Instant.now().toEpochMilli()));
|
|
}
|
|
|
|
}
|