diff --git a/src/main/java/com/cloneweek/hanghaebnb/common/config/WebSecurityConfig.java b/src/main/java/com/cloneweek/hanghaebnb/common/config/WebSecurityConfig.java index ef1468a..4c38107 100644 --- a/src/main/java/com/cloneweek/hanghaebnb/common/config/WebSecurityConfig.java +++ b/src/main/java/com/cloneweek/hanghaebnb/common/config/WebSecurityConfig.java @@ -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); diff --git a/src/main/java/com/cloneweek/hanghaebnb/controller/RoomController.java b/src/main/java/com/cloneweek/hanghaebnb/controller/RoomController.java index 18a40d3..7d508df 100644 --- a/src/main/java/com/cloneweek/hanghaebnb/controller/RoomController.java +++ b/src/main/java/com/cloneweek/hanghaebnb/controller/RoomController.java @@ -51,10 +51,9 @@ public ResponseEntity> getnoclientRooms(@PageableDefau //숙소 키워드 조회 @GetMapping("/rooms/search") // '/api/rooms/search?keyword=제목&page=0&size=2' - public ResponseEntity> 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> search(@PageableDefault(sort = "createdAt", direction = Sort.Direction.DESC) Pageable pageable, + String keyword){ + return ResponseEntity.ok(roomService.search(keyword, pageable)); } //숙소 정보 수정 @@ -80,7 +79,7 @@ public ResponseEntity saveLike(@PathVariable Long roomId, return ResponseEntity.ok().body(roomService.saveLike(roomId, userDetails.getUser())); } - // 게시글 좋아요 취소 + // 숙소 좋아요 취소 @DeleteMapping("/rooms/{roomId}/like") public ResponseEntity cancelLike(@PathVariable Long roomId, @AuthenticationPrincipal UserDetailsImpl userDetails) { diff --git a/src/main/java/com/cloneweek/hanghaebnb/service/RoomService.java b/src/main/java/com/cloneweek/hanghaebnb/service/RoomService.java index 3cf0ed9..28aca74 100644 --- a/src/main/java/com/cloneweek/hanghaebnb/service/RoomService.java +++ b/src/main/java/com/cloneweek/hanghaebnb/service/RoomService.java @@ -92,15 +92,16 @@ public List getnoclientRooms(Pageable pageable) { //숙소 키워드 검색 @Transactional(readOnly = true) - public List search(String keyword, Pageable pageable, User user) { + public List search(String keyword, Pageable pageable) { Page roomList = roomRepository.findByTitleContaining(keyword, pageable); - List roomResponseDtos = new ArrayList<>(); + + List roomResponseDtos = new ArrayList<>(); for (Room room : roomList) { List 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;