Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/search course #121

Merged
merged 13 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit Hold shift + click to select a range
605afcf
feat:: ๊ฒ€์ƒ‰ ๊ธฐ๋ณธ์ ์ธ ์ „๋žต ์ƒ์„ฑ
Devheun Jan 15, 2025
907daf3
feat:: ๊ฐ•์˜ ์นดํ…Œ๊ณ ๋ฆฌ enum ์ƒ์„ฑ ๋ฐ ์ปค์Šคํ…€ ์—๋Ÿฌ ์ƒ์„ฑ
Devheun Jan 21, 2025
a564651
feat:: ๊ฐ•์˜๊ฒ€์ƒ‰ ๋ฆฌํŒฉํ† ๋ง์— ๋”ฐ๋ฅธ ์ƒˆ๋กœ์šด DTO ์ƒ์„ฑ
Devheun Jan 21, 2025
76881fc
refactor:: Course ์ปจํŠธ๋กค๋Ÿฌ ์ˆ˜์ • ๋ฐ ๋ฐ์ฝ”๋ ˆ์ดํ„ฐ ์ˆ˜์ •
Devheun Jan 27, 2025
6ed09fa
refactor:: ๊ฐ•์˜๊ฒ€์ƒ‰ ์ „๋žต ์ƒ์„ฑ
Devheun Jan 27, 2025
47aecd1
refactor:: ๊ฐ•์˜๊ฒ€์ƒ‰ service ๋กœ์ง ์ˆ˜์ •
Devheun Jan 27, 2025
1dbcec1
refactor:: ๋ชจ๋“ˆ ๋“ฑ๋ก
Devheun Jan 27, 2025
8f85ce5
refactor:: ํ•„์š”์—†๋Š” CourseCategory enum๊ฐ’ ์ œ๊ฑฐ
Devheun Jan 27, 2025
4679553
refactor:: enum ์ˆ˜์ •์— ๋”ฐ๋ฅธ dto ์ˆ˜์ •
Devheun Jan 27, 2025
4203629
refactor:: ์ˆœํ™˜ ์˜์กด์„ฑ ํ•ด๊ฒฐ ๋ฐ ๊ฒ€์ƒ‰ ๋กœ์ง ์ˆ˜์ •
Devheun Jan 27, 2025
423fad8
refactor:: ์„ฑํ˜„'s review ๋ฐ˜์˜
Devheun Feb 2, 2025
7d0f2ca
fix:: swagger ๋ช…์„ธ ์ˆ˜์ •
Devheun Feb 2, 2025
605b6db
fix: ์˜คํƒ€ ์ˆ˜์ • ๋ฐ swagger ๋ช…์„ธ ์ˆ˜์ •
Devheun Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 6 additions & 142 deletions src/course/course.controller.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { Controller, Get, Param, Query, UseGuards } from '@nestjs/common';
import { Controller, Get, Query, UseGuards } from '@nestjs/common';
import { CourseService } from './course.service';
import { ApiTags } from '@nestjs/swagger';
import { CommonCourseResponseDto } from './dto/common-course-response.dto';
import { JwtAuthGuard } from 'src/auth/guards/jwt-auth.guard';
import { SearchCourseCodeDto } from './dto/search-course-code.dto';
import { SearchCourseNameDto } from './dto/search-course-name.dto';
import { SearchProfessorNameDto } from './dto/search-professor-name.dto';
import { PaginatedCoursesDto } from './dto/paginated-courses.dto';
import { CourseDocs } from 'src/decorators/docs/course.decorator';
import { GetGeneralCourseDto } from './dto/get-general-course.dto';
import { GetMajorCourseDto } from './dto/get-major-course.dto';
import { GetAcademicFoundationCourseDto } from './dto/get-academic-foundation-course.dto';
import { SearchCoursesWithKeywordDto } from './dto/search-courses-with-keyword.dto';
import { SearchCourseNewDto } from './dto/search-course-new.dto';

