Skip to content

Commit

Permalink
Merge pull request #52 from hanghaebnb/feature/51
Browse files Browse the repository at this point in the history
[CHORE] - 검색어기λŠ₯ λΉ„νšŒμ›λ„ κ°€λŠ₯ν•˜λ„λ‘ μˆ˜μ • #51
  • Loading branch information
leejincha authored Dec 28, 2022
2 parents e28df5e + bb8dc6f commit 02f25a2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.antMatchers("/api/users/**").permitAll()
.antMatchers("/email/**").permitAll()
.antMatchers(HttpMethod.GET, "/api/rooms/main").permitAll()
.antMatchers(HttpMethod.GET, "/api/rooms/search").permitAll()
.anyRequest().authenticated()
.and()
.addFilterBefore(new JwtAuthFilter(jwtUtil),UsernamePasswordAuthenticationFilter.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ public ResponseEntity<List<UnClientResponseDto>> getnoclientRooms(@PageableDefau

//μˆ™μ†Œ ν‚€μ›Œλ“œ 쑰회
@GetMapping("/rooms/search") // '/api/rooms/search?keyword=제λͺ©&page=0&size=2'
public ResponseEntity<List<RoomResponseDto>> search(@AuthenticationPrincipal UserDetailsImpl userDetails,
@PageableDefault(sort = "createdAt", direction = Sort.Direction.DESC) Pageable pageable,
String keyword){
return ResponseEntity.ok(roomService.search(keyword, pageable, userDetails.getUser()));
public ResponseEntity<List<UnClientResponseDto>> search(@PageableDefault(sort = "createdAt", direction = Sort.Direction.DESC) Pageable pageable,
String keyword){
return ResponseEntity.ok(roomService.search(keyword, pageable));
}

//μˆ™μ†Œ 정보 μˆ˜μ •
Expand All @@ -80,7 +79,7 @@ public ResponseEntity<ResponseMsgDto> saveLike(@PathVariable Long roomId,
return ResponseEntity.ok().body(roomService.saveLike(roomId, userDetails.getUser()));
}

// κ²Œμ‹œκΈ€ μ’‹μ•„μš” μ·¨μ†Œ
// μˆ™μ†Œ μ’‹μ•„μš” μ·¨μ†Œ
@DeleteMapping("/rooms/{roomId}/like")
public ResponseEntity<ResponseMsgDto> cancelLike(@PathVariable Long roomId,
@AuthenticationPrincipal UserDetailsImpl userDetails) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,16 @@ public List<UnClientResponseDto> getnoclientRooms(Pageable pageable) {

//μˆ™μ†Œ ν‚€μ›Œλ“œ 검색
@Transactional(readOnly = true)
public List<RoomResponseDto> search(String keyword, Pageable pageable, User user) {
public List<UnClientResponseDto> search(String keyword, Pageable pageable) {
Page<Room> roomList = roomRepository.findByTitleContaining(keyword, pageable);
List<RoomResponseDto> roomResponseDtos = new ArrayList<>();

List<UnClientResponseDto> roomResponseDtos = new ArrayList<>();
for (Room room : roomList) {
List<String> imageFileList = new ArrayList<>();
for (ImageFile imageFile : room.getImageFileList()) {
imageFileList.add(imageFile.getPath());
}
roomResponseDtos.add(new RoomResponseDto(room, (checkLike(room.getId(), user)), imageFileList));
roomResponseDtos.add(new UnClientResponseDto(room, imageFileList));
}

return roomResponseDtos;
Expand Down

0 comments on commit 02f25a2

Please sign in to comment.