add filter APPROVED to couse to see olny APPROVED course
This commit is contained in:
parent
cb1e804490
commit
6acb536aef
3 changed files with 33 additions and 18 deletions
|
|
@ -8,7 +8,9 @@ import { UnauthorizedError, ValidationError, ForbiddenError } from '../middlewar
|
|||
export class CoursesService {
|
||||
async ListCourses(category_id?: number): Promise<listCourseResponse> {
|
||||
try {
|
||||
const where: Prisma.CourseWhereInput = {};
|
||||
const where: Prisma.CourseWhereInput = {
|
||||
status: 'APPROVED',
|
||||
};
|
||||
|
||||
if (category_id) {
|
||||
where.category_id = category_id;
|
||||
|
|
@ -30,7 +32,12 @@ export class CoursesService {
|
|||
|
||||
async GetCourseById(id: number): Promise<getCourseResponse> {
|
||||
try {
|
||||
const course = await prisma.course.findUnique({ where: { id } });
|
||||
const course = await prisma.course.findFirst({
|
||||
where: {
|
||||
id,
|
||||
status: 'APPROVED' // Only show approved courses to students
|
||||
}
|
||||
});
|
||||
return {
|
||||
code: 200,
|
||||
message: 'Course fetched successfully',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue