8935196fcd
Deploy / Staging E2E Tests (push) Has been skipped
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
Deploy / Deploy Staging (push) Failing after 138h4m33s
CI/CD Pipeline / Frontend Lint (push) Failing after 138h4m39s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 138h4m39s
111 lines
2.8 KiB
TypeScript
111 lines
2.8 KiB
TypeScript
/**
|
||
* 查重 API 模块
|
||
* 提供视频查重相关接口
|
||
*/
|
||
import apiClient from "./client";
|
||
|
||
/** 查重记录状态 */
|
||
export type DuplicationStatus =
|
||
"pending" | "processing" | "completed" | "failed";
|
||
|
||
/** 查重记录 */
|
||
export interface DuplicationRecord {
|
||
id: string;
|
||
/** 原始文件名 */
|
||
filename: string;
|
||
/** 文件大小(字节) */
|
||
file_size: number;
|
||
/** 时长(秒) */
|
||
duration_seconds?: number;
|
||
/** 状态 */
|
||
status: DuplicationStatus;
|
||
/** 查重率(0-100) */
|
||
duplicate_rate?: number;
|
||
/** 重复片段数 */
|
||
duplicate_count?: number;
|
||
/** 创建时间 */
|
||
created_at: string;
|
||
/** 更新时间 */
|
||
updated_at: string;
|
||
}
|
||
|
||
/** 重复片段详情 */
|
||
export interface DuplicateSegment {
|
||
id: string;
|
||
/** 在原始视频中的起始时间(秒) */
|
||
source_start: number;
|
||
/** 在原始视频中的结束时间(秒) */
|
||
source_end: number;
|
||
/** 匹配到的已有视频 ID */
|
||
matched_video_id: string;
|
||
/** 匹配到的已有视频名称 */
|
||
matched_video_name: string;
|
||
/** 匹配片段在已有视频中的起始时间 */
|
||
matched_start: number;
|
||
/** 匹配片段在已有视频中的结束时间 */
|
||
matched_end: number;
|
||
/** 相似度(0-100) */
|
||
similarity: number;
|
||
}
|
||
|
||
/** 查重详情 */
|
||
export interface DuplicationDetail extends DuplicationRecord {
|
||
/** 重复片段列表 */
|
||
segments: DuplicateSegment[];
|
||
}
|
||
|
||
/** 上传查重响应 */
|
||
export interface DuplicationUploadResponse {
|
||
/** 查重记录 ID */
|
||
id: string;
|
||
/** 状态 */
|
||
status: DuplicationStatus;
|
||
/** 消息 */
|
||
message: string;
|
||
}
|
||
|
||
// ============ API 函数 ============
|
||
|
||
/** 上传视频进行查重 */
|
||
export const uploadForDuplication = async (
|
||
file: File,
|
||
): Promise<DuplicationUploadResponse> => {
|
||
const formData = new FormData();
|
||
formData.append("file", file);
|
||
const response = await apiClient.post("/duplication/upload", formData, {
|
||
headers: { "Content-Type": "multipart/form-data" },
|
||
});
|
||
return response.data;
|
||
};
|
||
|
||
/** 获取查重记录列表 */
|
||
export const getDuplicationRecords = async (): Promise<DuplicationRecord[]> => {
|
||
const response = await apiClient.get("/duplication/records");
|
||
return response.data;
|
||
};
|
||
|
||
/** 获取查重详情 */
|
||
export const getDuplicationDetail = async (
|
||
recordId: string,
|
||
): Promise<DuplicationDetail> => {
|
||
const response = await apiClient.get(`/duplication/records/${recordId}`);
|
||
return response.data;
|
||
};
|
||
|
||
/** 删除查重记录 */
|
||
export const deleteDuplicationRecord = async (
|
||
recordId: string,
|
||
): Promise<void> => {
|
||
await apiClient.delete(`/duplication/records/${recordId}`);
|
||
};
|
||
|
||
/** 重新查重 */
|
||
export const retryDuplication = async (
|
||
recordId: string,
|
||
): Promise<DuplicationUploadResponse> => {
|
||
const response = await apiClient.post(
|
||
`/duplication/records/${recordId}/retry`,
|
||
);
|
||
return response.data;
|
||
};
|