-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Teacher 조회 시 Lesson이 없어도 조회 가능 (#84)
- Loading branch information
Showing
3 changed files
with
13 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/be/dash/dashserver/database/core/teacher/TeacherJpaRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
package be.dash.dashserver.database.core.teacher; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import be.dash.dashserver.database.core.teacher.projection.TeacherLessonCount; | ||
|
||
public interface TeacherJpaRepository extends JpaRepository<TeacherJpaEntity, Long> { | ||
Optional<TeacherJpaEntity> findByMemberId(Long memberId); | ||
|
||
@Query("select new be.dash.dashserver.database.core.teacher.projection.TeacherLessonCount(t.id, t.member.nickname, count(l)) " + | ||
"from TeacherJpaEntity t " + | ||
"left join LessonJpaEntity l on l.teacher.id = t.id " + | ||
"where t.member.nickname like %:keyword% " + | ||
"group by t.id, t.member.nickname " + | ||
"order by count(l) desc") | ||
List<TeacherLessonCount> findTeacherLessonCountsDesc(@Param("keyword") String keyword); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters