-
Notifications
You must be signed in to change notification settings - Fork 3
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: 방 검색 기능 구현 #121
Merged
Merged
feat: 방 검색 기능 구현 #121
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b0b6b30
Merge branch 'develop' into feature/#108-search
Shin-Jae-Yoon 20d48f7
feat: 검색 Native Query 작성
Shin-Jae-Yoon 6a3044c
feat: 방 검색 서비스 기능 구현
Shin-Jae-Yoon 474914d
test: 방 검색 서비스 테스트
Shin-Jae-Yoon 81c813e
feat: 방 검색 컨트롤러 구현
Shin-Jae-Yoon 3204f18
test: 방 컨트롤러 통합 테스트 구현
Shin-Jae-Yoon 9c3e6e6
refactor: 파라미터 타입 통일화
Shin-Jae-Yoon f187e7b
refactor: controller 타입 수정
Shin-Jae-Yoon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
37 changes: 37 additions & 0 deletions
37
src/main/java/com/moabam/api/domain/room/repository/RoomRepository.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,9 +1,46 @@ | ||
package com.moabam.api.domain.room.repository; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import com.moabam.api.domain.room.Room; | ||
|
||
public interface RoomRepository extends JpaRepository<Room, Long> { | ||
|
||
@Query(value = "select distinct rm.* from room rm left join routine rt on rm.id = rt.room_id " | ||
+ "where rm.title like %:keyword% " | ||
+ "or rm.manager_nickname like %:keyword% " | ||
+ "or rt.content like %:keyword% " | ||
+ "order by rm.id desc limit 11", nativeQuery = true) | ||
List<Room> searchByKeyword(@Param(value = "keyword") String keyword); | ||
|
||
@Query(value = "select distinct rm.* from room rm left join routine rt on rm.id = rt.room_id " | ||
+ "where (rm.title like %:keyword% " | ||
+ "or rm.manager_nickname like %:keyword% " | ||
+ "or rt.content like %:keyword%) " | ||
+ "and rm.room_type = :roomType " | ||
+ "order by rm.id desc limit 11", nativeQuery = true) | ||
List<Room> searchByKeywordAndRoomType(@Param(value = "keyword") String keyword, | ||
@Param(value = "roomType") String roomType); | ||
|
||
@Query(value = "select distinct rm.* from room rm left join routine rt on rm.id = rt.room_id " | ||
+ "where (rm.title like %:keyword% " | ||
+ "or rm.manager_nickname like %:keyword% " | ||
+ "or rt.content like %:keyword%) " | ||
+ "and rm.id < :roomId " | ||
+ "order by rm.id desc limit 11", nativeQuery = true) | ||
List<Room> searchByKeywordAndRoomId(@Param(value = "keyword") String keyword, @Param(value = "roomId") Long roomId); | ||
|
||
@Query(value = "select distinct rm.* from room rm left join routine rt on rm.id = rt.room_id " | ||
+ "where rm.title like %:keyword% " | ||
+ "or rm.manager_nickname like %:keyword% " | ||
+ "or rt.content like %:keyword% " | ||
+ "and rm.room_type = :roomType " | ||
+ "and rm.id < :roomId " | ||
+ "order by rm.id desc limit 11", nativeQuery = true) | ||
List<Room> searchByKeywordAndRoomIdAndRoomType(@Param(value = "keyword") String keyword, | ||
@Param(value = "roomType") String roomType, @Param(value = "roomId") Long roomId); | ||
} |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
중복된 쿼리 값들 default 메서드로 하셔도 되는거 아닌가요?