feat: Implement lesson creation with file uploads (video, attachments) and quiz data, integrating MinIO for storage.
This commit is contained in:
parent
4851182f4a
commit
04e2da43c4
6 changed files with 715 additions and 4 deletions
|
|
@ -2,7 +2,7 @@ import { prisma } from '../config/database';
|
|||
import { Prisma } from '@prisma/client';
|
||||
import { config } from '../config';
|
||||
import { logger } from '../config/logger';
|
||||
import { UnauthorizedError, ValidationError, ForbiddenError } from '../middleware/errorHandler';
|
||||
import { UnauthorizedError, ValidationError, ForbiddenError, NotFoundError } from '../middleware/errorHandler';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import {
|
||||
CreateCourseInput,
|
||||
|
|
@ -190,6 +190,14 @@ export class CoursesInstructorService {
|
|||
submitted_by: decoded.id,
|
||||
}
|
||||
});
|
||||
await prisma.course.update({
|
||||
where: {
|
||||
id: sendCourseForReview.course_id
|
||||
},
|
||||
data: {
|
||||
status: 'PENDING'
|
||||
}
|
||||
});
|
||||
return {
|
||||
code: 200,
|
||||
message: 'Course sent for review successfully',
|
||||
|
|
@ -288,7 +296,7 @@ export class CoursesInstructorService {
|
|||
}
|
||||
}
|
||||
|
||||
private static async validateCourseInstructor(token: string, courseId: number): Promise<{ user_id: number; is_primary: boolean }> {
|
||||
static async validateCourseInstructor(token: string, courseId: number): Promise<{ user_id: number; is_primary: boolean }> {
|
||||
const decoded = jwt.verify(token, config.jwt.secret) as { id: number; type: string };
|
||||
const courseInstructor = await prisma.courseInstructor.findFirst({
|
||||
where: {
|
||||
|
|
@ -301,4 +309,14 @@ export class CoursesInstructorService {
|
|||
throw new ForbiddenError('You are not an instructor of this course');
|
||||
} else return { user_id: courseInstructor.user_id, is_primary: courseInstructor.is_primary };
|
||||
}
|
||||
|
||||
static async validateCourseStatus(courseId: number): Promise<void> {
|
||||
const course = await prisma.course.findUnique({ where: { id: courseId } });
|
||||
if (!course) {
|
||||
throw new NotFoundError('Course not found');
|
||||
}
|
||||
if (course.status === 'APPROVED') {
|
||||
throw new ForbiddenError('Course is already approved Cannot Edit');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue