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

#38 [FEAT] 해당 프로젝트 내 회고 리스트 조회 API #39

Merged
merged 2 commits into from
Jul 17, 2023
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
@@ -1,6 +1,7 @@
package com.puzzling.puzzlingServer.api.review.controller;

import com.puzzling.puzzlingServer.api.review.dto.request.Review5FRequestDto;
import com.puzzling.puzzlingServer.api.review.dto.response.MyReviewProjectResponseDto;
import com.puzzling.puzzlingServer.api.review.dto.response.ReviewActionPlanResponseDto;
import com.puzzling.puzzlingServer.api.review.dto.request.ReviewAARRequestDto;
import com.puzzling.puzzlingServer.api.review.dto.response.ReviewPreviousTemplateResponseDto;
Expand Down Expand Up @@ -57,4 +58,9 @@ public ApiResponse<ReviewPreviousTemplateResponseDto> getPreviousReviewTemplate(
public ApiResponse<ReviewActionPlanResponseDto> getReviewActionPlans(@PathVariable Long memberId, @PathVariable Long projectId) {
return ApiResponse.success(SuccessStatus.GET_REVIEW_ACTION_PLAN, reviewService.getReviewActionPlans(memberId, projectId));
}

@GetMapping("member/{memberId}/project/{projectId}/review")
public ApiResponse<MyReviewProjectResponseDto> getMyReviewProjects(@PathVariable Long memberId, @PathVariable Long projectId) {
return ApiResponse.success(SuccessStatus.GET_PROJECT_MY_REVIEWS_SUCCESS, reviewService.getMyReviewProjects(memberId, projectId));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.puzzling.puzzlingServer.api.review.dto.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import static lombok.AccessLevel.PRIVATE;

@Getter
@NoArgsConstructor(access = PRIVATE)
@AllArgsConstructor
public class MyReviewProjectResponseDto {
private Long reviewId;
private String reviewDate;
private String contents;

public static MyReviewProjectResponseDto of(Long reviewId, String reviewDate, String contents) {
return new MyReviewProjectResponseDto(reviewId,reviewDate,contents);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.puzzling.puzzlingServer.api.project.repository.UserProjectRepository;
import com.puzzling.puzzlingServer.api.review.domain.Review;
import com.puzzling.puzzlingServer.api.review.dto.request.Review5FRequestDto;
import com.puzzling.puzzlingServer.api.review.dto.response.MyReviewProjectResponseDto;
import com.puzzling.puzzlingServer.api.review.dto.response.ReviewActionPlanResponseDto;
import com.puzzling.puzzlingServer.api.review.dto.request.ReviewAARRequestDto;

Expand Down Expand Up @@ -191,6 +192,35 @@ public List<ReviewActionPlanResponseDto> getReviewActionPlans(Long memberId, Lon
.collect(Collectors.toList());
}

@Override
@Transactional
public List<MyReviewProjectResponseDto> getMyReviewProjects(Long memberId, Long projectId) {
List<Review> findReviews = reviewRepository.findAllByMemberIdAndProjectIdOrderByReviewDateDesc(memberId, projectId);

if (findReviews.isEmpty()) {
throw new BadRequestException("유저가 해당 프로젝트 팀원이 아닙니다.");
}
return findReviews.stream()
.map(findReview -> {
String reviewTemplateName = findReview.getReviewTemplate().getName();

switch (reviewTemplateName) {
case "TIL":
ReviewTIL reviewTIL = findReviewByReviewId(findReview.getId(), reviewTILRepository, "TIL");
return MyReviewProjectResponseDto.of(findReview.getId(), findReview.getReviewDate(), reviewTIL.getActionPlan());
case "5F":
Review5F review5F = findReviewByReviewId(findReview.getId(), review5FRepository, "5F");
return MyReviewProjectResponseDto.of(findReview.getId(), findReview.getReviewDate(), review5F.getActionPlan());
case "AAR":
ReviewAAR reviewAAR = findReviewByReviewId(findReview.getId(), reviewAARRepository, "AAR");
return MyReviewProjectResponseDto.of(findReview.getId(), findReview.getReviewDate(), reviewAAR.getActionPlan());
default:
throw new BadRequestException("올바르지 않은 리뷰 템플릿 이름: " + reviewTemplateName);
}
})
.collect(Collectors.toList());
}

private ReviewTemplate findReviewTemplateById (Long reviewTemplateId) {
return reviewTemplateRepository.findById(reviewTemplateId)
.orElseThrow(() -> new NotFoundException("해당하는 회고 팀플릿이 없습니다."));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.puzzling.puzzlingServer.api.review.service;

import com.puzzling.puzzlingServer.api.review.dto.request.Review5FRequestDto;
import com.puzzling.puzzlingServer.api.review.dto.response.MyReviewProjectResponseDto;
import com.puzzling.puzzlingServer.api.review.dto.response.ReviewActionPlanResponseDto;
import com.puzzling.puzzlingServer.api.review.dto.request.ReviewAARRequestDto;
import com.puzzling.puzzlingServer.api.review.dto.response.ReviewPreviousTemplateResponseDto;
Expand All @@ -23,4 +24,6 @@ public interface ReviewService {
ReviewPreviousTemplateResponseDto getPreviousReviewTemplate(Long memberId, Long projectId);

List<ReviewActionPlanResponseDto> getReviewActionPlans(Long memberId, Long projectId);

List<MyReviewProjectResponseDto> getMyReviewProjects(Long memberId, Long projectId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ public enum SuccessStatus {
GET_REVIEW_TEMPLATE_SUCCESS(HttpStatus.OK,"회고 템플릿 목록 조회 성공"),
POST_REVIEW_SUCCESS(HttpStatus.CREATED,"회고 글 작성 성공"),
GET_REVIEW_PREVIOUS_TEMPLATE(HttpStatus.OK, "이전 회고 템플릿 조회 성공"),
GET_REVIEW_ACTION_PLAN(HttpStatus.OK, "ACTIONPLAN 내용 조회 성공")
GET_REVIEW_ACTION_PLAN(HttpStatus.OK, "ACTIONPLAN 내용 조회 성공"),
GET_PROJECT_MY_REVIEWS_SUCCESS(HttpStatus.OK, "해당 프로젝트 내 회고 리스트 조회 성공")
;

private final HttpStatus httpStatus;
private final String message;

Expand Down
Loading