no message
This commit is contained in:
parent
88add639f4
commit
4decb7a7c7
@ -4,17 +4,49 @@ import { z } from "zod";
|
|||||||
import { success } from "@/lib/responseFormat";
|
import { success } from "@/lib/responseFormat";
|
||||||
import { validateFields } from "@/middleware/middleware";
|
import { validateFields } from "@/middleware/middleware";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
import compressing from "compressing";
|
||||||
import { flowDataSchema } from "@/agents/productionAgent/tools";
|
import { flowDataSchema } from "@/agents/productionAgent/tools";
|
||||||
|
import path from "path";
|
||||||
|
import getPath from "@/utils/getPath";
|
||||||
|
|
||||||
export default router.post(
|
export default router.post(
|
||||||
"/",
|
"/",
|
||||||
validateFields({
|
validateFields({
|
||||||
projectId: z.number(),
|
shotId: z.array(
|
||||||
episodesId: z.number(),
|
z.object({
|
||||||
data: flowDataSchema,
|
id: z.string(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
}),
|
}),
|
||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
const { projectId, episodesId } = req.body;
|
const { shotId } = req.body;
|
||||||
return res.status(200).send(success());
|
const id = shotId.map((item: { id: string }) => item.id);
|
||||||
|
const data = await u.db("o_storyboard").whereIn("id", id);
|
||||||
|
const result = await Promise.all(
|
||||||
|
data.map(async (item) => {
|
||||||
|
const url = await u.oss.getFileUrl(item.filePath!);
|
||||||
|
return { ...item, url };
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
const zipStream = new compressing.zip.Stream();
|
||||||
|
result.forEach((item) => {
|
||||||
|
const ext = (item.filePath?.split(".").pop() || "png").toLowerCase();
|
||||||
|
const absPath = path.join(getPath("oss"), item.filePath!);
|
||||||
|
zipStream.addEntry(absPath, { relativePath: `${item.title}.${ext}` });
|
||||||
|
});
|
||||||
|
|
||||||
|
const fileName = `分镜.zip`;
|
||||||
|
const zipFilePath = getPath(["oss", "temp", fileName]);
|
||||||
|
await new Promise<void>((resolve, reject) => {
|
||||||
|
const fs = require("fs");
|
||||||
|
fs.mkdirSync(getPath(["oss", "temp"]), { recursive: true });
|
||||||
|
const writeStream = fs.createWriteStream(zipFilePath);
|
||||||
|
zipStream.pipe(writeStream);
|
||||||
|
writeStream.on("finish", resolve);
|
||||||
|
writeStream.on("error", reject);
|
||||||
|
});
|
||||||
|
|
||||||
|
const downloadUrl = `${process.env.OSSURL || "http://127.0.0.1:10588/"}temp/${fileName}`;
|
||||||
|
res.json(success({ url: downloadUrl }));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@ -13,8 +13,7 @@ export default router.post(
|
|||||||
}),
|
}),
|
||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
const { scriptId, specifyIds } = req.body;
|
const { scriptId, specifyIds } = req.body;
|
||||||
console.log("%c Line:16 🍡", "background:#465975");
|
const data = await u.db("o_video").where("scriptId", scriptId).whereIn("id", specifyIds).andWhere("state", "生成中").select("*");
|
||||||
const data = await u.db("o_video").where("scriptId", scriptId).whereIn("id", specifyIds).select("*");
|
|
||||||
res.status(200).send(success(data));
|
res.status(200).send(success(data));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
4
src/types/database.d.ts
vendored
4
src/types/database.d.ts
vendored
@ -1,4 +1,4 @@
|
|||||||
// @db-hash 3cdc2f747dac456ddd4bbfd877efe991
|
// @db-hash 56071dcf512e84c37ffd555806af7162
|
||||||
//该文件由脚本自动生成,请勿手动修改
|
//该文件由脚本自动生成,请勿手动修改
|
||||||
|
|
||||||
export interface memories {
|
export interface memories {
|
||||||
@ -79,8 +79,6 @@ export interface o_novel {
|
|||||||
'chapterData'?: string | null;
|
'chapterData'?: string | null;
|
||||||
'chapterIndex'?: number | null;
|
'chapterIndex'?: number | null;
|
||||||
'createTime'?: number | null;
|
'createTime'?: number | null;
|
||||||
'event'?: string | null;
|
|
||||||
'eventState'?: number | null;
|
|
||||||
'id'?: number;
|
'id'?: number;
|
||||||
'projectId'?: number | null;
|
'projectId'?: number | null;
|
||||||
'reel'?: string | null;
|
'reel'?: string | null;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user