Skip to content

Commit

Permalink
#9 refactor: 보드 조회API-도시 별(1개) 전체 조회 시 카테고리 조건 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
xhaktmchl committed Apr 30, 2023
1 parent dfe0230 commit c8972d5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public ApplicationResponse<List<List<GetAllBoardRes>>> findBoardsByCategories(@R
@ApiResponse(code= 404, message = "존재하지 않는 유저입니다."),
@ApiResponse(code = 4000 , message = "서버 오류입니다.")
})
@PostMapping("/get/city")
@PostMapping("/get/category/city")
public ApplicationResponse<GetAllBoardsByCityRes> findAllBoardsByCityName(@RequestBody @Validated GetAllBoardsByCityReq getAllBoardsByCityReq){
return boardService.findAllBoardsByCityName(getAllBoardsByCityReq);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public interface BoardRepository extends JpaRepository<Board, Long> {
@Query("select b from Board b where b.status = 'ACTIVE' and b.category.id = :categoryId")
Page<Board> findAllBoardsByCategory(Pageable pageable, @Param("categoryId") Long categoryId);

@Query("select b from Board b where b.status = 'ACTIVE' and b.city.cityName = :cityName")
Page<Board> 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<Board> 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<Board> findMyClubBoardsByUserId(Pageable pageable, @Param("userId") Long userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ public ApplicationResponse<GetAllBoardsByCityRes> findAllBoardsByCityName(GetAll
);
PageRequest pageRequest = PageRequest.of(cursor, PAGING_SIZE, sort);

Page<Board> boards = boardRepository.findAllBoardsByCityName(pageRequest, dto.getCityName());
Page<Board> boards = boardRepository.findAllBoardsByCityName(pageRequest, dto.getCategoryId(), dto.getCityName());
// 보드 res에 이미지uuid -> aws s3 url로 변환
/*List<GetAllBoardRes> boardsRes = boards.stream()
.filter(board -> !blockedUsers.contains(board.getHost())) // 차단당한 유저의 데이터 제외
Expand Down

0 comments on commit c8972d5

Please sign in to comment.