From 5c0554f2f748ebb869291425d8bd8a631ac99944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=B7=E9=BE=99?= Date: Wed, 13 Aug 2025 14:06:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/DTO/movieEdit.ts | 616 +++++++++++++++++++++ api/allMovieType.ts | 518 ----------------- api/video_flow.ts | 19 +- app/service/Interaction/RoleService.ts | 34 +- app/service/Interaction/RoleShotService.ts | 2 +- app/service/Interaction/ShotService.ts | 6 +- app/service/usecase/RoleEditUseCase.ts | 35 +- app/service/usecase/ShotEditUsecase.ts | 128 +---- 8 files changed, 691 insertions(+), 667 deletions(-) create mode 100644 api/DTO/movieEdit.ts delete mode 100644 api/allMovieType.ts diff --git a/api/DTO/movieEdit.ts b/api/DTO/movieEdit.ts new file mode 100644 index 0000000..383746f --- /dev/null +++ b/api/DTO/movieEdit.ts @@ -0,0 +1,616 @@ + +/** + * 视频流程项目相关的TypeScript类型定义 + * 包含角色、场景、服装、音乐等完整的数据结构 + */ +/** + * 角色性别枚举 + */ +export enum Gender { + MALE = 'male', + FEMALE = 'female' +} +/** + * 角色种族枚举 + */ + +export enum Race { + WESTERN = 'Western', + ASIAN = 'Asian', + AFRICAN = 'African', + LATINO = 'Latino', + MIDDLE_EASTERN = 'Middle Eastern', + MIXED = 'Mixed' +} +/** + * 角色类型枚举 + */ + +export enum RoleType { + PROTAGONIST = 'Protagonist', + ANTAGONIST = 'Antagonist', + SUPPORTING = 'Supporting', + BACKGROUND = 'Background' +} +/** + * 项目状态枚举 + */ + +export enum ProjectStatus { + COMPLETED = 'COMPLETED', + IN_PROGRESS = 'IN_PROGRESS', + PENDING = 'PENDING', + FAILED = 'FAILED' +} +/** + * 项目步骤枚举 + */ + +export enum ProjectStep { + INIT = 'INIT', + SKETCH = 'SKETCH', + CHARACTER = 'CHARACTER', + SHOT_SKETCH = 'SHOT_SKETCH', + VIDEO = 'VIDEO', + FINAL = 'FINAL' +} +/** + * 项目模式枚举 + */ + +export enum ProjectMode { + AUTOMATIC = 'automatic', + MANUAL = 'manual', + HYBRID = 'hybrid' +} +/** + * 分辨率枚举 + */ + +export enum Resolution { + P720 = '720p', + P1080 = '1080p', + P4K = '4K' +} +/** + * 语言枚举 + */ + +export enum Language { + EN = 'en', + ZH = 'zh', + JA = 'ja', + KO = 'ko' +} +/** + * 草图提示JSON结构接口 + */ + +export interface SketchPromptJson { + /** 草图名称 */ + sketch_name: string; + /** 草图描述 */ + sketch_description: string; + /** 核心氛围 */ + core_atmosphere: string; +} +/** + * 草图数据项 + */ + +export interface SketchData { + /** 草图名称 */ + sketch_name: string; + /** 图片ID */ + image_id: string; + /** 提示词 */ + prompt: string; + /** 提示词JSON */ + prompt_json: SketchPromptJson; + /** 图片路径 */ + image_path: string; +} +/** + * 草图响应数据接口 + */ + +export interface SketchResponse { + /** 总数 */ + total_count: number; + /** 草图数据列表 */ + data: SketchData[]; +} +/** + * 角色响应数据接口 + */ + +export interface CharacterResponse { + /** 角色图片路径 */ + image_path: string; + /** 角色名称 */ + character_name: string; + /** 角色描述 */ + character_description: string; +} +/** + * 角色数据接口 + */ + +export interface CharacterData { + /** 角色数据列表 */ + data: CharacterResponse[]; + /** 总数 */ + total_count: number; +} +/** + * 镜头草图提示JSON结构接口 + */ + +export interface ShotSketchPromptJson { + /** 镜头类型 */ + shot_type: string; + /** 帧描述 */ + frame_description: string; + /** 关键动作 */ + key_action: string; + /** 氛围 */ + atmosphere: string; + /** 摄影蓝图构图 */ + cinematography_blueprint_composition: string; + /** 摄影蓝图镜头运动 */ + cinematography_blueprint_camera_motion: string; + /** 对话表演台词 */ + dialogue_performance_line?: any; + /** 对话表演语言 */ + dialogue_performance_language?: any; + /** 对话表演表达 */ + dialogue_performance_delivery?: any; + /** 对话表演说话者 */ + dialogue_performance_speaker?: any; +} +/** + * 镜头草图数据项 + */ + +export interface ShotSketchData { + /** 图片ID */ + image_id: string; + /** 描述 */ + description: string; + /** 提示词JSON */ + prompt_json: ShotSketchPromptJson; + /** 图片URL */ + url: string; +} +/** + * 镜头草图响应数据接口 + */ + +export interface ShotSketchResponse { + /** 镜头草图数据列表 */ + data: ShotSketchData[]; + /** 总数 */ + total_count: number; +} +/** + * 主要角色列表项 + */ + +export interface MasterCharacterListItem { + /** 角色ID */ + id: string; + /** 角色名称 */ + name: string; + /** 角色描述 */ + description: string; +} +/** + * 主要服装列表项 + */ + +export interface MasterWardrobeListItem { + /** 所属角色 */ + belongs_to: string; + /** 服装描述 */ + description: string; +} +/** + * 主要场景列表项 + */ + +export interface MasterSceneListItem { + /** 场景名称 */ + name: string; + /** 场景描述 */ + description: string; +} +/** + * 视频提示JSON结构接口 + */ + +export interface VideoPromptJson { + /** 导演指令 */ + directors_directive: string; + /** 叙事提示 */ + narrative_prompt: string; + /** 对话语言 */ + dialogue_language: string; + /** 整体项目风格 */ + overall_project_style: string; + /** 主要角色列表 */ + master_character_list: MasterCharacterListItem[]; + /** 主要服装列表 */ + master_wardrobe_list: MasterWardrobeListItem[]; + /** 主要场景列表 */ + master_scene_list: MasterSceneListItem[]; + /** 核心氛围 */ + core_atmosphere: string; +} +/** + * 视频数据项 + */ + +export interface VideoData { + /** 视频ID */ + video_id: string; + /** 描述 */ + description: string; + /** 提示词JSON */ + prompt_json: VideoPromptJson; + /** 视频名称前缀 */ + video_name_prefix: string; + /** 视频URL列表 */ + urls: string[]; +} +/** + * 视频响应数据接口 + */ + +export interface VideoResponse { + /** 视频数据列表 */ + data: VideoData[]; + /** 总数 */ + total_count: number; + /** 全局ID */ + guid: string; + /** 项目ID */ + project_id: string; +} +/** + * 音乐数据接口 + */ + +export interface MusicData { + [key: string]: any; +} +/** + * 最终视频接口 + */ + +export interface FinalVideo { + /** 最终视频URL */ + video: string; +} +/** + * 多语言视频接口 + */ + +export interface MultilingualVideo { + [key: string]: any; +} +/** + * 项目内容数据接口 + */ + +export interface ProjectContentData { + /** 草图数据 */ + sketch: SketchResponse; + /** 角色数据 */ + character: CharacterData; + /** 镜头草图数据 */ + shot_sketch: ShotSketchResponse; + /** 视频数据 */ + video: VideoResponse; + /** 音乐数据 */ + music: MusicData; + /** 最终视频 */ + final_video: FinalVideo; + /** 多语言视频 */ + multilingual_video: MultilingualVideo; +} +/** + * 视频流程项目 - 完整的接口返回值类型 + */ + +export interface VideoFlowProjectResponse { + /** 项目名称 */ + name: string; + /** 项目ID */ + project_id: string; + /** 项目模式 */ + mode: string; + /** 分辨率 */ + resolution: string; + /** 语言 */ + language: string; + /** 原始文本 */ + original_text: string; + /** 生成的脚本 */ + generated_script: string; + /** 项目状态 */ + status: string; + /** 项目标题 */ + title: string; + /** 项目类型 */ + genre: string; + /** 项目标签 */ + tags: string[]; + /** 项目步骤 */ + step: string; + /** 最后消息 */ + last_message: string; + /** 项目内容 */ + data: ProjectContentData; +} +/** + * 新角色列表项接口 + */ + +export interface NewCharacterItem { + /** 角色名称 */ + character_name: string; + /** 角色描述 */ + character_description: string; + /** 角色类型 */ + role: string; + /** 图片路径 */ + image_path: string; + /** 语音ID */ + voice_id: string; + /** 语音URL */ + voice_url: string; + /** 语音描述 */ + voice_desc: string; + /** 简介 */ + brief: string; + /** 性别 */ + gender: string; + /** 体型年龄 */ + physique_age: string; + /** 关键视觉锚点 */ + key_visual_anchors: string; + /** 发型 */ + hairstyle: string; + /** 默认表情 */ + default_demeanor: string; + /** 种族 */ + race: string; +} +/** + * 新角色列表响应接口 + */ + +export interface NewCharacterListResponse { + /** 角色列表 */ + data: NewCharacterItem[]; +} +/** + * 项目角色列表请求参数 + */ + +export interface CharacterListByProjectRequest { + /** 项目ID */ + project_id: string; + /** 每个角色最多提取的高亮关键词数量 */ + max_keywords?: number; +} +/** + * 项目角色列表项(含高亮关键词) + */ + +export interface CharacterListByProjectItem { + /** 角色名称 */ + character_name: string; + /** 角色自然语言描述 */ + character_description: string; + /** 角色类型/作用 */ + role?: string; + /** 角色图片URL */ + image_path?: string; + /** 角色语音ID */ + voice_id?: string; + /** 角色语音音频URL */ + voice_url?: string; + /** 角色语音描述 */ + voice_desc?: string; + /** 角色简要说明/摘要 */ + brief?: string; + /** 性别 */ + gender?: string; + /** 体格与年龄描述 */ + physique_age?: string; + /** 关键视觉锚点 */ + key_visual_anchors?: string; + /** 发型描述 */ + hairstyle?: string; + /** 默认行为/性格 */ + default_demeanor?: string; + /** 种族/人种 */ + race?: string; + /** 从角色描述提取的高亮关键词/短语 */ + highlights: string[]; +} +/** + * 项目角色列表响应 + */ + +export interface CharacterListByProjectWithHighlightResponse { + /** 项目ID */ + project_id: string; + /** 角色列表 */ + characters: CharacterListByProjectItem[]; +} +/** + * 角色更新和重新生成请求参数 + */ + +export interface CharacterUpdateAndRegenerateRequest { + /** 项目ID */ + project_id: string; + /** 角色名称 */ + character_name: string; + /** 新的角色描述 */ + character_description: string; + /** 返回的高亮关键词数量上限 */ + max_keywords?: number; +} +/** + * 角色更新和重新生成响应 + */ + +export interface CharacterUpdateAndRegenerateResponse { + /** 角色名称 */ + character_name: string; + /** 角色描述(已更新) */ + character_description: string; + /** 重新生成产物的图片地址 */ + image_url?: string; + /** 从角色描述提取的高亮关键词/短语 */ + highlights: string[]; +} +/** + * 角色描述生成请求接口 + */ + +export interface CharacterGenerateDescriptionRequest { + /** 前端提供的原始文字描述 */ + original_text: string; + /** 优化类型 */ + optimization_type?: string; + /** 风格偏好 */ + style_preference?: string; +} +/** + * 角色描述生成响应接口 + */ + +export interface CharacterGenerateDescriptionResponse { + /** 原始文本 */ + original_text: string; + /** 优化后的角色描述 */ + optimized_description: string; + /** 提取的关键词 */ + keywords: string[]; + /** 优化类型 */ + optimization_type: string; + /** 风格偏好 */ + style_preference: string; +}/** + * 边界框坐标信息 + * @description 描述检测到的人物在图片中的位置和尺寸 + */ + + + + + +export interface BoundingBox { + /** X坐标(像素) */ + x: number; + /** Y坐标(像素) */ + y: number; + /** 宽度(像素) */ + width: number; + /** 高度(像素) */ + height: number; +} +/** + * 匹配的人物信息 + * @description 从图片中识别出的与已知角色匹配的人物信息 + */ + +export interface MatchedPerson { + /** 人物名 */ + person_id: string; + /**x坐标 小数百分比形式 */ + x: number; + /**y坐标 小数百分比形式 */ + y: number; + /**宽度 小数百分比形式 */ + width: number; + /**高度 小数百分比形式 */ + height: number; +} +/** + * 角色识别结果数据 + * @description AI识别图片中人物后的详细结果 + */ + +export interface RecognitionResultData { + /** 目标图片URL */ + target_image_url: string; + /** 检测到的总人数 */ + total_persons_detected: number; + /** 匹配的人物列表 */ + matched_persons: MatchedPerson[]; +} +/** + * 角色识别响应结果 + * @description API返回的角色识别完整响应 + */ + +export interface RecognitionResult { + /** 响应状态码 */ + code: number; + /** 响应消息 */ + message: string; + /** 识别结果数据 */ + data: RecognitionResultData; +} +/** + * 使用的角色信息 + * @description 在识别过程中使用的已知角色信息 + */ + +export interface CharacterUsed { + /** 角色名称 */ + character_name: string; + /** 角色C-ID */ + c_id: string; + /** 角色图片路径 */ + image_path: string; + /** 角色头像 */ + avatar: string; +} +/** + * 角色识别API响应类型 + * @description 完整的角色识别API响应结构 + */ + +export interface RoleRecognitionResponse { + /** 项目ID */ + project_id: string; + /** 视频ID */ + video_id: string; + /** 目标图片URL */ + target_image_url: string; + /** 已知人物数量 */ + known_persons_count: number; + /** 识别结果 */ + recognition_result: RecognitionResult; + /** 使用的角色列表 */ + characters_used: CharacterUsed[]; +} +export interface RoleResponse { + /** 角色描述 */ + character_description: string; + /** 角色名称 */ + character_name: string; + /** 高亮关键词 */ + highlights: string[]; + /** 角色图片地址 */ + image_path: string; + /**缓存 */ + character_draft: string; +} + diff --git a/api/allMovieType.ts b/api/allMovieType.ts deleted file mode 100644 index 75f9f82..0000000 --- a/api/allMovieType.ts +++ /dev/null @@ -1,518 +0,0 @@ -/** - * 视频流程项目相关的TypeScript类型定义 - * 包含角色、场景、服装、音乐等完整的数据结构 - */ - -/** - * 角色性别枚举 - */ -export enum Gender { - MALE = 'male', - FEMALE = 'female' - } - - /** - * 角色种族枚举 - */ - export enum Race { - WESTERN = 'Western', - ASIAN = 'Asian', - AFRICAN = 'African', - LATINO = 'Latino', - MIDDLE_EASTERN = 'Middle Eastern', - MIXED = 'Mixed' - } - - /** - * 角色类型枚举 - */ - export enum RoleType { - PROTAGONIST = 'Protagonist', - ANTAGONIST = 'Antagonist', - SUPPORTING = 'Supporting', - BACKGROUND = 'Background' - } - - /** - * 项目状态枚举 - */ - export enum ProjectStatus { - COMPLETED = 'COMPLETED', - IN_PROGRESS = 'IN_PROGRESS', - PENDING = 'PENDING', - FAILED = 'FAILED' - } - - /** - * 项目步骤枚举 - */ - export enum ProjectStep { - INIT = 'INIT', - SKETCH = 'SKETCH', - CHARACTER = 'CHARACTER', - SHOT_SKETCH = 'SHOT_SKETCH', - VIDEO = 'VIDEO', - FINAL = 'FINAL' - } - - /** - * 项目模式枚举 - */ - export enum ProjectMode { - AUTOMATIC = 'automatic', - MANUAL = 'manual', - HYBRID = 'hybrid' - } - - /** - * 分辨率枚举 - */ - export enum Resolution { - P720 = '720p', - P1080 = '1080p', - P4K = '4K' - } - - /** - * 语言枚举 - */ - export enum Language { - EN = 'en', - ZH = 'zh', - JA = 'ja', - KO = 'ko' - } - - /** - * 草图提示JSON结构接口 - */ - export interface SketchPromptJson { - /** 草图名称 */ - sketch_name: string; - /** 草图描述 */ - sketch_description: string; - /** 核心氛围 */ - core_atmosphere: string; - } - - /** - * 草图数据项 - */ - export interface SketchData { - /** 草图名称 */ - sketch_name: string; - /** 图片ID */ - image_id: string; - /** 提示词 */ - prompt: string; - /** 提示词JSON */ - prompt_json: SketchPromptJson; - /** 图片路径 */ - image_path: string; - } - - /** - * 草图响应数据接口 - */ - export interface SketchResponse { - /** 总数 */ - total_count: number; - /** 草图数据列表 */ - data: SketchData[]; - } - - /** - * 角色响应数据接口 - */ - export interface CharacterResponse { - /** 角色图片路径 */ - image_path: string; - /** 角色名称 */ - character_name: string; - /** 角色描述 */ - character_description: string; - } - - /** - * 角色数据接口 - */ - export interface CharacterData { - /** 角色数据列表 */ - data: CharacterResponse[]; - /** 总数 */ - total_count: number; - } - - /** - * 镜头草图提示JSON结构接口 - */ - export interface ShotSketchPromptJson { - /** 镜头类型 */ - shot_type: string; - /** 帧描述 */ - frame_description: string; - /** 关键动作 */ - key_action: string; - /** 氛围 */ - atmosphere: string; - /** 摄影蓝图构图 */ - cinematography_blueprint_composition: string; - /** 摄影蓝图镜头运动 */ - cinematography_blueprint_camera_motion: string; - /** 对话表演台词 */ - dialogue_performance_line?: any; - /** 对话表演语言 */ - dialogue_performance_language?: any; - /** 对话表演表达 */ - dialogue_performance_delivery?: any; - /** 对话表演说话者 */ - dialogue_performance_speaker?: any; - } - - /** - * 镜头草图数据项 - */ - export interface ShotSketchData { - /** 图片ID */ - image_id: string; - /** 描述 */ - description: string; - /** 提示词JSON */ - prompt_json: ShotSketchPromptJson; - /** 图片URL */ - url: string; - } - - /** - * 镜头草图响应数据接口 - */ - export interface ShotSketchResponse { - /** 镜头草图数据列表 */ - data: ShotSketchData[]; - /** 总数 */ - total_count: number; - } - - /** - * 主要角色列表项 - */ - export interface MasterCharacterListItem { - /** 角色ID */ - id: string; - /** 角色名称 */ - name: string; - /** 角色描述 */ - description: string; - } - - /** - * 主要服装列表项 - */ - export interface MasterWardrobeListItem { - /** 所属角色 */ - belongs_to: string; - /** 服装描述 */ - description: string; - } - - /** - * 主要场景列表项 - */ - export interface MasterSceneListItem { - /** 场景名称 */ - name: string; - /** 场景描述 */ - description: string; - } - - /** - * 视频提示JSON结构接口 - */ - export interface VideoPromptJson { - /** 导演指令 */ - directors_directive: string; - /** 叙事提示 */ - narrative_prompt: string; - /** 对话语言 */ - dialogue_language: string; - /** 整体项目风格 */ - overall_project_style: string; - /** 主要角色列表 */ - master_character_list: MasterCharacterListItem[]; - /** 主要服装列表 */ - master_wardrobe_list: MasterWardrobeListItem[]; - /** 主要场景列表 */ - master_scene_list: MasterSceneListItem[]; - /** 核心氛围 */ - core_atmosphere: string; - } - - /** - * 视频数据项 - */ - export interface VideoData { - /** 视频ID */ - video_id: string; - /** 描述 */ - description: string; - /** 提示词JSON */ - prompt_json: VideoPromptJson; - /** 视频名称前缀 */ - video_name_prefix: string; - /** 视频URL列表 */ - urls: string[]; - } - - /** - * 视频响应数据接口 - */ - export interface VideoResponse { - /** 视频数据列表 */ - data: VideoData[]; - /** 总数 */ - total_count: number; - /** 全局ID */ - guid: string; - /** 项目ID */ - project_id: string; - } - - /** - * 音乐数据接口 - */ - export interface MusicData { - [key: string]: any; - } - - /** - * 最终视频接口 - */ - export interface FinalVideo { - /** 最终视频URL */ - video: string; - } - - /** - * 多语言视频接口 - */ - export interface MultilingualVideo { - [key: string]: any; - } - - /** - * 项目内容数据接口 - */ - export interface ProjectContentData { - /** 草图数据 */ - sketch: SketchResponse; - /** 角色数据 */ - character: CharacterData; - /** 镜头草图数据 */ - shot_sketch: ShotSketchResponse; - /** 视频数据 */ - video: VideoResponse; - /** 音乐数据 */ - music: MusicData; - /** 最终视频 */ - final_video: FinalVideo; - /** 多语言视频 */ - multilingual_video: MultilingualVideo; - } - - /** - * 视频流程项目 - 完整的接口返回值类型 - */ - export interface VideoFlowProjectResponse { - /** 项目名称 */ - name: string; - /** 项目ID */ - project_id: string; - /** 项目模式 */ - mode: string; - /** 分辨率 */ - resolution: string; - /** 语言 */ - language: string; - /** 原始文本 */ - original_text: string; - /** 生成的脚本 */ - generated_script: string; - /** 项目状态 */ - status: string; - /** 项目标题 */ - title: string; - /** 项目类型 */ - genre: string; - /** 项目标签 */ - tags: string[]; - /** 项目步骤 */ - step: string; - /** 最后消息 */ - last_message: string; - /** 项目内容 */ - data: ProjectContentData; - } - - // 为了向后兼容,保留原有的接口名称 - export interface Character extends CharacterResponse {} - export interface Sketch extends SketchResponse {} - export interface Shot_sketch extends ShotSketchResponse {} - export interface Video extends VideoResponse {} - export interface Music extends MusicData {} - export interface Final_video extends FinalVideo {} - export interface Multilingual_video extends MultilingualVideo {} - export interface RootObject extends VideoFlowProjectResponse {} - - /** - * 新角色列表项接口 - */ - export interface NewCharacterItem { - /** 角色名称 */ - character_name: string; - /** 角色描述 */ - character_description: string; - /** 角色类型 */ - role: string; - /** 图片路径 */ - image_path: string; - /** 语音ID */ - voice_id: string; - /** 语音URL */ - voice_url: string; - /** 语音描述 */ - voice_desc: string; - /** 简介 */ - brief: string; - /** 性别 */ - gender: string; - /** 体型年龄 */ - physique_age: string; - /** 关键视觉锚点 */ - key_visual_anchors: string; - /** 发型 */ - hairstyle: string; - /** 默认表情 */ - default_demeanor: string; - /** 种族 */ - race: string; - } - - /** - * 新角色列表响应接口 - */ - export interface NewCharacterListResponse { - /** 角色列表 */ - data: NewCharacterItem[]; - } - -/** - * 项目角色列表请求参数 - */ -export interface CharacterListByProjectRequest { - /** 项目ID */ - project_id: string; - /** 每个角色最多提取的高亮关键词数量 */ - max_keywords?: number; -} - -/** - * 项目角色列表项(含高亮关键词) - */ -export interface CharacterListByProjectItem { - /** 角色名称 */ - character_name: string; - /** 角色自然语言描述 */ - character_description: string; - /** 角色类型/作用 */ - role?: string; - /** 角色图片URL */ - image_path?: string; - /** 角色语音ID */ - voice_id?: string; - /** 角色语音音频URL */ - voice_url?: string; - /** 角色语音描述 */ - voice_desc?: string; - /** 角色简要说明/摘要 */ - brief?: string; - /** 性别 */ - gender?: string; - /** 体格与年龄描述 */ - physique_age?: string; - /** 关键视觉锚点 */ - key_visual_anchors?: string; - /** 发型描述 */ - hairstyle?: string; - /** 默认行为/性格 */ - default_demeanor?: string; - /** 种族/人种 */ - race?: string; - /** 从角色描述提取的高亮关键词/短语 */ - highlights: string[]; -} - -/** - * 项目角色列表响应 - */ -export interface CharacterListByProjectWithHighlightResponse { - /** 项目ID */ - project_id: string; - /** 角色列表 */ - characters: CharacterListByProjectItem[]; -} - -/** - * 角色更新和重新生成请求参数 - */ -export interface CharacterUpdateAndRegenerateRequest { - /** 项目ID */ - project_id: string; - /** 角色名称 */ - character_name: string; - /** 新的角色描述 */ - character_description: string; - /** 返回的高亮关键词数量上限 */ - max_keywords?: number; -} - -/** - * 角色更新和重新生成响应 - */ -export interface CharacterUpdateAndRegenerateResponse { - /** 角色名称 */ - character_name: string; - /** 角色描述(已更新) */ - character_description: string; - /** 重新生成产物的图片地址 */ - image_url?: string; - /** 从角色描述提取的高亮关键词/短语 */ - highlights: string[]; -} - -/** - * 角色描述生成请求接口 - */ -export interface CharacterGenerateDescriptionRequest { - /** 前端提供的原始文字描述 */ - original_text: string; - /** 优化类型 */ - optimization_type?: string; - /** 风格偏好 */ - style_preference?: string; -} - -/** - * 角色描述生成响应接口 - */ -export interface CharacterGenerateDescriptionResponse { - /** 原始文本 */ - original_text: string; - /** 优化后的角色描述 */ - optimized_description: string; - /** 提取的关键词 */ - keywords: string[]; - /** 优化类型 */ - optimization_type: string; - /** 风格偏好 */ - style_preference: string; -} diff --git a/api/video_flow.ts b/api/video_flow.ts index 7cbbc58..f8752d8 100644 --- a/api/video_flow.ts +++ b/api/video_flow.ts @@ -15,9 +15,9 @@ import { ScriptSlice, } from "@/app/service/domain/valueObject"; import { task_item, VideoSegmentEntityAdapter } from "@/app/service/adapter/oldErrAdapter"; -import { VideoFlowProjectResponse, NewCharacterItem, NewCharacterListResponse, CharacterListByProjectWithHighlightResponse, CharacterUpdateAndRegenerateRequest, CharacterUpdateAndRegenerateResponse } from "./allMovieType"; -import { RoleResponse } from "@/app/service/usecase/RoleEditUseCase"; -import { RoleRecognitionResponse } from "@/app/service/usecase/ShotEditUsecase"; +import { VideoFlowProjectResponse, NewCharacterItem, NewCharacterListResponse, CharacterListByProjectWithHighlightResponse, CharacterUpdateAndRegenerateRequest, CharacterUpdateAndRegenerateResponse } from "./DTO/movieEdit"; +import { RoleResponse } from "./DTO/movieEdit"; +import { RoleRecognitionResponse } from "./DTO/movieEdit"; /** * 角色替换参数接口 @@ -1064,4 +1064,17 @@ export const analyzeImageDescription = async (request: { }>>("/character/analyze_image_description", request); }; +/** + * 检查分镜视频状态 + * @description 保存当前项目数据 + * @param request - 请求参数 + * @returns Promise> 保存结果 + */ +export const checkShotVideoStatus = async (request: { + /** 项目ID */ + project_id: string; +}): Promise> => { + return post>("/check_shot_video_status", request); +}; + diff --git a/app/service/Interaction/RoleService.ts b/app/service/Interaction/RoleService.ts index 5fb6302..ae86ad9 100644 --- a/app/service/Interaction/RoleService.ts +++ b/app/service/Interaction/RoleService.ts @@ -2,7 +2,7 @@ import { useState, useCallback, useMemo } from 'react'; import { RoleEntity, AITextEntity } from '../domain/Entities'; import { RoleEditUseCase } from '../usecase/RoleEditUseCase'; import { getUploadToken, uploadToQiniu } from '@/api/common'; -import { analyzeImageDescription } from '@/api/video_flow'; +import { analyzeImageDescription, checkShotVideoStatus } from '@/api/video_flow'; /** * 角色服务Hook返回值接口 @@ -38,6 +38,8 @@ interface UseRoleService { uploadImageAndUpdateRole: (file: File) => Promise; /** 保存重新生成的角色到角色库 */ saveRoleToLibrary: () => Promise; + /** 保存数据 */ + saveData: () => Promise; } /** @@ -419,6 +421,33 @@ export const useRoleServiceHook = (): UseRoleService => { } }, [selectedRole, roleEditUseCase, projectId]); + /** + * 保存数据 + * @description 调用接口保存当前项目数据 + * @throws {Error} 当缺少项目ID或API调用失败时抛出错误 + * @returns {Promise} 保存完成后的Promise + */ + const saveData = useCallback(async () => { + if (!projectId) { + throw new Error('缺少项目ID,无法保存数据'); + } + + try { + const result = await checkShotVideoStatus({ + project_id: projectId + }); + + if (!result.successful) { + throw new Error(`保存数据失败: ${result.message}`); + } + + console.log('数据保存成功'); + } catch (error) { + console.error('保存数据失败:', error); + throw error; + } + }, [projectId]); + return { // 响应式数据 roleList, @@ -436,6 +465,7 @@ export const useRoleServiceHook = (): UseRoleService => { fetchUserRoleLibrary, replaceRoleWithLibrary, uploadImageAndUpdateRole, - saveRoleToLibrary + saveRoleToLibrary, + saveData }; }; diff --git a/app/service/Interaction/RoleShotService.ts b/app/service/Interaction/RoleShotService.ts index 9572c1d..80065b4 100644 --- a/app/service/Interaction/RoleShotService.ts +++ b/app/service/Interaction/RoleShotService.ts @@ -175,7 +175,7 @@ export const useRoleShotServiceHook = (projectId: string,selectRole?:RoleEntity) // 循环调用接口,为每个选中的分镜单独调用 shotSelectionList.forEach(async (shot) => { try { - (selectedRole as any).shot = shot.videoUrl; + (selectedRole as any).shot = shot; // 调用应用角色到分镜接口(不等待完成) applyRoleToShots({ project_id: projectId, diff --git a/app/service/Interaction/ShotService.ts b/app/service/Interaction/ShotService.ts index 3d68847..90f7439 100644 --- a/app/service/Interaction/ShotService.ts +++ b/app/service/Interaction/ShotService.ts @@ -1,9 +1,11 @@ import { useState, useCallback, useEffect } from "react"; import { - MatchedPerson, - RoleRecognitionResponse, VideoSegmentEditUseCase, } from "../usecase/ShotEditUsecase"; +import { + MatchedPerson, + RoleRecognitionResponse +} from "@/api/DTO/movieEdit"; import { VideoSegmentEntity } from "../domain/Entities"; import { LensType, SimpleCharacter } from "../domain/valueObject"; import { getUploadToken, uploadToQiniu } from "@/api/common"; diff --git a/app/service/usecase/RoleEditUseCase.ts b/app/service/usecase/RoleEditUseCase.ts index 2cd8e85..639211f 100644 --- a/app/service/usecase/RoleEditUseCase.ts +++ b/app/service/usecase/RoleEditUseCase.ts @@ -1,4 +1,4 @@ -import { NewCharacterItem, CharacterListByProjectItem, CharacterListByProjectWithHighlightResponse, CharacterUpdateAndRegenerateRequest, CharacterUpdateAndRegenerateResponse } from '@/api/allMovieType'; +import { NewCharacterItem, CharacterListByProjectItem, CharacterListByProjectWithHighlightResponse, CharacterUpdateAndRegenerateRequest, CharacterUpdateAndRegenerateResponse, RoleResponse } from "@/api/DTO/movieEdit"; import { RoleEntity } from '../domain/Entities'; import { applyRoleToShots, @@ -13,21 +13,9 @@ import { generateCharacterDescription, saveRegeneratedCharacter, getSimilarCharacters, + checkShotVideoStatus, } from '@/api/video_flow'; -export interface RoleResponse { - /** 角色描述 */ - character_description: string; - /** 角色名称 */ - character_name: string; - /** 高亮关键词 */ - highlights: string[]; - /** 角色图片地址 */ - image_path: string; - /**缓存 */ - character_draft: string; -} - /** * 角色图编辑用例 * 负责角色图内容的初始化、修改和优化 @@ -424,6 +412,25 @@ export class RoleEditUseCase { } } + /** + * @description 检查镜头视频状态 + * @param projectId 项目ID + * @returns Promise 镜头视频状态信息 + */ + async checkShotVideoStatus(projectId: string): Promise { + try { + // 这里需要调用后端API来检查镜头视频状态 + // 由于这是一个新的功能,需要根据实际的后端API接口来实现 + // 目前返回一个模拟的状态信息 + // TODO: 替换为真实的API调用 + const response = await checkShotVideoStatus({ project_id: projectId }); + + return response.data; + } catch (error) { + console.error('检查镜头视频状态失败:', error); + throw new Error('检查镜头视频状态失败'); + } + } } diff --git a/app/service/usecase/ShotEditUsecase.ts b/app/service/usecase/ShotEditUsecase.ts index a2013d5..fcd125c 100644 --- a/app/service/usecase/ShotEditUsecase.ts +++ b/app/service/usecase/ShotEditUsecase.ts @@ -1,4 +1,4 @@ -import { VideoFlowProjectResponse } from "@/api/allMovieType"; +import { VideoFlowProjectResponse } from "@/api/DTO/movieEdit"; import { task_item, VideoSegmentEntityAdapter } from "../adapter/oldErrAdapter"; import { VideoSegmentEntity } from "../domain/Entities"; import { LensType } from "../domain/valueObject"; @@ -351,130 +351,4 @@ export class VideoSegmentEditUseCase { -/** - * 边界框坐标信息 - * @description 描述检测到的人物在图片中的位置和尺寸 - */ -export interface BoundingBox { - /** X坐标(像素) */ - x: number; - /** Y坐标(像素) */ - y: number; - /** 宽度(像素) */ - width: number; - /** 高度(像素) */ - height: number; -} -/** - * 匹配的人物信息 - * @description 从图片中识别出的与已知角色匹配的人物信息 - */ -export interface MatchedPerson { - /** 人物名 */ - person_id: string; - /**x坐标 小数百分比形式 */ - x: number; - /**y坐标 小数百分比形式 */ - y: number; - /**宽度 小数百分比形式 */ - width: number; - /**高度 小数百分比形式 */ - height: number; -} - -/** - * 角色识别结果数据 - * @description AI识别图片中人物后的详细结果 - */ -export interface RecognitionResultData { - /** 目标图片URL */ - target_image_url: string; - /** 检测到的总人数 */ - total_persons_detected: number; - /** 匹配的人物列表 */ - matched_persons: MatchedPerson[]; -} - -/** - * 角色识别响应结果 - * @description API返回的角色识别完整响应 - */ -export interface RecognitionResult { - /** 响应状态码 */ - code: number; - /** 响应消息 */ - message: string; - /** 识别结果数据 */ - data: RecognitionResultData; -} - -/** - * 使用的角色信息 - * @description 在识别过程中使用的已知角色信息 - */ -export interface CharacterUsed { - /** 角色名称 */ - character_name: string; - /** 角色C-ID */ - c_id: string; - /** 角色图片路径 */ - image_path: string; - /** 角色头像 */ - avatar: string; -} - -/** - * 角色识别API响应类型 - * @description 完整的角色识别API响应结构 - */ -export interface RoleRecognitionResponse { - /** 项目ID */ - project_id: string; - /** 视频ID */ - video_id: string; - /** 目标图片URL */ - target_image_url: string; - /** 已知人物数量 */ - known_persons_count: number; - /** 识别结果 */ - recognition_result: RecognitionResult; - /** 使用的角色列表 */ - characters_used: CharacterUsed[]; -} - -// export const roleRecognitionResponse:RoleRecognitionResponse = { -// "project_id": "d0df7120-e27b-4f84-875c-e532f1bd318c", -// "video_id": "984f3347-c81c-4af8-9145-49ead82becde", -// "target_image_url": "https://cdn.qikongjian.com/videos/1754970412744_kqxplx.png", -// "known_persons_count": 1, -// "recognition_result": { -// "code": 200, -// "message": "识别完成", -// "data": -// { -// "target_image_url": "https://cdn.qikongjian.com/videos/1754970412744_kqxplx.png", -// "total_persons_detected": 1, -// "matched_persons": [ -// { -// "person_id": "CH-01", -// "bbox": { -// "x": 269, -// "y": 23, -// "width": 585, -// "height": 685 -// }, -// "confidence": 0.36905956268310547 -// } -// ] -// } -// }, -// "characters_used": [ -// { -// "character_name": "CH-01", -// "c_id": "无C-ID", -// "image_path": "无image_path", -// "avatar": "https://cdn.huiying.video/template/Whisk_9afb196368.jpg" -// } -// ] -// }