查询素材数据插入片尾视频
This commit is contained in:
parent
553d0a360e
commit
06ae21eae1
@ -526,6 +526,7 @@ description: 专注于从剧本内容中提取所使用的资产(角色、场
|
|||||||
table.text("state");
|
table.text("state");
|
||||||
table.integer("scriptId");
|
table.integer("scriptId");
|
||||||
table.integer("storyboardId");
|
table.integer("storyboardId");
|
||||||
|
table.integer("projectId");
|
||||||
table.primary(["id"]);
|
table.primary(["id"]);
|
||||||
table.unique(["id"]);
|
table.unique(["id"]);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,24 +1,44 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
import u from "@/utils";
|
import u from "@/utils";
|
||||||
|
import { z } from "zod";
|
||||||
import { success } from "@/lib/responseFormat";
|
import { success } from "@/lib/responseFormat";
|
||||||
|
import { validateFields } from "@/middleware/middleware";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
// 获取生成图片
|
// 获取生成图片
|
||||||
export default router.post("/", async (req, res) => {
|
export default router.post(
|
||||||
const list = await u.db("o_assets").leftJoin("o_image", "o_assets.id", "=", "o_image.assetsId").where("o_assets.type", "clip").select("*");
|
"/",
|
||||||
|
validateFields({
|
||||||
|
projectId: z.number(),
|
||||||
|
}),
|
||||||
|
async (req, res) => {
|
||||||
|
const { projectId } = req.body;
|
||||||
|
const list = await u
|
||||||
|
.db("o_assets")
|
||||||
|
.leftJoin("o_image", "o_assets.id", "=", "o_image.assetsId")
|
||||||
|
.where("o_assets.type", "clip")
|
||||||
|
.andWhere("projectId", projectId)
|
||||||
|
.select("*");
|
||||||
const data = await Promise.all(
|
const data = await Promise.all(
|
||||||
list.map(async (item) => ({
|
list.map(async (item) => ({
|
||||||
...item,
|
...item,
|
||||||
filePath: item.filePath ? await u.oss.getFileUrl(item.filePath) : "",
|
filePath: item.filePath ? await u.oss.getFileUrl(item.filePath) : "",
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
//拿到本地片尾视频并插入到data中
|
||||||
|
const ending = await u.oss.getFileUrl("/ending/1d7a2dfdd0c057823797fdf97677a7a0.mp4");
|
||||||
|
data.push({
|
||||||
|
id: 0,
|
||||||
|
name: "片尾",
|
||||||
|
filePath: ending,
|
||||||
|
type: "clip",
|
||||||
|
});
|
||||||
// 查询o_videoConfig表,拿到已选中的videoId
|
// 查询o_videoConfig表,拿到已选中的videoId
|
||||||
const configRows = await u.db("o_videoConfig").select("videoId");
|
const configRows = await u.db("o_videoConfig").select("videoId");
|
||||||
const selectedIds = new Set(configRows.map((row) => row.videoId));
|
const selectedIds = new Set(configRows.map((row) => row.videoId));
|
||||||
|
|
||||||
// 查询o_video表
|
// 查询o_video表
|
||||||
const videoRows = await u.db("o_video").where("state", "生成成功").select("*");
|
const videoRows = await u.db("o_video").where("state", "生成成功").andWhere("projectId", projectId).select("*");
|
||||||
|
|
||||||
// 处理并返回结果
|
// 处理并返回结果
|
||||||
const video = await Promise.all(
|
const video = await Promise.all(
|
||||||
videoRows.map(async (row) => ({
|
videoRows.map(async (row) => ({
|
||||||
@ -28,5 +48,7 @@ export default router.post("/", async (req, res) => {
|
|||||||
storyboard: row.storyboardId,
|
storyboard: row.storyboardId,
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
res.status(200).send(success({ data, video }));
|
res.status(200).send(success({ data, video }));
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|||||||
@ -39,6 +39,7 @@ export default router.post(
|
|||||||
state: "生成中",
|
state: "生成中",
|
||||||
scriptId,
|
scriptId,
|
||||||
storyboardId,
|
storyboardId,
|
||||||
|
projectId,
|
||||||
};
|
};
|
||||||
const [videoId] = await u.db("o_video").insert(videoData);
|
const [videoId] = await u.db("o_video").insert(videoData);
|
||||||
//查询分镜是否已有配置
|
//查询分镜是否已有配置
|
||||||
|
|||||||
16
src/types/database.d.ts
vendored
16
src/types/database.d.ts
vendored
@ -1,13 +1,6 @@
|
|||||||
// @db-hash 24748d4ef971381a79c720c846f83847
|
// @db-hash 6be0a80e9c8f541987a4c1e907736237
|
||||||
//该文件由脚本自动生成,请勿手动修改
|
//该文件由脚本自动生成,请勿手动修改
|
||||||
|
|
||||||
export interface _o_script_old_20260327 {
|
|
||||||
'content'?: string | null;
|
|
||||||
'createTime'?: number | null;
|
|
||||||
'id'?: number;
|
|
||||||
'name'?: string | null;
|
|
||||||
'projectId'?: number | null;
|
|
||||||
}
|
|
||||||
export interface memories {
|
export interface memories {
|
||||||
'content': string;
|
'content': string;
|
||||||
'createTime': number;
|
'createTime': number;
|
||||||
@ -28,7 +21,7 @@ export interface o_agentDeploy {
|
|||||||
'model'?: string | null;
|
'model'?: string | null;
|
||||||
'modelName'?: string | null;
|
'modelName'?: string | null;
|
||||||
'name'?: string | null;
|
'name'?: string | null;
|
||||||
'vendorId'?: number | null;
|
'vendorId'?: string | null;
|
||||||
}
|
}
|
||||||
export interface o_agentWorkData {
|
export interface o_agentWorkData {
|
||||||
'createTime'?: number | null;
|
'createTime'?: number | null;
|
||||||
@ -54,6 +47,7 @@ export interface o_assets {
|
|||||||
'name'?: string | null;
|
'name'?: string | null;
|
||||||
'projectId'?: number | null;
|
'projectId'?: number | null;
|
||||||
'prompt'?: string | null;
|
'prompt'?: string | null;
|
||||||
|
'promptState'?: string | null;
|
||||||
'remark'?: string | null;
|
'remark'?: string | null;
|
||||||
'scriptId'?: number | null;
|
'scriptId'?: number | null;
|
||||||
'startTime'?: number | null;
|
'startTime'?: number | null;
|
||||||
@ -173,7 +167,7 @@ export interface o_storyboard {
|
|||||||
'filePath'?: string | null;
|
'filePath'?: string | null;
|
||||||
'frameMode'?: string | null;
|
'frameMode'?: string | null;
|
||||||
'id'?: number;
|
'id'?: number;
|
||||||
'index'?: string | null;
|
'index'?: number | null;
|
||||||
'lines'?: string | null;
|
'lines'?: string | null;
|
||||||
'mode'?: string | null;
|
'mode'?: string | null;
|
||||||
'model'?: string | null;
|
'model'?: string | null;
|
||||||
@ -218,6 +212,7 @@ export interface o_video {
|
|||||||
'errorReason'?: string | null;
|
'errorReason'?: string | null;
|
||||||
'filePath'?: string | null;
|
'filePath'?: string | null;
|
||||||
'id'?: number;
|
'id'?: number;
|
||||||
|
'projectId'?: number | null;
|
||||||
'scriptId'?: number | null;
|
'scriptId'?: number | null;
|
||||||
'state'?: string | null;
|
'state'?: string | null;
|
||||||
'storyboardId'?: number | null;
|
'storyboardId'?: number | null;
|
||||||
@ -239,7 +234,6 @@ export interface o_videoConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface DB {
|
export interface DB {
|
||||||
"_o_script_old_20260327": _o_script_old_20260327;
|
|
||||||
"memories": memories;
|
"memories": memories;
|
||||||
"o_agentDeploy": o_agentDeploy;
|
"o_agentDeploy": o_agentDeploy;
|
||||||
"o_agentWorkData": o_agentWorkData;
|
"o_agentWorkData": o_agentWorkData;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user