-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/99 리뷰 조회 기능 #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Feature/99 리뷰 조회 기능 #116
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c9a4106
feat(review): 응답 DTO, 동적 쿼리 조건 DTO
leebs0521 c4bedef
feat(review): 리뷰 조회 기능(단건, 기관별, 유저별)
leebs0521 b117b02
test(review): 리뷰 조회 기능(단건, 기관별, 유저별) 테스트
leebs0521 36650af
feat(review): 조회 API 컨트롤러
leebs0521 85f9d15
feat(review): 에러 메시지 추가
leebs0521 14de8b6
feat(volunteer-apply): 레포지토리 기능 추가
leebs0521 3bb940f
feat(volunteer): 리뷰 조회에 필요한 기능 추가
leebs0521 8a0012b
test(volunteer): 리뷰 조회에 필요한 기능 추가 테스트
leebs0521 e394dae
feat(review): 컨트롤러 스웨거 추가
leebs0521 0b6c4a3
refactor: sonar cube 수정 사항 반영
leebs0521 73ae476
chore: 불필요한 import 제거
leebs0521 368a972
refactor(review): 쿼리 조건식 배치 수정 및 elseif 제거
leebs0521 245805d
refactor(review): 리뷰 사항 반영
leebs0521 4449b23
refactor(review): 리뷰 사항 반영
leebs0521 5c30e18
refactor(recruit-board): volunteerType -> VolunteerCategory
leebs0521 3818d8d
refactor(recruit-board): volunteerType -> VolunteerCategory
leebs0521 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
81 changes: 81 additions & 0 deletions
81
src/main/java/com/somemore/review/controller/ReviewQueryApiController.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| package com.somemore.review.controller; | ||
|
|
||
| import static org.springframework.data.domain.Sort.Direction.DESC; | ||
|
|
||
| import com.somemore.global.common.response.ApiResponse; | ||
| import com.somemore.recruitboard.domain.VolunteerType; | ||
| import com.somemore.review.dto.condition.ReviewSearchCondition; | ||
| import com.somemore.review.dto.response.ReviewResponseDto; | ||
| import com.somemore.review.dto.response.ReviewWithNicknameResponseDto; | ||
| import com.somemore.review.usecase.ReviewQueryUseCase; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import java.util.UUID; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.data.web.PageableDefault; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RequestParam; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @Tag(name = "Review Query API", description = "리뷰 조회 API") | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/api") | ||
| @RestController | ||
| public class ReviewQueryApiController { | ||
|
|
||
| private final ReviewQueryUseCase reviewQueryUseCase; | ||
|
|
||
| @Operation(summary = "리뷰 단건 조회", description = "리뷰 ID를 사용하여 단건 리뷰 조회") | ||
| @GetMapping("/review/{id}") | ||
| public ApiResponse<ReviewResponseDto> getById(@PathVariable Long id) { | ||
|
|
||
| return ApiResponse.ok( | ||
| 200, | ||
| reviewQueryUseCase.getReviewById(id), | ||
| "리뷰 단건 조회 성공" | ||
| ); | ||
| } | ||
|
|
||
| @Operation(summary = "기관별 리뷰 조회", description = "기관 ID를 사용하여 리뷰 조회") | ||
| @GetMapping("/reviews/center/{centerId}") | ||
| public ApiResponse<Page<ReviewWithNicknameResponseDto>> getReviewsByCenterId( | ||
| @PathVariable UUID centerId, | ||
| @PageableDefault(sort = "created_at", direction = DESC) Pageable pageable, | ||
| @RequestParam(required = false) VolunteerType type | ||
| ) { | ||
| ReviewSearchCondition condition = ReviewSearchCondition.builder() | ||
| .volunteerType(type) | ||
| .pageable(pageable) | ||
| .build(); | ||
|
|
||
| return ApiResponse.ok( | ||
| 200, | ||
| reviewQueryUseCase.getReviewsByCenterId(centerId, condition), | ||
| "기관 리뷰 리스트 조회 성공" | ||
| ); | ||
| } | ||
|
|
||
| @Operation(summary = "봉사자 리뷰 조회", description = "봉사자 ID를 사용하여 리뷰 조회") | ||
| @GetMapping("/reviews/volunteer/{volunteerId}") | ||
| public ApiResponse<Page<ReviewWithNicknameResponseDto>> getReviewsByVolunteerId( | ||
| @PathVariable UUID volunteerId, | ||
| @PageableDefault(sort = "created_at", direction = DESC) Pageable pageable, | ||
| @RequestParam(required = false) VolunteerType type | ||
| ) { | ||
| ReviewSearchCondition condition = ReviewSearchCondition.builder() | ||
| .volunteerType(type) | ||
| .pageable(pageable) | ||
| .build(); | ||
|
|
||
| return ApiResponse.ok( | ||
| 200, | ||
| reviewQueryUseCase.getReviewsByVolunteerId(volunteerId, condition), | ||
| "유저 리뷰 리스트 조회 성공" | ||
| ); | ||
| } | ||
|
|
||
| } |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/somemore/review/dto/condition/ReviewSearchCondition.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.somemore.review.dto.condition; | ||
|
|
||
| import com.somemore.recruitboard.domain.VolunteerType; | ||
| import lombok.Builder; | ||
| import org.springframework.data.domain.Pageable; | ||
|
|
||
| @Builder | ||
| public record ReviewSearchCondition( | ||
| VolunteerType volunteerType, | ||
| Pageable pageable | ||
| ) { | ||
|
|
||
| } | ||
41 changes: 41 additions & 0 deletions
41
src/main/java/com/somemore/review/dto/response/ReviewResponseDto.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package com.somemore.review.dto.response; | ||
|
|
||
| import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; | ||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
| import com.somemore.review.domain.Review; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import java.time.LocalDateTime; | ||
| import java.util.UUID; | ||
| import lombok.Builder; | ||
|
|
||
| @Builder | ||
| @JsonNaming(SnakeCaseStrategy.class) | ||
| @Schema(description = "리뷰 응답 DTO") | ||
| public record ReviewResponseDto( | ||
| @Schema(description = "리뷰 ID", example = "123") | ||
| Long id, | ||
| @Schema(description = "봉사자(작성자) ID", example = "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d") | ||
| UUID volunteerId, | ||
| @Schema(description = "리뷰 제목", example = "제 인생 최고의 봉사활동") | ||
| String title, | ||
| @Schema(description = "리뷰 내용", example = "정말 유익했습니다. 더보기..") | ||
| String content, | ||
| @Schema(description = "이미지 링크", example = "https://image.domain.com/links") | ||
| String imgUrl, | ||
| @Schema(description = "작성 일자", example = "2024-12-01T09:00:00") | ||
| LocalDateTime createdAt, | ||
| @Schema(description = "수정 일자", example = "2024-12-01T09:00:00") | ||
| LocalDateTime updateAt | ||
| ) { | ||
|
|
||
| public static ReviewResponseDto from(Review review) { | ||
| return ReviewResponseDto.builder() | ||
| .id(review.getId()) | ||
| .volunteerId(review.getVolunteerId()) | ||
| .title(review.getTitle()) | ||
| .content(review.getContent()) | ||
| .imgUrl(review.getImgUrl()) | ||
| .build(); | ||
| } | ||
|
|
||
| } |
44 changes: 44 additions & 0 deletions
44
src/main/java/com/somemore/review/dto/response/ReviewWithNicknameResponseDto.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package com.somemore.review.dto.response; | ||
|
|
||
| import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; | ||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
| import com.somemore.review.domain.Review; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import java.time.LocalDateTime; | ||
| import java.util.UUID; | ||
| import lombok.Builder; | ||
|
|
||
| @Builder | ||
| @JsonNaming(SnakeCaseStrategy.class) | ||
| @Schema(description = "작성자 닉네임이 포함된 리뷰 응답 DTO") | ||
| public record ReviewWithNicknameResponseDto( | ||
| @Schema(description = "리뷰 ID", example = "123") | ||
| Long id, | ||
| @Schema(description = "봉사자(작성자) ID", example = "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d") | ||
| UUID volunteerId, | ||
| @Schema(description = "작성자 닉네임", example = "volunteer123") | ||
| String volunteerNickname, | ||
| @Schema(description = "리뷰 제목", example = "제 인생 최고의 봉사활동") | ||
| String title, | ||
| @Schema(description = "리뷰 내용", example = "정말 유익했습니다. 더보기..") | ||
| String content, | ||
| @Schema(description = "이미지 링크", example = "https://image.domain.com/links") | ||
| String imgUrl, | ||
| @Schema(description = "작성 일자", example = "2024-12-01T09:00:00") | ||
| LocalDateTime createdAt, | ||
| @Schema(description = "수정 일자", example = "2024-12-01T09:00:00") | ||
| LocalDateTime updateAt | ||
| ) { | ||
|
|
||
| public static ReviewWithNicknameResponseDto from(Review review, String volunteerNickname) { | ||
| return ReviewWithNicknameResponseDto.builder() | ||
| .id(review.getId()) | ||
| .volunteerId(review.getVolunteerId()) | ||
| .volunteerNickname(volunteerNickname) | ||
| .title(review.getTitle()) | ||
| .content(review.getContent()) | ||
| .imgUrl(review.getImgUrl()) | ||
| .build(); | ||
| } | ||
|
|
||
| } |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/somemore/review/repository/ReviewRepository.java
This file contains hidden or 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,13 +1,23 @@ | ||
| package com.somemore.review.repository; | ||
|
|
||
| import com.somemore.review.domain.Review; | ||
| import com.somemore.review.dto.condition.ReviewSearchCondition; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import java.util.UUID; | ||
| import org.springframework.data.domain.Page; | ||
|
|
||
| public interface ReviewRepository { | ||
|
|
||
| Review save(Review review); | ||
|
|
||
| List<Review> saveAll(List<Review> reviews); | ||
|
|
||
| Optional<Review> findById(Long id); | ||
|
|
||
| boolean existsByVolunteerApplyId(Long volunteerApplyId); | ||
|
|
||
| Page<Review> findAllByVolunteerIdAndSearch(UUID volunteerId, ReviewSearchCondition condition); | ||
|
|
||
| Page<Review> findAllByCenterIdAndSearch(UUID centerId, ReviewSearchCondition condition); | ||
| } |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.