feat(aiot): AiConfigController新增版本管理API
- 新增配置版本列表查询 - 新增配置快照详情查询 - 新增配置回滚接口 - 新增推送前预览接口 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
package com.genersoft.iot.vmp.aiot.controller;
|
||||
|
||||
import com.genersoft.iot.vmp.aiot.bean.AiConfigSnapshot;
|
||||
import com.genersoft.iot.vmp.aiot.service.IAiConfigService;
|
||||
import com.genersoft.iot.vmp.aiot.service.IAiConfigSnapshotService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -12,16 +16,21 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/ai/config")
|
||||
@Tag(name = "AI-配置推送")
|
||||
@Tag(name = "AI-配置推送与版本管理")
|
||||
public class AiConfigController {
|
||||
|
||||
@Autowired
|
||||
private IAiConfigService configService;
|
||||
|
||||
@Operation(summary = "推送配置到边缘端")
|
||||
@Autowired
|
||||
private IAiConfigSnapshotService snapshotService;
|
||||
|
||||
// ==================== 配置推送 ====================
|
||||
|
||||
@Operation(summary = "推送配置到边缘端(Redis+通知)")
|
||||
@PostMapping("/push")
|
||||
public void pushConfig(@RequestParam String cameraId) {
|
||||
configService.pushConfig(cameraId);
|
||||
public Map<String, Object> pushConfig(@RequestParam String cameraId) {
|
||||
return configService.pushConfig(cameraId);
|
||||
}
|
||||
|
||||
@Operation(summary = "导出通道完整配置JSON")
|
||||
@@ -29,4 +38,61 @@ public class AiConfigController {
|
||||
public Map<String, Object> exportConfig(@RequestParam String cameraId) {
|
||||
return configService.exportConfig(cameraId);
|
||||
}
|
||||
|
||||
@Operation(summary = "推送前预览diff")
|
||||
@GetMapping("/preview")
|
||||
public Map<String, Object> preview(@RequestParam String cameraId) {
|
||||
return snapshotService.preview(cameraId);
|
||||
}
|
||||
|
||||
// ==================== 版本管理 ====================
|
||||
|
||||
@Operation(summary = "查询版本列表")
|
||||
@GetMapping("/versions")
|
||||
public PageInfo<AiConfigSnapshot> queryVersions(
|
||||
@Parameter(description = "范围类型:CAMERA/ROI/BIND") @RequestParam(required = false) String scopeType,
|
||||
@Parameter(description = "范围ID") @RequestParam(required = false) String scopeId,
|
||||
@Parameter(description = "摄像头ID") @RequestParam(required = false) String cameraId,
|
||||
@RequestParam(defaultValue = "1") int page,
|
||||
@RequestParam(defaultValue = "20") int count) {
|
||||
return snapshotService.queryVersions(scopeType, scopeId, cameraId, page, count);
|
||||
}
|
||||
|
||||
@Operation(summary = "查看快照详情")
|
||||
@GetMapping("/snapshot/{id}")
|
||||
public AiConfigSnapshot querySnapshot(@PathVariable Long id) {
|
||||
return snapshotService.queryById(id);
|
||||
}
|
||||
|
||||
@Operation(summary = "回滚配置")
|
||||
@PostMapping("/rollback")
|
||||
public void rollback(
|
||||
@Parameter(description = "范围类型:CAMERA/ROI/BIND") @RequestParam String scopeType,
|
||||
@Parameter(description = "范围ID(cameraId/roiId/bindId)") @RequestParam String scopeId,
|
||||
@Parameter(description = "目标版本号") @RequestParam Integer targetVersion,
|
||||
@Parameter(description = "操作人") @RequestParam(required = false) String operator) {
|
||||
switch (scopeType.toUpperCase()) {
|
||||
case "CAMERA":
|
||||
snapshotService.rollbackCamera(scopeId, targetVersion, operator);
|
||||
break;
|
||||
case "ROI":
|
||||
snapshotService.rollbackRoi(scopeId, targetVersion, operator);
|
||||
break;
|
||||
case "BIND":
|
||||
snapshotService.rollbackBind(scopeId, targetVersion, operator);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("不支持的scopeType: " + scopeType);
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "版本间比对")
|
||||
@GetMapping("/diff")
|
||||
public Map<String, Object> diff(
|
||||
@Parameter(description = "范围类型") @RequestParam String scopeType,
|
||||
@Parameter(description = "范围ID") @RequestParam String scopeId,
|
||||
@Parameter(description = "版本A") @RequestParam Integer versionA,
|
||||
@Parameter(description = "版本B") @RequestParam Integer versionB) {
|
||||
return snapshotService.diff(scopeType, scopeId, versionA, versionB);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user