docs: Add JSDoc comments to all instructor course controller methods and update HTTP verbs for instructor management endpoints.
This commit is contained in:
parent
b5ca6b2e0f
commit
946d6ea0ca
1 changed files with 54 additions and 3 deletions
|
|
@ -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 { ValidationError } from '../middleware/errorHandler';
|
||||||
import { CoursesInstructorService } from '../services/CoursesInstructor.service';
|
import { CoursesInstructorService } from '../services/CoursesInstructor.service';
|
||||||
import {
|
import {
|
||||||
|
|
@ -27,6 +27,10 @@ import { config } from '../config';
|
||||||
@Tags('CoursesInstructor')
|
@Tags('CoursesInstructor')
|
||||||
export class CoursesInstructorController {
|
export class CoursesInstructorController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ดึงรายการคอร์สทั้งหมดของผู้สอน
|
||||||
|
* Get all courses where the authenticated user is an instructor
|
||||||
|
*/
|
||||||
@Get('')
|
@Get('')
|
||||||
@Security('jwt', ['instructor'])
|
@Security('jwt', ['instructor'])
|
||||||
@SuccessResponse('200', 'Courses retrieved successfully')
|
@SuccessResponse('200', 'Courses retrieved successfully')
|
||||||
|
|
@ -40,6 +44,11 @@ export class CoursesInstructorController {
|
||||||
return await CoursesInstructorService.listMyCourses(token);
|
return await CoursesInstructorService.listMyCourses(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ดึงข้อมูลคอร์สเฉพาะของผู้สอน (พร้อมบทเรียนและเนื้อหา)
|
||||||
|
* Get detailed course information including chapters, lessons, attachments, and quizzes
|
||||||
|
* @param courseId - รหัสคอร์ส / Course ID
|
||||||
|
*/
|
||||||
@Get('{courseId}')
|
@Get('{courseId}')
|
||||||
@Security('jwt', ['instructor'])
|
@Security('jwt', ['instructor'])
|
||||||
@SuccessResponse('200', 'Course retrieved successfully')
|
@SuccessResponse('200', 'Course retrieved successfully')
|
||||||
|
|
@ -53,6 +62,11 @@ export class CoursesInstructorController {
|
||||||
return await CoursesInstructorService.getmyCourse({ token, course_id: courseId });
|
return await CoursesInstructorService.getmyCourse({ token, course_id: courseId });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* แก้ไขข้อมูลคอร์ส
|
||||||
|
* Update course information (only for course instructors)
|
||||||
|
* @param courseId - รหัสคอร์ส / Course ID
|
||||||
|
*/
|
||||||
@Put('{courseId}')
|
@Put('{courseId}')
|
||||||
@Security('jwt', ['instructor'])
|
@Security('jwt', ['instructor'])
|
||||||
@SuccessResponse('200', 'Course updated successfully')
|
@SuccessResponse('200', 'Course updated successfully')
|
||||||
|
|
@ -66,6 +80,10 @@ export class CoursesInstructorController {
|
||||||
return await CoursesInstructorService.updateCourse(token, courseId, body.data);
|
return await CoursesInstructorService.updateCourse(token, courseId, body.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* สร้างคอร์สใหม่
|
||||||
|
* Create a new course (status will be DRAFT by default)
|
||||||
|
*/
|
||||||
@Post('')
|
@Post('')
|
||||||
@Security('jwt', ['instructor'])
|
@Security('jwt', ['instructor'])
|
||||||
@SuccessResponse('201', 'Course created successfully')
|
@SuccessResponse('201', 'Course created successfully')
|
||||||
|
|
@ -80,6 +98,11 @@ export class CoursesInstructorController {
|
||||||
return course;
|
return course;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ลบคอร์ส (เฉพาะผู้สอนหลักเท่านั้น)
|
||||||
|
* Delete a course (only primary instructor can delete)
|
||||||
|
* @param courseId - รหัสคอร์ส / Course ID
|
||||||
|
*/
|
||||||
@Delete('{courseId}')
|
@Delete('{courseId}')
|
||||||
@Security('jwt', ['instructor'])
|
@Security('jwt', ['instructor'])
|
||||||
@SuccessResponse('200', 'Course deleted successfully')
|
@SuccessResponse('200', 'Course deleted successfully')
|
||||||
|
|
@ -93,6 +116,11 @@ export class CoursesInstructorController {
|
||||||
return await CoursesInstructorService.deleteCourse(token, courseId);
|
return await CoursesInstructorService.deleteCourse(token, courseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ส่งคอร์สเพื่อขออนุมัติจากแอดมิน
|
||||||
|
* Submit course for admin review and approval
|
||||||
|
* @param courseId - รหัสคอร์ส / Course ID
|
||||||
|
*/
|
||||||
@Post('send-review/{courseId}')
|
@Post('send-review/{courseId}')
|
||||||
@Security('jwt', ['instructor'])
|
@Security('jwt', ['instructor'])
|
||||||
@SuccessResponse('200', 'Course submitted successfully')
|
@SuccessResponse('200', 'Course submitted successfully')
|
||||||
|
|
@ -106,6 +134,11 @@ export class CoursesInstructorController {
|
||||||
return await CoursesInstructorService.sendCourseForReview({ token, course_id: courseId });
|
return await CoursesInstructorService.sendCourseForReview({ token, course_id: courseId });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ดึงรายชื่อผู้สอนทั้งหมดในคอร์ส
|
||||||
|
* Get list of all instructors in a specific course
|
||||||
|
* @param courseId - รหัสคอร์ส / Course ID
|
||||||
|
*/
|
||||||
@Get('listinstructor/{courseId}')
|
@Get('listinstructor/{courseId}')
|
||||||
@Security('jwt', ['instructor'])
|
@Security('jwt', ['instructor'])
|
||||||
@SuccessResponse('200', 'Instructors retrieved successfully')
|
@SuccessResponse('200', 'Instructors retrieved successfully')
|
||||||
|
|
@ -119,6 +152,12 @@ export class CoursesInstructorController {
|
||||||
return await CoursesInstructorService.listInstructorsOfCourse({ token, course_id: courseId });
|
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}')
|
@Post('add-instructor/{courseId}/{userId}')
|
||||||
@Security('jwt', ['instructor'])
|
@Security('jwt', ['instructor'])
|
||||||
@SuccessResponse('200', 'Instructor added successfully')
|
@SuccessResponse('200', 'Instructor added successfully')
|
||||||
|
|
@ -132,7 +171,13 @@ export class CoursesInstructorController {
|
||||||
return await CoursesInstructorService.addInstructorToCourse({ token, course_id: courseId, user_id: userId });
|
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'])
|
@Security('jwt', ['instructor'])
|
||||||
@SuccessResponse('200', 'Instructor removed successfully')
|
@SuccessResponse('200', 'Instructor removed successfully')
|
||||||
@Response('401', 'Invalid or expired token')
|
@Response('401', 'Invalid or expired token')
|
||||||
|
|
@ -145,7 +190,13 @@ export class CoursesInstructorController {
|
||||||
return await CoursesInstructorService.removeInstructorFromCourse({ token, course_id: courseId, user_id: userId });
|
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'])
|
@Security('jwt', ['instructor'])
|
||||||
@SuccessResponse('200', 'Primary instructor set successfully')
|
@SuccessResponse('200', 'Primary instructor set successfully')
|
||||||
@Response('401', 'Invalid or expired token')
|
@Response('401', 'Invalid or expired token')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue