Skip to content

Commit 4da61f3

Browse files
authored
feat: 유저 프로필 조회를 위한 코스 조회 쿼리를 jpql로 직접 작성한다. (#129)
1 parent a841830 commit 4da61f3

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/main/java/org/runnect/server/course/repository/CourseRepository.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public interface CourseRepository extends JpaRepository<Course, Long> {
2525
@Query("select c from Course c join fetch c.runnectUser where c.runnectUser.id = :userId and c.isPrivate = true and c.deletedAt = null order by c.createdAt desc")
2626
List<Course> findCourseByUserIdOnlyPrivate(@Param("userId") Long userId);
2727

28-
List<Course> findCoursesByRunnectUserAndIsPrivateIsTrue(RunnectUser runnectUser);
28+
@Query("select c from Course c where c.runnectUser = :runnectUser and c.isPrivate = false and c.deletedAt = null order by c.createdAt desc")
29+
List<Course> findCoursesForUserProfile(@Param("runnectUser") RunnectUser runnectUser);
2930

3031
List<Course> findCoursesByRunnectUserAndIsPrivateIsFalseAndDeletedAtIsNull(RunnectUser runnectUser);
3132

src/main/java/org/runnect/server/user/service/UserService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public UserProfileResponseDto getUserProfile(Long profileUserId, Long requestUse
7272
.orElseThrow(() -> new NotFoundUserException(ErrorStatus.NOT_FOUND_USER_EXCEPTION,
7373
ErrorStatus.NOT_FOUND_USER_EXCEPTION.getMessage()));
7474

75-
List<PublicCourse> publicCourses = courseRepository.findCoursesByRunnectUserAndIsPrivateIsTrue(profileUser)
75+
List<PublicCourse> publicCourses = courseRepository.findCoursesForUserProfile(profileUser)
7676
.stream().map(course -> course.getPublicCourse()).collect(Collectors.toList());
7777

7878
List<PublicCourseResponse> publicCourseResponses = publicCourses.stream()

0 commit comments

Comments
 (0)