done with videos

This commit is contained in:
Ebenezer
2026-04-15 18:05:22 +08:00
parent 123f82e92c
commit 6a7847c249
2 changed files with 227 additions and 12 deletions

View File

@@ -135,6 +135,8 @@ export function registerCourseVideoRoutes(app: Express, getPool: () => mysql.Poo
const moduleName = String(req.body.moduleName || "").trim();
const statusRaw = String(req.body.status || "published").trim().toLowerCase();
const status = statusRaw === "draft" ? "draft" : "published";
const durationRaw = String(req.body.duration || "").trim();
const duration = /^\d{2}:\d{2}(:\d{2})?$/.test(durationRaw) ? durationRaw : "00:00";
if (!title || !courseKey) {
fs.unlink(file.path, () => {});
@@ -147,8 +149,8 @@ export function registerCourseVideoRoutes(app: Express, getPool: () => mysql.Poo
await pool.execute(
`INSERT INTO ${TABLE} (id, title, course_key, course_label_zh, course_label_en, module_name, file_relpath, status, views, duration)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 0, '00:00')`,
[id, title, courseKey, courseLabelZh || courseKey, courseLabelEn || courseKey, moduleName, rel, status],
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 0, ?)`,
[id, title, courseKey, courseLabelZh || courseKey, courseLabelEn || courseKey, moduleName, rel, status, duration],
);
const [rows] = await pool.query<RowDataPacket[]>(`SELECT * FROM ${TABLE} WHERE id = ?`, [id]);