@ApiTags('course')
@CourseDocs
Expand All @@ -20,139 +13,10 @@ export class CourseController {
constructor(private courseService: CourseService) {}

@UseGuards(JwtAuthGuard)
@Get('search-all')
async searchAllCourses(
@Query() searchCoursesWithKeywordDto: SearchCoursesWithKeywordDto,
@Get()
async searchCourses(
@Query() searchCourseNewDto: SearchCourseNewDto,
): Promise<PaginatedCoursesDto> {
return await this.courseService.searchAllCourses(
searchCoursesWithKeywordDto,
);
}

@UseGuards(JwtAuthGuard)
@Get('search-major')
async searchMajorCourses(
@Query('major') major: string,
@Query() searchCoursesWithKeywordDto: SearchCoursesWithKeywordDto,
): Promise<PaginatedCoursesDto> {
return await this.courseService.searchMajorCourses(
major,
searchCoursesWithKeywordDto,
);
}

@UseGuards(JwtAuthGuard)
@Get('search-general')
async searchGeneralCourses(
@Query() searchCoursesWithKeywordDto: SearchCoursesWithKeywordDto,
): Promise<PaginatedCoursesDto> {
return await this.courseService.searchGeneralCourses(
searchCoursesWithKeywordDto,
);
}

@UseGuards(JwtAuthGuard)
@Get('search-academic-foundation')
async searchAcademicFoundationCourses(
@Query('college') college: string,
@Query() searchCoursesWithKeywordDto: SearchCoursesWithKeywordDto,
): Promise<PaginatedCoursesDto> {
return await this.courseService.searchAcademicFoundationCourses(
college,
searchCoursesWithKeywordDto,
);
}

// ํ•™์ˆ˜๋ฒˆํ˜ธ ๊ฒ€์ƒ‰
@UseGuards(JwtAuthGuard)
@Get('search-course-code')
async searchCourseCode(
@Query() searchCourseCodeDto: SearchCourseCodeDto,
): Promise<PaginatedCoursesDto> {
return await this.courseService.searchCourseCode(searchCourseCodeDto);
}

// ์ „๊ณต -- ๊ณผ๋ชฉ๋ช… ๊ฒ€์ƒ‰
@UseGuards(JwtAuthGuard)
@Get('search-major-course-name')
async searchMajorCourseName(
@Query('major') major: string,
@Query() searchCourseNameDto: SearchCourseNameDto,
): Promise<PaginatedCoursesDto> {
return await this.courseService.searchMajorCourseName(
major,
searchCourseNameDto,
);
}

// ๊ต์–‘ - ๊ณผ๋ชฉ๋ช… ๊ฒ€์ƒ‰
@UseGuards(JwtAuthGuard)
@Get('search-general-course-name')
async searchGeneralCourseName(
@Query() searchCourseNameDto: SearchCourseNameDto,
): Promise<PaginatedCoursesDto> {
return await this.courseService.searchGeneralCourseName(
searchCourseNameDto,
);
}

// ์ „๊ณต - ๊ต์ˆ˜๋‹˜ ์„ฑํ•จ ๊ฒ€์ƒ‰
@UseGuards(JwtAuthGuard)
@Get('search-major-professor-name')
async searchMajorProfessorName(
@Query('major') major: string,
@Query() searchProfessorNameDto: SearchProfessorNameDto,
): Promise<PaginatedCoursesDto> {
return await this.courseService.searchMajorProfessorName(
major,
searchProfessorNameDto,
);
}

// ๊ต์–‘ - ๊ต์ˆ˜๋‹˜ ์„ฑํ•จ ๊ฒ€์ƒ‰
@UseGuards(JwtAuthGuard)
@Get('search-general-professor-name')
async searchGeneralProfessorName(
@Query() searchProfessorNameDto: SearchProfessorNameDto,
): Promise<PaginatedCoursesDto> {
return await this.courseService.searchGeneralProfessorName(
searchProfessorNameDto,
);
}

// ๊ต์–‘ ๋ฆฌ์ŠคํŠธ
@UseGuards(JwtAuthGuard)
@Get('general')
async getGeneralCourses(
@Query() getGeneralCourseDto: GetGeneralCourseDto,
): Promise<PaginatedCoursesDto> {
return await this.courseService.getGeneralCourses(getGeneralCourseDto);
}

// ์ „๊ณต ๋ฆฌ์ŠคํŠธ (ํ•™๋ถ€๋ณ„)
@UseGuards(JwtAuthGuard)
@Get('major')
async getMajorCourses(
@Query() getMajorCourseDto: GetMajorCourseDto,
): Promise<PaginatedCoursesDto> {
return await this.courseService.getMajorCourses(getMajorCourseDto);
}

// ํ•™๋ฌธ์˜ ๊ธฐ์ดˆ ๋ฆฌ์ŠคํŠธ
@UseGuards(JwtAuthGuard)
@Get('academic-foundation')
async getAcademicFoundationCourses(
@Query() getAcademicFoundationCourseDto: GetAcademicFoundationCourseDto,
): Promise<PaginatedCoursesDto> {
return await this.courseService.getAcademicFoundationCourses(
getAcademicFoundationCourseDto,
);
}

@Get('/:courseId')
async getCourse(
@Param('courseId') courseId: number,
): Promise<CommonCourseResponseDto> {
return await this.courseService.getCourse(courseId);
return await this.courseService.searchCourses(searchCourseNewDto);
}
}
34 changes: 33 additions & 1 deletion src/course/course.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,43 @@ import { CourseDetailRepository } from './course-detail.repository';
import { TypeOrmModule } from '@nestjs/typeorm';
import { CourseEntity } from 'src/entities/course.entity';
import { CourseDetailEntity } from 'src/entities/course-detail.entity';
import { AcademicFoundationSearchStrategy } from './strategy/academic-foundation-search-strategy';
import { GeneralSearchStrategy } from './strategy/general-search-strategy';
import { MajorSearchStrategy } from './strategy/major-search-strategy';
import { AllCoursesSearchStrategy } from './strategy/all-courses-search-strategy';

@Module({
imports: [TypeOrmModule.forFeature([CourseEntity, CourseDetailEntity])],
controllers: [CourseController],
providers: [CourseService, CourseRepository, CourseDetailRepository],
providers: [
CourseService,
CourseRepository,
CourseDetailRepository,
AcademicFoundationSearchStrategy,
GeneralSearchStrategy,
MajorSearchStrategy,
AllCoursesSearchStrategy,
{
provide: 'CourseSearchStrategy',
useFactory: (
academicFoundationSearchStrategy: AcademicFoundationSearchStrategy,
generalSearchStrategy: GeneralSearchStrategy,
majorSearchStrategy: MajorSearchStrategy,
allCoursesSearchStrategy: AllCoursesSearchStrategy,
) => [
academicFoundationSearchStrategy,
generalSearchStrategy,
majorSearchStrategy,
allCoursesSearchStrategy,
],
inject: [
AcademicFoundationSearchStrategy,
GeneralSearchStrategy,
MajorSearchStrategy,
AllCoursesSearchStrategy,
],
},
],
exports: [CourseService],
})
export class CourseModule {}
Loading