docs: Add JSDoc comments to all instructor course controller methods and update HTTP verbs for instructor management endpoints.

This commit is contained in:
JakkrapartXD 2026-01-19 10:09:10 +07:00
parent b5ca6b2e0f
commit 946d6ea0ca

View file

@ -1,4 +1,4 @@
import { Get, Body, Post, Route, Tags, SuccessResponse, Response, Security, Put, Path, Delete, Request } from 'tsoa';
import { Get, Body, Post, Route, Tags, SuccessResponse, Response, Security, Put, Path, Delete, Request, Example } from 'tsoa';
import { ValidationError } from '../middleware/errorHandler';
import { CoursesInstructorService } from '../services/CoursesInstructor.service';
import {
@ -27,6 +27,10 @@ import { config } from '../config';
@Tags('CoursesInstructor')
export class CoursesInstructorController {
/**
*
* Get all courses where the authenticated user is an instructor
*/
@Get('')
@Security('jwt', ['instructor'])
@SuccessResponse('200', 'Courses retrieved successfully')
@ -40,6 +44,11 @@ export class CoursesInstructorController {
return await CoursesInstructorService.listMyCourses(token);
}
/**
* ()
* Get detailed course information including chapters, lessons, attachments, and quizzes
* @param courseId - / Course ID
*/
@Get('{courseId}')
@Security('jwt', ['instructor'])
@SuccessResponse('200', 'Course retrieved successfully')
@ -53,6 +62,11 @@ export class CoursesInstructorController {
return await CoursesInstructorService.getmyCourse({ token, course_id: courseId });
}
/**
*
* Update course information (only for course instructors)
* @param courseId - / Course ID
*/
@Put('{courseId}')
@Security('jwt', ['instructor'])
@SuccessResponse('200', 'Course updated successfully')
@ -66,6 +80,10 @@ export class CoursesInstructorController {
return await CoursesInstructorService.updateCourse(token, courseId, body.data);
}
/**
*
* Create a new course (status will be DRAFT by default)
*/
@Post('')
@Security('jwt', ['instructor'])
@SuccessResponse('201', 'Course created successfully')
@ -80,6 +98,11 @@ export class CoursesInstructorController {
return course;
}
/**
* ()
* Delete a course (only primary instructor can delete)
* @param courseId - / Course ID
*/
@Delete('{courseId}')
@Security('jwt', ['instructor'])
@SuccessResponse('200', 'Course deleted successfully')
@ -93,6 +116,11 @@ export class CoursesInstructorController {
return await CoursesInstructorService.deleteCourse(token, courseId);
}
/**
*
* Submit course for admin review and approval
* @param courseId - / Course ID
*/
@Post('send-review/{courseId}')
@Security('jwt', ['instructor'])
@SuccessResponse('200', 'Course submitted successfully')
@ -106,6 +134,11 @@ export class CoursesInstructorController {
return await CoursesInstructorService.sendCourseForReview({ token, course_id: courseId });
}
/**
*
* Get list of all instructors in a specific course
* @param courseId - / Course ID
*/
@Get('listinstructor/{courseId}')
@Security('jwt', ['instructor'])
@SuccessResponse('200', 'Instructors retrieved successfully')
@ -119,6 +152,12 @@ export class CoursesInstructorController {
return await CoursesInstructorService.listInstructorsOfCourse({ token, course_id: courseId });
}
/**
*
* Add a new instructor to the course
* @param courseId - / Course ID
* @param userId - / User ID to add as instructor
*/
@Post('add-instructor/{courseId}/{userId}')
@Security('jwt', ['instructor'])
@SuccessResponse('200', 'Instructor added successfully')
@ -132,7 +171,13 @@ export class CoursesInstructorController {
return await CoursesInstructorService.addInstructorToCourse({ token, course_id: courseId, user_id: userId });
}
@Post('remove-instructor/{courseId}/{userId}')
/**
*
* Remove an instructor from the course
* @param courseId - / Course ID
* @param userId - / User ID to remove from instructors
*/
@Delete('remove-instructor/{courseId}/{userId}')
@Security('jwt', ['instructor'])
@SuccessResponse('200', 'Instructor removed successfully')
@Response('401', 'Invalid or expired token')
@ -145,7 +190,13 @@ export class CoursesInstructorController {
return await CoursesInstructorService.removeInstructorFromCourse({ token, course_id: courseId, user_id: userId });
}
@Post('set-primary-instructor/{courseId}/{userId}')
/**
*
* Set a user as the primary instructor of the course
* @param courseId - / Course ID
* @param userId - / User ID to set as primary instructor
*/
@Put('set-primary-instructor/{courseId}/{userId}')
@Security('jwt', ['instructor'])
@SuccessResponse('200', 'Primary instructor set successfully')
@Response('401', 'Invalid or expired token')