-
Notifications
You must be signed in to change notification settings - Fork 2
MOSU-86 refactor: 한국어 Enum 반환 시 한글 반환으로 변경 #87
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
Changes from all commits
12e971e
8bc4688
31f50d5
ada04cb
b40e10e
37db5d9
97e8b3b
5605e25
82095da
2c9ffaf
76978a5
a938a26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |||||||||
|
|
||||||||||
| import java.util.List; | ||||||||||
| import life.mosu.mosuserver.domain.faq.FaqJpaEntity; | ||||||||||
| import life.mosu.mosuserver.domain.faq.FaqRepository; | ||||||||||
| import life.mosu.mosuserver.domain.faq.FaqJpaRepository; | ||||||||||
| import life.mosu.mosuserver.global.exception.CustomRuntimeException; | ||||||||||
| import life.mosu.mosuserver.global.exception.ErrorCode; | ||||||||||
| import life.mosu.mosuserver.presentation.faq.dto.FaqCreateRequest; | ||||||||||
|
|
@@ -21,21 +21,21 @@ | |||||||||
| @RequiredArgsConstructor | ||||||||||
| public class FaqService { | ||||||||||
|
|
||||||||||
| private final FaqRepository faqRepository; | ||||||||||
| private final FaqJpaRepository faqJpaRepository; | ||||||||||
| private final FaqAttachmentService attachmentService; | ||||||||||
|
|
||||||||||
|
|
||||||||||
| @Transactional | ||||||||||
| public void createFaq(FaqCreateRequest request) { | ||||||||||
| FaqJpaEntity faqEntity = faqRepository.save(request.toEntity()); | ||||||||||
| FaqJpaEntity faqEntity = faqJpaRepository.save(request.toEntity()); | ||||||||||
|
|
||||||||||
| attachmentService.createAttachment(request.attachments(), faqEntity); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) | ||||||||||
| public List<FaqResponse> getFaqWithAttachments(int page, int size) { | ||||||||||
| Pageable pageable = PageRequest.of(page, size, Sort.by("id")); | ||||||||||
| Page<FaqJpaEntity> faqPage = faqRepository.findAll(pageable); | ||||||||||
| Page<FaqJpaEntity> faqPage = faqJpaRepository.findAll(pageable); | ||||||||||
|
|
||||||||||
| return faqPage.stream() | ||||||||||
| .map(this::toFaqResponse) | ||||||||||
|
|
@@ -44,19 +44,19 @@ public List<FaqResponse> getFaqWithAttachments(int page, int size) { | |||||||||
|
|
||||||||||
| @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) | ||||||||||
| public FaqResponse getFaqDetail(Long faqId) { | ||||||||||
| FaqJpaEntity faq = faqRepository.findById(faqId) | ||||||||||
| FaqJpaEntity faq = faqJpaRepository.findById(faqId) | ||||||||||
| .orElseThrow(() -> new CustomRuntimeException(ErrorCode.FAQ_NOT_FOUND)); | ||||||||||
|
|
||||||||||
| return toFaqResponse(faq); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| @Transactional | ||||||||||
| public void update(FaqUpdateRequest request, Long faqId) { | ||||||||||
| FaqJpaEntity faqEntity = faqRepository.findById(faqId) | ||||||||||
| FaqJpaEntity faqEntity = faqJpaRepository.findById(faqId) | ||||||||||
| .orElseThrow(() -> new CustomRuntimeException(ErrorCode.FAQ_NOT_FOUND)); | ||||||||||
|
|
||||||||||
| faqEntity.update(request.question(), request.answer(), request.author()); | ||||||||||
| faqRepository.save(faqEntity); | ||||||||||
| faqJpaRepository.save(faqEntity); | ||||||||||
|
|
||||||||||
| attachmentService.deleteAttachment(faqEntity); | ||||||||||
| attachmentService.createAttachment(request.attachments(), faqEntity); | ||||||||||
|
|
@@ -65,9 +65,9 @@ public void update(FaqUpdateRequest request, Long faqId) { | |||||||||
|
|
||||||||||
| @Transactional | ||||||||||
| public void deleteFaq(Long faqId) { | ||||||||||
| FaqJpaEntity faqEntity = faqRepository.findById(faqId) | ||||||||||
| FaqJpaEntity faqEntity = faqJpaRepository.findById(faqId) | ||||||||||
| .orElseThrow(() -> new CustomRuntimeException(ErrorCode.FILE_NOT_FOUND)); | ||||||||||
|
Comment on lines
+68
to
69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix inconsistent error code usage. The error code should be - FaqJpaEntity faqEntity = faqJpaRepository.findById(faqId)
- .orElseThrow(() -> new CustomRuntimeException(ErrorCode.FILE_NOT_FOUND));
+ FaqJpaEntity faqEntity = faqJpaRepository.findById(faqId)
+ .orElseThrow(() -> new CustomRuntimeException(ErrorCode.FAQ_NOT_FOUND));📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| faqRepository.delete(faqEntity); | ||||||||||
| faqJpaRepository.delete(faqEntity); | ||||||||||
| attachmentService.deleteAttachment(faqEntity); | ||||||||||
| } | ||||||||||
|
|
||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| package life.mosu.mosuserver.application.inquiry; | ||
|
|
||
| import life.mosu.mosuserver.domain.inquiry.InquiryJpaEntity; | ||
| import life.mosu.mosuserver.domain.inquiry.InquiryRepository; | ||
| import life.mosu.mosuserver.domain.inquiry.InquiryJpaRepository; | ||
| import life.mosu.mosuserver.domain.inquiry.InquiryStatus; | ||
| import life.mosu.mosuserver.domain.inquiryAnswer.InquiryAnswerRepository; | ||
| import life.mosu.mosuserver.domain.inquiryAnswer.InquiryAnswerJpaRepository; | ||
| import life.mosu.mosuserver.global.exception.CustomRuntimeException; | ||
| import life.mosu.mosuserver.global.exception.ErrorCode; | ||
| import life.mosu.mosuserver.presentation.inquiry.dto.InquiryCreateRequest; | ||
|
|
@@ -22,13 +22,13 @@ | |
| public class InquiryService { | ||
|
|
||
| private final InquiryAttachmentService inquiryAttachmentService; | ||
| private final InquiryRepository inquiryRepository; | ||
| private final InquiryJpaRepository inquiryJpaRepository; | ||
| private final InquiryAnswerService inquiryAnswerService; | ||
| private final InquiryAnswerRepository inquiryAnswerRepository; | ||
| private final InquiryAnswerJpaRepository inquiryAnswerJpaRepository; | ||
|
|
||
|
Comment on lines
24
to
28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid mixing service & repository layers for the same aggregate Injecting both 🤖 Prompt for AI Agents |
||
| @Transactional | ||
| public void createInquiry(InquiryCreateRequest request) { | ||
| InquiryJpaEntity inquiryEntity = inquiryRepository.save(request.toEntity()); | ||
| InquiryJpaEntity inquiryEntity = inquiryJpaRepository.save(request.toEntity()); | ||
| inquiryAttachmentService.createAttachment(request.attachments(), inquiryEntity); | ||
| } | ||
|
|
||
|
|
@@ -39,7 +39,7 @@ public Page<InquiryResponse> getInquiries( | |
| boolean asc, | ||
| Pageable pageable) { | ||
|
|
||
| return inquiryRepository.searchInquiries(status, sortField, asc, pageable); | ||
| return inquiryJpaRepository.searchInquiries(status, sortField, asc, pageable); | ||
|
|
||
| } | ||
|
|
||
|
|
@@ -54,13 +54,13 @@ public InquiryDetailResponse getInquiryDetail(Long postId) { | |
| public void deleteInquiry(Long postId) { | ||
| InquiryJpaEntity inquiryEntity = getInquiryOrThrow(postId); | ||
|
|
||
| inquiryAnswerRepository.findByInquiryId(postId).ifPresent(answer -> { | ||
| inquiryAnswerJpaRepository.findByInquiryId(postId).ifPresent(answer -> { | ||
| inquiryAnswerService.deleteInquiryAnswer(postId); | ||
| }); | ||
|
|
||
| inquiryAttachmentService.deleteAttachment(inquiryEntity); | ||
|
|
||
| inquiryRepository.delete(inquiryEntity); | ||
| inquiryJpaRepository.delete(inquiryEntity); | ||
| } | ||
|
|
||
|
|
||
|
|
@@ -77,7 +77,7 @@ private InquiryDetailResponse toInquiryDetailResponse(InquiryJpaEntity inquiry) | |
| } | ||
|
|
||
| private InquiryJpaEntity getInquiryOrThrow(Long postId) { | ||
| return inquiryRepository.findById(postId) | ||
| return inquiryJpaRepository.findById(postId) | ||
| .orElseThrow(() -> new CustomRuntimeException(ErrorCode.INQUIRY_NOT_FOUND)); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error code
ErrorCode.FILE_NOT_FOUNDseems incorrect. UsingErrorCode.FAQ_NOT_FOUNDwould be clearer, as ingetFaqDetailandupdate.