-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 검색 Native Query 작성 * feat: 방 검색 서비스 기능 구현 * test: 방 검색 서비스 테스트 * feat: 방 검색 컨트롤러 구현 * test: 방 컨트롤러 통합 테스트 구현 * refactor: 파라미터 타입 통일화 * refactor: controller 타입 수정
- Loading branch information
1 parent
cf6070f
commit fb060f9
Showing
8 changed files
with
361 additions
and
15 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
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
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.