add filter to course

This commit is contained in:
JakkrapartXD 2026-01-23 10:37:19 +07:00
parent 1cbaed72cb
commit 5e7d265ffb
2 changed files with 16 additions and 5 deletions

View file

@ -1,4 +1,4 @@
import { Get, Body, Post, Route, Tags, SuccessResponse, Response, Delete, Controller, Security, Request, Put, Path } from 'tsoa';
import { Get, Body, Post, Route, Tags, SuccessResponse, Response, Delete, Controller, Security, Request, Put, Path, Query } from 'tsoa';
import { ValidationError } from '../middleware/errorHandler';
import { listCourseResponse } from '../types/courses.types';
import { CoursesService } from '../services/courses.service';
@ -8,11 +8,16 @@ import { CoursesService } from '../services/courses.service';
export class CoursesController {
private coursesService = new CoursesService();
/**
* ( filter category_id )
* Get all courses (can filter by category_id)
* @param category_id - / Category ID (optional)
*/
@Get()
@SuccessResponse('200', 'Courses fetched successfully')
@Response('401', 'Invalid or expired token')
public async listCourses(): Promise<listCourseResponse> {
return await this.coursesService.ListCourses();
public async listCourses(@Query() category_id?: number): Promise<listCourseResponse> {
return await this.coursesService.ListCourses(category_id);
}
@Get('{id}')