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] feat: 리뷰 폼 응답 재구현 #295

Merged
merged 28 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2ea69e6
feat: TemplateController 추가 및 리뷰 템플릿 응답 기능 구현
Kimprodp Aug 10, 2024
c424c06
feat: 리뷰 템플릿 응답을 위한 dto 생성
Kimprodp Aug 10, 2024
5abbf92
refactor: 에러 응답 메세지 변경
Kimprodp Aug 10, 2024
8d10101
refactor: onSelectedOptionId 타입 변경
Kimprodp Aug 10, 2024
d532c2b
refactor: 도메인 id 제외 생성자 추가
Kimprodp Aug 10, 2024
8cdaabe
feat: TemplateService 추가 및 기본 템플릿 응답 기능 추가
Kimprodp Aug 10, 2024
9039ec8
feat: TemplateMapper 구현
Kimprodp Aug 10, 2024
d6f708f
refactor: mapping url 중복으로 인한 context 로딩 에러 해결을 위해 임시적으로 url 경로 변경
Kimprodp Aug 10, 2024
9c50413
refactor: 로깅 레벨 warn으로 변경
Kimprodp Aug 10, 2024
fa0ae42
refactor: 질문에 옵션 그룹이 없을 경우 null을 사용하도록 변경
Kimprodp Aug 10, 2024
1811deb
refactor: id 리스트를 즉시 로딩할 수 있도록 변경
Kimprodp Aug 10, 2024
f2edd17
refactor: 메서드명 변경
Kimprodp Aug 10, 2024
2c93220
test: 테스트 추가
Kimprodp Aug 10, 2024
bb2245c
test: DatabaseCleaner에서 CollectionTable로 생성된 테이블 초기화 하도록 변경
Kimprodp Aug 11, 2024
040cbea
refactor: Transactional readOnly 설정
Kimprodp Aug 11, 2024
274d8d3
refactor: 컨트롤러 요청 경로 변경
Kimprodp Aug 11, 2024
31999b1
refactor: response에서 null 가능한 필드 명시
Kimprodp Aug 11, 2024
de0c64d
style: 오타 수정
Kimprodp Aug 11, 2024
f6c309c
refactor: Question2 hasGuideline 메서드에서 guideline이 null 인 경우도 추가
Kimprodp Aug 11, 2024
f7b1ec3
refactor: 기본 사용 템플릿을 찾을 수 없는 경우에 대한 예외명과 로그 메세지 수정
Kimprodp Aug 11, 2024
207eccc
refactor: 옵션 그룹에 옵션 아이템이 없는 경우에 대한 예외명 수정
Kimprodp Aug 11, 2024
fef29f6
refactor: SectionNotFoundException의 로그 레벨 수정 (info -> warn)
Kimprodp Aug 11, 2024
bc28681
refactor: 사용하지 않는 메서드 삭제
Kimprodp Aug 11, 2024
d26b268
test: 가이드라인이 제공되지 않는 경우 테스트 추가
Kimprodp Aug 11, 2024
3092be1
test: 옵션 그룹에 없는 질문이 없는 경우 테스트 추가
Kimprodp Aug 11, 2024
892c73b
test: 섹션의 선택된 옵션이 필요없는 경우 테스트 추가
Kimprodp Aug 11, 2024
be6b8d5
refactor: long 타입 변경
Kimprodp Aug 11, 2024
d5c3b3d
Merge remote-tracking branch 'refs/remotes/origin/develop' into be/fe…
Kimprodp Aug 12, 2024
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 @@ -16,7 +16,7 @@ public class TemplateController {

@GetMapping("/reviews/write")
Copy link
Contributor

Choose a reason for hiding this comment

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

기존 컨트롤러 지우면 프론트엔드가 간극이 있을 수 있으니 버전 업 하는 게 좋을 듯해요. v2 prefix를 들고가보는 건 어떨까요 /

Copy link
Contributor

Choose a reason for hiding this comment

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

(이미 반영되었네요)

public ResponseEntity<TemplateResponse> findReviewTemplate(@RequestParam String reviewRequestCode) {
TemplateResponse response = templateService.findDefaultTemplate();
TemplateResponse response = templateService.findDefaultTemplate(reviewRequestCode);
return ResponseEntity.ok(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package reviewme.template.domain.exception;

import lombok.extern.slf4j.Slf4j;
import reviewme.global.exception.NotFoundException;

@Slf4j
public class NoRegisteredTemplatesException extends NotFoundException {

public NoRegisteredTemplatesException() {
super("서버 내부에서 문제가 발생했어요. 서버에 문의해주세요.");
log.warn("NoRegisteredTemplatesException is occurred");
Copy link
Contributor

Choose a reason for hiding this comment

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

템플릿 아이디와 같은 문맥이 필요해요. 로그를 적을 때에는 달랑 이 메시지만 보고 어디에서 발생하는지에 대한 정보가 풍부하면 좋겠습니다

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package reviewme.template.service;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import reviewme.review.domain.exception.ReviewGroupNotFoundByRequestReviewCodeException;
import reviewme.reviewgroup.domain.ReviewGroup;
import reviewme.reviewgroup.repository.ReviewGroupRepository;
import reviewme.template.domain.Template;
import reviewme.template.domain.exception.NoRegisteredTemplatesException;
import reviewme.template.dto.response.TemplateResponse;
import reviewme.template.repository.TemplateRepository;

@Service
@RequiredArgsConstructor
public class TemplateService {

private final ReviewGroupRepository reviewGroupRepository;
private final TemplateRepository templateRepository;
private final TemplateMapper templateMapper;

@Transactional
public TemplateResponse findDefaultTemplate(String reviewRequestCode) {
ReviewGroup reviewGroup = reviewGroupRepository.findByReviewRequestCode(reviewRequestCode)
.orElseThrow(() -> new ReviewGroupNotFoundByRequestReviewCodeException(reviewRequestCode));

Template defaultTemplate = templateRepository.findTopByOrderByIdDesc()
.orElseThrow(NoRegisteredTemplatesException::new);
Copy link
Contributor

Choose a reason for hiding this comment

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

ReviewGroup에 templateId 필드를 두고, 거기로부터 templateId 를 가져와서 조회하는게 좋을 것 같아요! (지금은 templateId 가 review에 있는데 개인적으로 ReviewGroup에 옮겨야 한다고 생각합니다)


return templateMapper.mapToTemplateResponse(reviewGroup, defaultTemplate);
}
}