done with videos
This commit is contained in:
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user