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

#13 [FEAT] 이전 회고 템플릿 형식 조회 성공 #24

Merged
merged 1 commit into from
Jul 16, 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,5 @@
package com.puzzling.puzzlingServer.api.project.dto.response;

import com.puzzling.puzzlingServer.api.project.domain.Project;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.Optional;

public interface UserProjectRepository extends JpaRepository<UserProject, Long> {

Expand All @@ -13,6 +14,6 @@ public interface UserProjectRepository extends JpaRepository<UserProject, Long>

List<UserProject> findAllByProjectId(Long projectId);

UserProject findByMemberIdAndProjectId(Long memberId, Long projectId);
Optional<UserProject> findByMemberIdAndProjectId(Long memberId, Long projectId);

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.puzzling.puzzlingServer.api.project.service;

import com.puzzling.puzzlingServer.api.project.domain.Project;
import com.puzzling.puzzlingServer.api.project.dto.response.ProjectOwnPuzzleResponseDto;
import com.puzzling.puzzlingServer.api.project.dto.response.ProjectResponseDto;
import com.puzzling.puzzlingServer.api.project.dto.response.ProjectTeamPuzzleResponseDto;
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.ReviewPreviousTemplateResponseDto;
import com.puzzling.puzzlingServer.api.review.dto.response.ReviewTemplateGetResponseDto;
import com.puzzling.puzzlingServer.api.review.dto.request.ReviewTILRequestDto;
import com.puzzling.puzzlingServer.api.review.service.ReviewService;
Expand Down Expand Up @@ -35,4 +36,9 @@ public ApiResponse createReview5F(@PathVariable("memberId") Long memberId,@PathV
reviewService.createReview5F(memberId, projectId, review5FRequestDto);
return ApiResponse.success(SuccessStatus.POST_REVIEW_SUCCESS.getStatusCode(), SuccessStatus.POST_REVIEW_SUCCESS.getMessage());
}

@GetMapping("member/{memberId}/project/{projectId}/review/previous-template")
public ApiResponse<ReviewPreviousTemplateResponseDto> getPreviousReviewTemplate(@PathVariable Long memberId, @PathVariable Long projectId) {
return ApiResponse.success(SuccessStatus.GET_REVIEW_PREVIOUS_TEMPLATE, reviewService.getPreviousReviewTemplate(memberId, projectId));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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 ReviewPreviousTemplateResponseDto {
private Long previousTemplateId;

public static ReviewPreviousTemplateResponseDto of (Long previousTemplateId) {
return new ReviewPreviousTemplateResponseDto(previousTemplateId);
}
}
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.ReviewPreviousTemplateResponseDto;
import com.puzzling.puzzlingServer.api.review.dto.response.ReviewTemplateGetResponseDto;
import com.puzzling.puzzlingServer.api.review.dto.request.ReviewTILRequestDto;
import com.puzzling.puzzlingServer.api.review.repository.ReviewRepository;
Expand Down Expand Up @@ -45,7 +46,7 @@ public List<ReviewTemplateGetResponseDto> getReviewTemplateAll() {
@Override
@Transactional
public void createReviewTIL(Long memberId, Long projectId, ReviewTILRequestDto reviewTILRequestDto) {
UserProject userProject = userProjectRepository.findByMemberIdAndProjectId(memberId,projectId);
UserProject userProject = findUserProjectByMemberIdAndProjectId(memberId, projectId);

if ( reviewTILRequestDto.getReviewTemplateId() == null ) {
throw new BadRequestException("공백일 수 없습니다. (reviewTemplateId)");
Expand Down Expand Up @@ -75,7 +76,7 @@ public void createReviewTIL(Long memberId, Long projectId, ReviewTILRequestDto r
@Override
@Transactional
public void createReview5F(Long memberId, Long projectId, Review5FRequestDto review5FRequestDto) {
UserProject userProject = userProjectRepository.findByMemberIdAndProjectId(memberId,projectId);
UserProject userProject = findUserProjectByMemberIdAndProjectId(memberId, projectId);

if ( review5FRequestDto.getReviewTemplateId() == null ) {
throw new BadRequestException("공백일 수 없습니다. (reviewTemplateId)");
Expand Down Expand Up @@ -104,9 +105,21 @@ public void createReview5F(Long memberId, Long projectId, Review5FRequestDto rev
review5FRepository.save(review5F);
}

@Override
@Transactional
public ReviewPreviousTemplateResponseDto getPreviousReviewTemplate(Long memberId, Long projectId) {
UserProject findUserProject = findUserProjectByMemberIdAndProjectId(memberId, projectId);
return ReviewPreviousTemplateResponseDto.of(findUserProject.getReviewTemplateId());
}


private ReviewTemplate findReviewTemplateById (Long reviewTemplateId) {
return reviewTemplateRepository.findById(reviewTemplateId)
.orElseThrow(() -> new NotFoundException("해당하는 회고 팀플릿이 없습니다"));
.orElseThrow(() -> new NotFoundException("해당하는 회고 팀플릿이 없습니다."));
}

private UserProject findUserProjectByMemberIdAndProjectId (Long memberId, Long projectId) {
return userProjectRepository.findByMemberIdAndProjectId(memberId,projectId)
.orElseThrow(() -> new NotFoundException("해당하는 멤버가 참여하는 프로젝트가 아닙니다."));
}
Comment on lines +121 to 124
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p5
알려주셔서 감사합니다.

}
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.ReviewPreviousTemplateResponseDto;
import com.puzzling.puzzlingServer.api.review.dto.response.ReviewTemplateGetResponseDto;
import com.puzzling.puzzlingServer.api.review.dto.request.ReviewTILRequestDto;

Expand All @@ -13,4 +14,6 @@ public interface ReviewService {
void createReviewTIL(Long memberId, Long projectId, ReviewTILRequestDto reviewTILRequestDto);

void createReview5F(Long memberId, Long projectId, Review5FRequestDto review5FRequestDto);

ReviewPreviousTemplateResponseDto getPreviousReviewTemplate(Long memberId, Long projectId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public enum SuccessStatus {
* review
*/
GET_REVIEW_TEMPLATE_SUCCESS(HttpStatus.OK,"회고 템플릿 목록 조회 성공"),
POST_REVIEW_SUCCESS(HttpStatus.OK,"회고 글 작성 성공")
POST_REVIEW_SUCCESS(HttpStatus.CREATED,"회고 글 작성 성공"),
GET_REVIEW_PREVIOUS_TEMPLATE(HttpStatus.OK, "이전 회고 템플릿 조회 성공")
;

private final HttpStatus httpStatus;
Expand Down
Loading