|
|
@@ -195,14 +195,14 @@ class AnimeService
|
|
|
if (!empty($anime_id)) {
|
|
|
$boolen = DB::table('mp_animes')->where('id', $anime_id)->update($table_data);
|
|
|
if (!$boolen) {
|
|
|
- dLog('deepseek')->info('对话保存失败', $table_data);
|
|
|
+ dLog('anime')->info('对话保存失败', $table_data);
|
|
|
Utils::throwError('20003:对话保存失败');
|
|
|
}
|
|
|
}else {
|
|
|
$table['created_at'] = $table_data['updated_at'];
|
|
|
$anime_id = DB::table('mp_animes')->insertGetId($table_data);
|
|
|
if (!$anime_id) {
|
|
|
- dLog('deepseek')->info('对话保存失败', $table_data);
|
|
|
+ dLog('anime')->info('对话保存失败', $table_data);
|
|
|
Utils::throwError('20003:对话保存失败');
|
|
|
}
|
|
|
}
|
|
|
@@ -462,6 +462,136 @@ class AnimeService
|
|
|
return $img_url;
|
|
|
}
|
|
|
|
|
|
+ public function changeEpisodeRoles($data) {
|
|
|
+ $anime_id = getProp($data, 'anime_id');
|
|
|
+ $episode_id = getProp($data, 'episode_id');
|
|
|
+ $roles = getProp($data, 'roles');
|
|
|
+
|
|
|
+ // 参数验证
|
|
|
+ if (!$anime_id) Utils::throwError('20003:请提供动漫ID');
|
|
|
+ if (!$episode_id) Utils::throwError('20003:请提供剧集ID');
|
|
|
+ if (!is_array($roles)) Utils::throwError('20003:角色列表必须是数组格式');
|
|
|
+
|
|
|
+ // 验证剧集是否存在
|
|
|
+ $episode = DB::table('mp_anime_episodes')
|
|
|
+ ->where('anime_id', $anime_id)
|
|
|
+ ->where('id', $episode_id)
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ if (!$episode) Utils::throwError('20003:该剧集不存在');
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 更新角色列表
|
|
|
+ $result = DB::table('mp_anime_episodes')
|
|
|
+ ->where('anime_id', $anime_id)
|
|
|
+ ->where('id', $episode_id)
|
|
|
+ ->update([
|
|
|
+ 'roles' => json_encode($roles, 256),
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s')
|
|
|
+ ]);
|
|
|
+
|
|
|
+ if ($result === false) {
|
|
|
+ Utils::throwError('20003:更新角色列表失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ return ['success' => true, 'message' => '角色列表更新成功'];
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ dLog('anime')->error('更新剧集角色失败', [
|
|
|
+ 'anime_id' => $anime_id,
|
|
|
+ 'episode_id' => $episode_id,
|
|
|
+ 'error' => $e->getMessage()
|
|
|
+ ]);
|
|
|
+ Utils::throwError('20003:更新角色列表失败: ' . $e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function changeEpisodeScenes($data) {
|
|
|
+ $anime_id = getProp($data, 'anime_id');
|
|
|
+ $episode_id = getProp($data, 'episode_id');
|
|
|
+ $scenes = getProp($data, 'scenes');
|
|
|
+
|
|
|
+ // 参数验证
|
|
|
+ if (!$anime_id) Utils::throwError('20003:请提供动漫ID');
|
|
|
+ if (!$episode_id) Utils::throwError('20003:请提供剧集ID');
|
|
|
+ if (!is_array($scenes)) Utils::throwError('20003:场景列表必须是数组格式');
|
|
|
+
|
|
|
+ // 验证剧集是否存在
|
|
|
+ $episode = DB::table('mp_anime_episodes')
|
|
|
+ ->where('anime_id', $anime_id)
|
|
|
+ ->where('id', $episode_id)
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ if (!$episode) Utils::throwError('20003:该剧集不存在');
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 更新场景列表
|
|
|
+ $result = DB::table('mp_anime_episodes')
|
|
|
+ ->where('anime_id', $anime_id)
|
|
|
+ ->where('id', $episode_id)
|
|
|
+ ->update([
|
|
|
+ 'scenes' => json_encode($scenes, 256),
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s')
|
|
|
+ ]);
|
|
|
+
|
|
|
+ if ($result === false) {
|
|
|
+ Utils::throwError('20003:更新场景列表失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ return ['success' => true, 'message' => '场景列表更新成功'];
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ dLog('anime')->error('更新剧集场景失败', [
|
|
|
+ 'anime_id' => $anime_id,
|
|
|
+ 'episode_id' => $episode_id,
|
|
|
+ 'error' => $e->getMessage()
|
|
|
+ ]);
|
|
|
+ Utils::throwError('20003:更新场景列表失败: ' . $e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function editSegment($data) {
|
|
|
+ $segment_id = getProp($data, 'segment_id');
|
|
|
+ $segment_content = getProp($data, 'segment_content');
|
|
|
+
|
|
|
+ // 参数验证
|
|
|
+ if (!$segment_id) Utils::throwError('20003:请提供分镜ID');
|
|
|
+ if (!$segment_content) Utils::throwError('20003:请提供分镜内容');
|
|
|
+
|
|
|
+ // 验证分镜是否存在
|
|
|
+ $segment = DB::table('mp_episode_segments')
|
|
|
+ ->where('segment_id', $segment_id)
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ if (!$segment) Utils::throwError('20003:该分镜不存在');
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 准备更新数据
|
|
|
+ $update_data = [
|
|
|
+ 'segment_content' => $segment_content,
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s')
|
|
|
+ ];
|
|
|
+
|
|
|
+ // 使用现有方法分析segment_content,提取各个字段
|
|
|
+ $this->handleSegmentContent($update_data);
|
|
|
+
|
|
|
+ // 更新分镜信息
|
|
|
+ $result = DB::table('mp_episode_segments')
|
|
|
+ ->where('segment_id', $segment_id)
|
|
|
+ ->update($update_data);
|
|
|
+
|
|
|
+ if ($result === false) {
|
|
|
+ Utils::throwError('20003:更新分镜剧本失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ dLog('anime')->error('更新分镜剧本失败', [
|
|
|
+ 'segment_id' => $segment_id,
|
|
|
+ 'error' => $e->getMessage()
|
|
|
+ ]);
|
|
|
+ Utils::throwError('20003:更新分镜剧本失败: ' . $e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function batchSetSegmentPics($data) {
|
|
|
$anime_id = getProp($data, 'anime_id');
|
|
|
$episode_id = getProp($data, 'episode_id');
|
|
|
@@ -861,7 +991,7 @@ class AnimeService
|
|
|
|
|
|
|
|
|
// 更新分镜剧本信息
|
|
|
- $this->handleEpisodeContent($update_data);
|
|
|
+ $this->handleSegmentContent($update_data);
|
|
|
$boolen = DB::table('mp_episode_segments')
|
|
|
->where('segment_id', $segment_id)
|
|
|
->update($update_data);
|
|
|
@@ -996,7 +1126,7 @@ class AnimeService
|
|
|
];
|
|
|
|
|
|
// 更新分镜剧本信息
|
|
|
- $this->handleEpisodeContent($insert_data);
|
|
|
+ $this->handleSegmentContent($insert_data);
|
|
|
|
|
|
// 如果没有上传图片则使用当前描述进行生成
|
|
|
if (!$img_url) {
|
|
|
@@ -1343,7 +1473,7 @@ class AnimeService
|
|
|
}
|
|
|
|
|
|
// 从分镜剧本中提取关键字段
|
|
|
- private function handleEpisodeContent(&$data) {
|
|
|
+ private function handleSegmentContent(&$data) {
|
|
|
$segmentContent = getProp($data, 'segment_content');
|
|
|
// 解析分镜详细信息
|
|
|
$segmentData = [
|