Skip to content

Commit

Permalink
Merge branch 'develop' into feat/#30-team-review-start-end-get-api
Browse files Browse the repository at this point in the history
  • Loading branch information
yeseul106 authored Jul 17, 2023
2 parents 1f18e6d + ef4ca91 commit de68546
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ public interface UserProjectRepository extends JpaRepository<UserProject, Long>
List<UserProject> findAllByProjectIdOrderByReviewCountDesc(Long projectId);

Boolean existsByMemberIdAndProjectId(Long memberId, Long projectId);

boolean existsByProjectIdAndNickname(Long projectId, String memberProjectNickname);
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ public ProjectJoinResponseDto joinProject(Long memberId, ProjectJoinRequestDto p
if (userProjectRepository.existsByMemberIdAndProjectId(memberId, projectJoinRequestDto.getProjectId())){
throw new BadRequestException(("이미 프로젝트에 참여한 팀원입니다."));
}
if (userProjectRepository.existsByProjectIdAndNickname(projectJoinRequestDto.getProjectId(),projectJoinRequestDto.getMemberProjectNickname())){
throw new BadRequestException(("이미 프로젝트에 있는 닉네임입니다."));
}
Member member = findMemberById(memberId);
Project project = findProjectById(projectJoinRequestDto.getProjectId());

Expand Down
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 @@ -64,4 +65,9 @@ public ApiResponse<ReviewTeamStatusResponseDto> getTeamReviewStatus(@PathVariabl
@RequestParam String endDate) {
return ApiResponse.success(SuccessStatus.GET_REVIEW_TEAM_STATUS_SUCCESS, reviewService.getTeamReviewStatus(projectId, startDate, endDate));
}

@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 @@ -7,6 +7,10 @@
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.*;

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.request.ReviewTILRequestDto;
Expand Down Expand Up @@ -238,6 +242,33 @@ private Project findProjectById (Long projectId) {
return projectRepository.findById(projectId).orElseThrow(() ->
new NotFoundException(NOT_FOUND_PROJECT.getMessage()));
}

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)
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 @@ -26,4 +27,7 @@ public interface ReviewService {
List<ReviewActionPlanResponseDto> getReviewActionPlans(Long memberId, Long projectId);

List<ReviewTeamStatusResponseDto> getTeamReviewStatus(Long projectId, String startDate, String endDate);

List<MyReviewProjectResponseDto> getMyReviewProjects(Long memberId, Long projectId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ public enum SuccessStatus {
POST_REVIEW_SUCCESS(HttpStatus.CREATED,"회고 글 작성 성공"),
GET_REVIEW_PREVIOUS_TEMPLATE_SUCCESS(HttpStatus.OK, "이전 회고 템플릿 조회 성공"),
GET_REVIEW_ACTION_PLAN_SUCCESS(HttpStatus.OK, "ACTIONPLAN 내용 조회 성공"),
GET_REVIEW_TEAM_STATUS_SUCCESS(HttpStatus.OK, "팀원 회고 상황 조회 성공")
GET_REVIEW_TEAM_STATUS_SUCCESS(HttpStatus.OK, "팀원 회고 상황 조회 성공"),
GET_PROJECT_MY_REVIEWS_SUCCESS(HttpStatus.OK, "해당 프로젝트 내 회고 리스트 조회 성공")
;

private final HttpStatus httpStatus;
private final String message;

Expand Down

0 comments on commit de68546

Please sign in to comment.