Skip to content
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

[BE] refactor: 사용하지 않는 메서드 제거, 컨벤션 및 작은 리팩토링 #206

Merged
merged 5 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public ProblemDetail handleUnAuthorizedException(UnAuthorizedException ex) {
return ProblemDetail.forStatusAndDetail(HttpStatus.UNAUTHORIZED, ex.getErrorMessage());
}


@ExceptionHandler(Exception.class)
public ProblemDetail handleException(Exception ex) {
log.error("An error occurred", ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public ResponseEntity<ReviewSetupResponse> findReviewCreationSetup(@RequestParam
}

@GetMapping("/reviews/{id}")
public ResponseEntity<ReviewDetailResponse> findReceivedReviewDetail(@PathVariable long id, HttpServletRequest request) {
public ResponseEntity<ReviewDetailResponse> findReceivedReviewDetail(@PathVariable long id,
HttpServletRequest request) {
String groupAccessCode = request.getHeader(GROUP_ACCESS_CODE_HEADER);
ReviewDetailResponse response = reviewService.findReceivedReviewDetail(groupAccessCode, id);
return ResponseEntity.ok(response);
Expand Down
5 changes: 3 additions & 2 deletions backend/src/main/java/reviewme/review/domain/Review.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import lombok.AccessLevel;
Expand Down Expand Up @@ -42,7 +43,7 @@ public Review(long reviewGroupId, List<ReviewContent> reviewContents, LocalDateT
this.createdAt = createdAt;
}

public boolean isGroupIdEqualTo(long reviewGroupId) {
return this.reviewGroupId == reviewGroupId;
public LocalDate getCreatedDate() {
return createdAt.toLocalDate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private ReviewDetailResponse createReviewDetailResponse(Review review, ReviewGro

return new ReviewDetailResponse(
review.getId(),
review.getCreatedAt().toLocalDate(),
review.getCreatedDate(),
reviewGroup.getProjectName(),
reviewGroup.getReviewee(),
reviewContents,
Expand All @@ -144,12 +144,12 @@ public ReceivedReviewsResponse findReceivedReviews(String groupAccessCode) {
List<ReceivedReviewResponse> reviewResponses =
reviewRepository.findReceivedReviewsByGroupId(reviewGroup.getId())
.stream()
.map(this::extractResponse)
.map(this::createReceivedReviewResponse)
.toList();
return new ReceivedReviewsResponse(reviewGroup.getReviewee(), reviewGroup.getProjectName(), reviewResponses);
}

private ReceivedReviewResponse extractResponse(Review review) {
private ReceivedReviewResponse createReceivedReviewResponse(Review review) {
List<ReceivedReviewKeywordsResponse> keywordsResponses =
reviewKeywordRepository.findAllByReviewId(review.getId())
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public class ReviewGroupController {
private final ReviewGroupService reviewGroupService;

@PostMapping("/groups")
public ResponseEntity<ReviewGroupCreationResponse> createReviewGroup(@Valid @RequestBody ReviewGroupCreationRequest request) {
public ResponseEntity<ReviewGroupCreationResponse> createReviewGroup(
@Valid @RequestBody ReviewGroupCreationRequest request
) {
ReviewGroupCreationResponse response = reviewGroupService.createReviewGroup(request);
return ResponseEntity.ok(response);
}
Expand Down