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

[FEAT] 데이트 코스 필터링 조회(메인) API 구현 - #79 #83

Merged
merged 6 commits into from
Jul 12, 2024

Conversation

gardening-y
Copy link
Contributor

@gardening-y gardening-y commented Jul 12, 2024

🔥Pull requests

⛳️ 작업한 브랜치

👷 작업한 내용

데이트 코스 필터링 조회(메인) API를 구현했습니다.

    @GetMapping("/sort")
    public ResponseEntity<CourseGetAllRes> getSortedCourses(final @RequestParam String sortBy) {
        CourseGetAllRes courseSortedRes = courseService.getSortedCourses(sortBy);
        return ResponseEntity.ok(courseSortedRes);
    }

메인에서 최신순과 인기순으로 불러오는 API를 공통적으로 사용하기 위해 RequestParam으로 sortBy를 받아 조회 방법을 구별합니다.

    public CourseGetAllRes getSortedCourses(String sortBy) {
        List<Course> courses;
        if (sortBy.equalsIgnoreCase("POPULAR")) {
            courses = getCoursesSortedByLikes();
        } else if (sortBy.equalsIgnoreCase("LATEST")) {
            courses = getCoursesSortedByLatest();
        } else {
            throw new EntityNotFoundException(FailureCode.SORT_TYPE_NOT_FOUND);
        }
        List<CourseDtoGetRes> courseDtoGetResList = convertToDtoList(courses, Function.identity());
        return CourseGetAllRes.of(courseDtoGetResList);
    }

실제 받아온 값으로 CourseService 로직에서 값을 비교해 조회합니다.
각각 조회의 반환 갯수가 다르기 때문에 다른 메서드를 통해 구해줬으며, dto로 변환하는 것은 기존의 메서드를 재사용했습니다.

최신순일 경우 가장 최근에 작성한 코스가 3개 반환되며, 인기순일 경우 좋아요의 개수가 가장 많은 순으로 작성한 코스 5개가 반환됩니다.

🚨 참고 사항

📟 관련 이슈

Copy link
Member

@rlarlgnszx rlarlgnszx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다!!
LGTM~~~~~~~~~~~ 💯 ❤️

Copy link
Member

@sjk4618 sjk4618 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMMMMMM~

@gardening-y gardening-y merged commit 5656279 into develop Jul 12, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] 데이트 코스 필터링 조회(메인) API 구현
3 participants