mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
units,lesson as standalone
This commit is contained in:
@@ -153,11 +153,12 @@ exports.getUnit = async (req, res) => {
|
||||
exports.createUnit = async (req, res) => {
|
||||
const t = await sequelize.transaction();
|
||||
try {
|
||||
const { title, description, course_id, order, createdBy } = req.body;
|
||||
const { title, description, subscription, course_id, order, createdBy } = req.body;
|
||||
if (!title) return R.error(res, "Title is required.", 400);
|
||||
|
||||
const unit = await Unit.create({
|
||||
title,
|
||||
subscription: subscription || null,
|
||||
description: description ?? null,
|
||||
duration_seconds: 0,
|
||||
createdBy: createdBy ?? req.user?.user_id ?? null,
|
||||
@@ -196,10 +197,11 @@ exports.updateUnit = async (req, res) => {
|
||||
const unit = await Unit.findOne({ where: { unit_id: unitId, ...notDeleted } });
|
||||
if (!unit) return R.error(res, "Unit not found.", 404);
|
||||
|
||||
const { title, description, updatedBy } = req.body;
|
||||
const { title, description, subscription, updatedBy } = req.body;
|
||||
|
||||
if (title !== undefined) unit.title = title;
|
||||
if (description !== undefined) unit.description = description;
|
||||
if (title !== undefined) unit.title = title;
|
||||
if (description !== undefined) unit.description = description;
|
||||
if (subscription !== undefined) unit.subscription = subscription || null;
|
||||
unit.updatedBy = updatedBy ?? req.user?.user_id ?? null;
|
||||
|
||||
await unit.save();
|
||||
|
||||
Reference in New Issue
Block a user