| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- import client from './client'
- import type {
- AIUnderstandingVO,
- ArticleBasicVO,
- CommonResponse,
- DeconstructPointsVO,
- DeconstructQueryParam,
- DeconstructResultVO,
- DeconstructSubmitParam,
- MatchByArticleIdParam,
- MatchByMaterialIdParam,
- MatchByTextParam,
- MatchByVideoIdParam,
- MaterialBasicVO,
- RecallResultVO,
- VideoBasicVO,
- } from './types'
- const EMPTY_RESULT: RecallResultVO = {
- items: [],
- videoCount: 0,
- materialCount: 0,
- articleCount: 0,
- total: 0,
- }
- /**
- * 后端 MATERIAL 模态下 id 为 null,materialId(图片 md5)才是实际主键。
- * 前端组件统一用 item.id 做 rowKey/筛选/展示,这里在数据入口处把 materialId 回填到 id。
- */
- function normalizeRecallResult(data: RecallResultVO | null | undefined): RecallResultVO {
- if (!data) return EMPTY_RESULT
- const items = data.items.map((it) => {
- if (it.id == null && it.materialId) return { ...it, id: it.materialId }
- if (it.id == null && it.articleId) return { ...it, id: it.articleId }
- return it
- })
- return { ...data, items }
- }
- /** Tab1: 获取视频基础详情 */
- export async function getVideoDetail(videoId: string): Promise<VideoBasicVO | null> {
- const resp = await client.get<CommonResponse<VideoBasicVO | null>>(
- '/recallTest/videoDetail',
- { params: { videoId } },
- )
- return resp.data?.data ?? null
- }
- /** Tab2: 文本召回 */
- export async function matchByText(param: MatchByTextParam): Promise<RecallResultVO> {
- const resp = await client.post<CommonResponse<RecallResultVO>>(
- '/recallTest/matchByText',
- param,
- )
- return normalizeRecallResult(resp.data?.data)
- }
- /** Tab1: 通过视频ID召回相似 */
- export async function matchByVideoId(param: MatchByVideoIdParam): Promise<RecallResultVO> {
- const resp = await client.post<CommonResponse<RecallResultVO>>(
- '/recallTest/matchByVideoId',
- param,
- )
- return normalizeRecallResult(resp.data?.data)
- }
- /** Tab3: 获取素材基础信息 (图片URL等, 用于预览) */
- export async function getMaterialDetail(materialId: string): Promise<MaterialBasicVO | null> {
- const resp = await client.get<CommonResponse<MaterialBasicVO | null>>(
- '/recallTest/materialDetail',
- { params: { materialId } },
- )
- return resp.data?.data ?? null
- }
- /** Tab3: 通过素材ID召回相似 */
- export async function matchByMaterialId(param: MatchByMaterialIdParam): Promise<RecallResultVO> {
- const resp = await client.post<CommonResponse<RecallResultVO>>(
- '/recallTest/matchByMaterialId',
- param,
- )
- return normalizeRecallResult(resp.data?.data)
- }
- /** Tab4: 获取长文基础信息 */
- export async function getArticleDetail(articleId: string): Promise<ArticleBasicVO | null> {
- const resp = await client.get<CommonResponse<ArticleBasicVO | null>>(
- '/recallTest/articleDetail',
- { params: { articleId } },
- )
- return resp.data?.data ?? null
- }
- /** Tab4: 通过长文ID召回相似 */
- export async function matchByArticleId(param: MatchByArticleIdParam): Promise<RecallResultVO> {
- const resp = await client.post<CommonResponse<RecallResultVO>>(
- '/recallTest/matchByArticleId',
- param,
- )
- return normalizeRecallResult(resp.data?.data)
- }
- /** Tab1: 视频/素材的解构层级 */
- export async function getDeconstructPoints(videoId: string): Promise<DeconstructPointsVO | null> {
- const resp = await client.get<CommonResponse<DeconstructPointsVO | null>>(
- '/recallTest/deconstructPoints',
- { params: { videoId } },
- )
- return resp.data?.data ?? null
- }
- /** Tab1: AI理解结果 (未就绪时返回 null) */
- export async function getAiUnderstanding(videoId: string): Promise<AIUnderstandingVO | null> {
- const resp = await client.get<CommonResponse<AIUnderstandingVO | null>>(
- '/recallTest/aiUnderstanding',
- { params: { videoId } },
- )
- return resp.data?.data ?? null
- }
- /** 召回维度字典: configCode -> 中文标签 */
- export async function getAllConfigCodes(): Promise<Record<string, string>> {
- const resp = await client.get<CommonResponse<Record<string, string>>>(
- '/videoSearch/getAllConfigCodes',
- )
- return resp.data?.data ?? {}
- }
- /** Tab3: 提交素材解构任务 - 返回 taskId */
- export async function submitDeconstruct(param: DeconstructSubmitParam): Promise<string> {
- const resp = await client.post<CommonResponse<string>>(
- '/videoSearch/deconstruct',
- param,
- )
- return resp.data?.data ?? ''
- }
- /** Tab3: 查询解构结果 (轮询用; 走精简接口, 后端直接返回 topic + highValuePoints) */
- export async function getDeconstructResult(
- param: DeconstructQueryParam,
- ): Promise<DeconstructResultVO | null> {
- const resp = await client.post<CommonResponse<DeconstructResultVO | null>>(
- '/videoSearch/getDeconstructResultMini',
- param,
- )
- return resp.data?.data ?? null
- }
|