From c8972d54b548ef95dee01ed6ae6b3a7f7d7e6e21 Mon Sep 17 00:00:00 2001 From: xhaktmchl Date: Sun, 30 Apr 2023 22:15:33 +0900 Subject: [PATCH] =?UTF-8?q?#9=20refactor:=20=EB=B3=B4=EB=93=9C=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8CAPI-=EB=8F=84=EC=8B=9C=20=EB=B3=84(1=EA=B0=9C)=20?= =?UTF-8?q?=EC=A0=84=EC=B2=B4=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EC=B9=B4?= =?UTF-8?q?=ED=85=8C=EA=B3=A0=EB=A6=AC=20=EC=A1=B0=EA=B1=B4=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../board/controller/BoardController.java | 2 +- .../dto/request/GetAllBoardsByCityReq.java | 20 +++++++++++-------- .../board/repository/BoardRepository.java | 4 ++-- .../board/service/BoardServiceImpl.java | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/server/src/main/java/com/yogit/server/board/controller/BoardController.java b/server/src/main/java/com/yogit/server/board/controller/BoardController.java index aa21806..eb0134a 100644 --- a/server/src/main/java/com/yogit/server/board/controller/BoardController.java +++ b/server/src/main/java/com/yogit/server/board/controller/BoardController.java @@ -172,7 +172,7 @@ public ApplicationResponse>> findBoardsByCategories(@R @ApiResponse(code= 404, message = "존재하지 않는 유저입니다."), @ApiResponse(code = 4000 , message = "서버 오류입니다.") }) - @PostMapping("/get/city") + @PostMapping("/get/category/city") public ApplicationResponse findAllBoardsByCityName(@RequestBody @Validated GetAllBoardsByCityReq getAllBoardsByCityReq){ return boardService.findAllBoardsByCityName(getAllBoardsByCityReq); } diff --git a/server/src/main/java/com/yogit/server/board/dto/request/GetAllBoardsByCityReq.java b/server/src/main/java/com/yogit/server/board/dto/request/GetAllBoardsByCityReq.java index ad79bb3..d8a7c45 100644 --- a/server/src/main/java/com/yogit/server/board/dto/request/GetAllBoardsByCityReq.java +++ b/server/src/main/java/com/yogit/server/board/dto/request/GetAllBoardsByCityReq.java @@ -9,19 +9,23 @@ @NoArgsConstructor public class GetAllBoardsByCityReq { - @ApiModelProperty(example = "1") - @ApiParam(value = "유저 ID", required = true) + @ApiModelProperty(example = "1", value = "유저 ID") + @ApiParam(required = true) private Long userId; - @ApiModelProperty(example = "1") - @ApiParam(value = "페이징 조회 페이지", required = true) + @ApiModelProperty(example = "1", value = "페이징 조회 페이지") + @ApiParam(required = true) private int cursor; - @ApiModelProperty(example = "SEOUL") - @ApiParam(value = "City 이름", required = true) + @ApiModelProperty(example = "1", value = "그룹 카테고리 ID") + @ApiParam( required = true) + private Long categoryId; + + @ApiModelProperty(example = "SEOUL", value = "City 이름") + @ApiParam(required = true) private String cityName; - @ApiModelProperty(example = "reb5085c395164587b84ac583d023011f.0.sryrq.IDLsECw-rsTozfsX0Yz-CA") - @ApiParam(value = "애플 리프레쉬 토큰", required = true) + @ApiModelProperty(example = "reb5085c395164587b84ac583d023011f.0.sryrq.IDLsECw-rsTozfsX0Yz-CA", value = "애플 리프레쉬 토큰") + @ApiParam(required = true) private String refreshToken; } diff --git a/server/src/main/java/com/yogit/server/board/repository/BoardRepository.java b/server/src/main/java/com/yogit/server/board/repository/BoardRepository.java index a45ce98..11c22bd 100644 --- a/server/src/main/java/com/yogit/server/board/repository/BoardRepository.java +++ b/server/src/main/java/com/yogit/server/board/repository/BoardRepository.java @@ -24,8 +24,8 @@ public interface BoardRepository extends JpaRepository { @Query("select b from Board b where b.status = 'ACTIVE' and b.category.id = :categoryId") Page findAllBoardsByCategory(Pageable pageable, @Param("categoryId") Long categoryId); - @Query("select b from Board b where b.status = 'ACTIVE' and b.city.cityName = :cityName") - Page findAllBoardsByCityName(Pageable pageable, @Param("cityName") String cityName); + @Query("select b from Board b where b.status = 'ACTIVE' and b.category.id = :categoryId and b.city.cityName = :cityName") + Page findAllBoardsByCityName(Pageable pageable, @Param("categoryId") Long categoryId, @Param("cityName") String cityName); @Query("select b from Board b where b.status = 'ACTIVE' and b.host.id = :userId") Page findMyClubBoardsByUserId(Pageable pageable, @Param("userId") Long userId); diff --git a/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java b/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java index a156953..967a552 100644 --- a/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java +++ b/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java @@ -417,7 +417,7 @@ public ApplicationResponse findAllBoardsByCityName(GetAll ); PageRequest pageRequest = PageRequest.of(cursor, PAGING_SIZE, sort); - Page boards = boardRepository.findAllBoardsByCityName(pageRequest, dto.getCityName()); + Page boards = boardRepository.findAllBoardsByCityName(pageRequest, dto.getCategoryId(), dto.getCityName()); // 보드 res에 이미지uuid -> aws s3 url로 변환 /*List boardsRes = boards.stream() .filter(board -> !blockedUsers.contains(board.getHost())) // 차단당한 유저의 데이터 제외