feat(aiot-device): 完善设备模块 API 层,对接 WVP 实际接口
从 WVP 项目迁移全部设备管理 API: - 摄像头管理:列表查询、开始/停止拉流 - ROI 区域:增删改查、按摄像头查询、截图 - 算法绑定:绑定/解绑/更新参数 - 配置推送:推送到边缘端、导出配置 - 移除未使用的 PageParam 导入 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,99 +1,166 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
import { useAppConfig } from '@vben/hooks';
|
||||
|
||||
import { wvpRequestClient } from '#/api/aiot/request';
|
||||
|
||||
const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
|
||||
|
||||
export namespace AiotDeviceApi {
|
||||
/** ROI 区域 */
|
||||
export interface Roi {
|
||||
id?: number;
|
||||
channelId?: string;
|
||||
channelName?: string;
|
||||
roiId?: string;
|
||||
cameraId?: string;
|
||||
deviceId?: string;
|
||||
name?: string;
|
||||
type?: string;
|
||||
points?: string;
|
||||
enabled?: boolean;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
roiType?: string; // rectangle | polygon
|
||||
coordinates?: string;
|
||||
color?: string;
|
||||
priority?: number;
|
||||
enabled?: number; // 0 | 1
|
||||
description?: string;
|
||||
algorithms?: RoiAlgoBinding[];
|
||||
}
|
||||
|
||||
/** ROI 算法绑定 */
|
||||
export interface RoiAlgoBind {
|
||||
id?: number;
|
||||
roiId?: number;
|
||||
algorithmId?: number;
|
||||
algorithmName?: string;
|
||||
enabled?: boolean;
|
||||
config?: Record<string, any>;
|
||||
/** ROI 算法绑定(详情里的嵌套结构) */
|
||||
export interface RoiAlgoBinding {
|
||||
bind: AlgoBind;
|
||||
algorithm?: Algorithm;
|
||||
}
|
||||
|
||||
/** 算法绑定记录 */
|
||||
export interface AlgoBind {
|
||||
bindId?: string;
|
||||
roiId?: string;
|
||||
algoCode?: string;
|
||||
enabled?: number;
|
||||
params?: string;
|
||||
}
|
||||
|
||||
/** 算法 */
|
||||
export interface Algorithm {
|
||||
id?: number;
|
||||
name?: string;
|
||||
code?: string;
|
||||
algoCode?: string;
|
||||
algoName?: string;
|
||||
description?: string;
|
||||
enabled?: boolean;
|
||||
isActive?: boolean;
|
||||
paramSchema?: string;
|
||||
}
|
||||
|
||||
/** 摄像头通道 */
|
||||
export interface Channel {
|
||||
channelId?: string;
|
||||
name?: string;
|
||||
manufacturer?: string;
|
||||
status?: string;
|
||||
ptztypeText?: string;
|
||||
longitudeWgs84?: number;
|
||||
latitudeWgs84?: number;
|
||||
/** 摄像头(拉流代理) */
|
||||
export interface Camera {
|
||||
id?: number;
|
||||
app?: string;
|
||||
stream?: string;
|
||||
srcUrl?: string;
|
||||
pulling?: boolean;
|
||||
mediaServerId?: string;
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 摄像头管理 API ====================
|
||||
|
||||
/** 获取摄像头列表 */
|
||||
export function getCameraList(params: {
|
||||
page: number;
|
||||
count: number;
|
||||
query?: string;
|
||||
pulling?: boolean;
|
||||
}) {
|
||||
return wvpRequestClient.get<any>('/aiot/device/proxy/list', { params });
|
||||
}
|
||||
|
||||
/** 开始拉流 */
|
||||
export function startCamera(id: number) {
|
||||
return wvpRequestClient.get('/aiot/device/proxy/start', { params: { id } });
|
||||
}
|
||||
|
||||
/** 停止拉流 */
|
||||
export function stopCamera(id: number) {
|
||||
return wvpRequestClient.get('/aiot/device/proxy/stop', { params: { id } });
|
||||
}
|
||||
|
||||
// ==================== ROI 区域管理 API ====================
|
||||
|
||||
/** 获取 ROI 列表 */
|
||||
export function getRoiPage(params: PageParam) {
|
||||
return wvpRequestClient.get<PageResult<AiotDeviceApi.Roi>>(
|
||||
'/aiot/device/roi/list',
|
||||
{ params },
|
||||
);
|
||||
/** 获取 ROI 列表(分页) */
|
||||
export function getRoiList(params: {
|
||||
page: number;
|
||||
count: number;
|
||||
cameraId?: string;
|
||||
deviceId?: string;
|
||||
query?: string;
|
||||
}) {
|
||||
return wvpRequestClient.get<any>('/aiot/device/roi/list', { params });
|
||||
}
|
||||
|
||||
/** 获取 ROI 详情 */
|
||||
export function getRoiDetail(id: number) {
|
||||
return wvpRequestClient.get<any>(`/aiot/device/roi/${id}`);
|
||||
}
|
||||
|
||||
/** 获取某摄像头的所有 ROI */
|
||||
export function getRoiByCameraId(cameraId: string) {
|
||||
return wvpRequestClient.get<any>('/aiot/device/roi/channel', {
|
||||
params: { cameraId },
|
||||
});
|
||||
}
|
||||
|
||||
/** 保存 ROI */
|
||||
export function saveRoi(data: AiotDeviceApi.Roi) {
|
||||
export function saveRoi(data: Partial<AiotDeviceApi.Roi>) {
|
||||
return wvpRequestClient.post('/aiot/device/roi/save', data);
|
||||
}
|
||||
|
||||
/** 删除 ROI */
|
||||
export function deleteRoi(id: number) {
|
||||
return wvpRequestClient.delete(`/aiot/device/roi/delete?id=${id}`);
|
||||
export function deleteRoi(roiId: string) {
|
||||
return wvpRequestClient.delete(`/aiot/device/roi/delete/${roiId}`);
|
||||
}
|
||||
|
||||
/** 获取截图 URL */
|
||||
export function getSnapUrl(app: string, stream: string) {
|
||||
return `${apiURL}/aiot/device/roi/snap?app=${encodeURIComponent(app)}&stream=${encodeURIComponent(stream)}&t=${Date.now()}`;
|
||||
}
|
||||
|
||||
// ==================== 算法绑定 API ====================
|
||||
|
||||
/** 绑定算法到 ROI */
|
||||
export function bindAlgo(data: { roiId: number; algorithmId: number }) {
|
||||
export function bindAlgo(data: { roiId: string; algoCode: string }) {
|
||||
return wvpRequestClient.post('/aiot/device/roi/bindAlgo', data);
|
||||
}
|
||||
|
||||
/** 解绑算法 */
|
||||
export function unbindAlgo(bindId: number) {
|
||||
return wvpRequestClient.delete(
|
||||
`/aiot/device/roi/unbindAlgo?bindId=${bindId}`,
|
||||
);
|
||||
export function unbindAlgo(bindId: string) {
|
||||
return wvpRequestClient.delete('/aiot/device/roi/unbindAlgo', {
|
||||
params: { bindId },
|
||||
});
|
||||
}
|
||||
|
||||
/** 更新算法参数 */
|
||||
export function updateAlgoParams(data: {
|
||||
bindId: string;
|
||||
params?: string;
|
||||
enabled?: number;
|
||||
}) {
|
||||
return wvpRequestClient.post('/aiot/device/roi/updateAlgoParams', data);
|
||||
}
|
||||
|
||||
// ==================== 算法管理 API ====================
|
||||
|
||||
/** 获取算法列表 */
|
||||
export function getAlgorithmList() {
|
||||
return wvpRequestClient.get<AiotDeviceApi.Algorithm[]>(
|
||||
'/aiot/device/algorithm/list',
|
||||
);
|
||||
return wvpRequestClient.get<any>('/aiot/device/algorithm/list');
|
||||
}
|
||||
|
||||
// ==================== 摄像头通道 API ====================
|
||||
// ==================== 配置推送 API ====================
|
||||
|
||||
/** 获取摄像头通道列表 */
|
||||
export function getChannelPage(params: PageParam) {
|
||||
return wvpRequestClient.get<PageResult<AiotDeviceApi.Channel>>(
|
||||
'/aiot/device/channel/list',
|
||||
{ params },
|
||||
);
|
||||
/** 推送配置到边缘端 */
|
||||
export function pushConfig(cameraId: string) {
|
||||
return wvpRequestClient.post('/aiot/device/config/push', null, {
|
||||
params: { cameraId },
|
||||
});
|
||||
}
|
||||
|
||||
/** 导出配置 */
|
||||
export function exportConfig(cameraId: string) {
|
||||
return wvpRequestClient.get<any>('/aiot/device/config/export', {
|
||||
params: { cameraId },
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user