feat: update instructor search to exclude self and existing course instructors, add email_verified_at to user responses
Update searchInstructors endpoint to accept courseId parameter and filter out the requesting instructor and instructors already assigned to the course. Add email_verified_at field to UserResponse type and include it in auth and user service responses.
This commit is contained in:
parent
80d7372dfa
commit
48e8f56e22
6 changed files with 29 additions and 8 deletions
|
|
@ -48,18 +48,23 @@ export class CoursesInstructorController {
|
|||
}
|
||||
|
||||
/**
|
||||
* ค้นหาผู้สอนทั้งหมดในระบบ
|
||||
* Search all instructors in database
|
||||
* ค้นหาผู้สอนทั้งหมดในระบบ (ไม่รวมตัวเองและคนที่อยู่ในคอร์สแล้ว)
|
||||
* Search all instructors in database (excluding self and existing course instructors)
|
||||
* @param courseId - รหัสคอร์ส / Course ID
|
||||
* @param query - คำค้นหา (email หรือ username) / Search query (email or username)
|
||||
*/
|
||||
@Get('search-instructors')
|
||||
@Get('{courseId}/search-instructors')
|
||||
@Security('jwt', ['instructor'])
|
||||
@SuccessResponse('200', 'Instructors found')
|
||||
@Response('401', 'Invalid or expired token')
|
||||
public async searchInstructors(@Request() request: any, @Query() query: string): Promise<SearchInstructorResponse> {
|
||||
public async searchInstructors(
|
||||
@Request() request: any,
|
||||
@Path() courseId: number,
|
||||
@Query() query: string
|
||||
): Promise<SearchInstructorResponse> {
|
||||
const token = request.headers.authorization?.replace('Bearer ', '');
|
||||
if (!token) throw new ValidationError('No token provided');
|
||||
return await CoursesInstructorService.searchInstructors({ token, query });
|
||||
return await CoursesInstructorService.searchInstructors({ token, query, course_id: courseId });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue