0fcb77b991
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / Frontend Lint (push) Successful in 1m6s
CI Build & Deploy Pipeline / Build Staging Web Image (push) Successful in 1m49s
CI Build & Deploy Pipeline / Build Production API Image (push) Has been skipped
CI Build & Deploy Pipeline / Build Production Web Image (push) Has been skipped
CI Build & Deploy Pipeline / Build Production Worker Image (push) Has been skipped
CI Build & Deploy Pipeline / Deploy Production (push) Has been skipped
CI Build & Deploy Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Validate Code Quality And Tests (push) Successful in 3m1s
CI/CD Pipeline / Unit Tests (push) Successful in 3m20s
CI/CD Pipeline / Integration Tests (push) Successful in 1m29s
CI Build & Deploy Pipeline / Build Staging API Image (push) Successful in 7m4s
CI Build & Deploy Pipeline / Build Staging Worker Image (push) Successful in 7m54s
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 45s
CI Build & Deploy Pipeline / Staging E2E Tests (push) Failing after 2m50s
CI Build & Deploy Pipeline / Staging API Integration Tests (push) Successful in 3m28s
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com> Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
100 lines
2.7 KiB
TypeScript
100 lines
2.7 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
|
||
}
|