Merge pull request #909 from xinnan-tech/ota-activate

update:输入验证码后设备端快速刷新结果
This commit is contained in:
hrz
2025-04-20 21:15:00 +08:00
committed by GitHub
parent 8b9174b67e
commit bc99341f85
5 changed files with 29 additions and 5 deletions
@@ -167,5 +167,5 @@ public interface Constant {
/**
* 版本号
*/
public static final String VERSION = "0.3.8";
public static final String VERSION = "0.3.9";
}
@@ -15,25 +15,29 @@ import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import xiaozhi.modules.device.dto.DeviceReportReqDTO;
import xiaozhi.modules.device.dto.DeviceReportRespDTO;
import xiaozhi.modules.device.entity.DeviceEntity;
import xiaozhi.modules.device.service.DeviceService;
import xiaozhi.modules.device.utils.NetworkUtil;
@Tag(name = "设备管理", description = "OTA 相关接口")
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/ota/")
public class OTAController {
private final DeviceService deviceService;
@Operation(summary = "检查 OTA 版本和设备激活状态")
@Operation(summary = "OTA版本和设备激活状态检查")
@PostMapping
public ResponseEntity<String> checkOTAVersion(
@RequestBody DeviceReportReqDTO deviceReportReqDTO,
@@ -54,9 +58,25 @@ public class OTAController {
return createResponse(deviceService.checkDeviceActive(macAddress, clientId, deviceReportReqDTO));
}
@Operation(summary = "设备快速检查激活状态")
@PostMapping("activate")
public ResponseEntity<String> activateDevice(
@Parameter(name = "Device-Id", description = "设备唯一标识", required = true, in = ParameterIn.HEADER) @RequestHeader("Device-Id") String deviceId,
@Parameter(name = "Client-Id", description = "客户端标识", required = false, in = ParameterIn.HEADER) @RequestHeader(value = "Client-Id", required = false) String clientId) {
if (StringUtils.isBlank(deviceId)) {
return ResponseEntity.status(202).build();
}
DeviceEntity device = deviceService.getDeviceByMacAddress(deviceId);
if (device == null) {
return ResponseEntity.status(202).build();
}
return ResponseEntity.ok("success");
}
@GetMapping
public ResponseEntity<String> getOTAPrompt() {
return createResponse(DeviceReportRespDTO.createError("请提交正确的ota参数"));
@Hidden
public ResponseEntity<String> getOTA() {
return ResponseEntity.ok("OTA接口运行正常");
}
@SneakyThrows
@@ -44,6 +44,8 @@ public class DeviceReportRespDTO {
@Schema(description = "激活码信息: 激活地址")
private String message;
@Schema(description = "挑战码")
private String challenge;
}
@Getter
@@ -251,10 +251,12 @@ public class DeviceServiceImpl extends BaseServiceImpl<DeviceDao, DeviceEntity>
if (StringUtils.isNotBlank(cachedCode)) {
code.setCode(cachedCode);
code.setMessage(frontedUrl + "\n" + cachedCode);
code.setChallenge(deviceId);
} else {
String newCode = RandomUtil.randomNumbers(6);
code.setCode(newCode);
code.setMessage(frontedUrl + "\n" + newCode);
code.setChallenge(deviceId);
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("id", deviceId);
+1 -1
View File
@@ -3,7 +3,7 @@ import sys
from loguru import logger
from config.config_loader import load_config
SERVER_VERSION = "0.3.8"
SERVER_VERSION = "0.3.9"
def get_module_abbreviation(module_name, module_dict):