-
Notifications
You must be signed in to change notification settings - Fork 0
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
[refactor] 카카오 오픈채팅 api service 분리 #212
Conversation
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.
작업하시느라 고생하셨습니다!
코맨트 확인해주세요!
@@ -39,6 +40,7 @@ | |||
public class ModelController { | |||
|
|||
private final ModelService modelService; | |||
private final ModelRetrieveService modelRetrieveService; |
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.
p2
현재 ModelController이긴 하지만 해당 API는 OfferController의 성격을 띄고 있습니다.
비록 현재 라우터는 /model/{offerId}/agress
이지만, 이는 추후에 수정할 예정이기 때문에
지금은 어색하더라도 ModelRetrieveService가 아닌 OfferRetrieveService를 통해 정보를 가져오는 것이 좋을 것 같습니다
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class ModelRetrieveService { |
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.
p2
ModelRetrieveService 가 아닌 OfferRetrieveService 라고 생각하고 리뷰 달겠습니다!
Long designerId = hairServiceOfferRetrieveService.getDesignerApplicationId(offerId).designerId(); | ||
Long applicationId = hairServiceOfferRetrieveService.getDesignerApplicationId(offerId).applicationId(); |
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.
p1
우선 Offer 엔티티는 designerId와 applicationId를 외래키로 가지고 있습니다.
그래서 각 도메인의 retrieve 서비스를 이용하지 않아도
offerRepository를 통해서 해당 Offer를 가져온다면 designerId와 applicationId를 가지고 올 수 있습니다.
public DesignerInfoOpenChatDTO getDesignerOpenDetail(final Long userId){ | ||
Designer designer = designerJpaRepository.findById(userId).orElseThrow(() -> new NotFoundException(ErrorCode.DESIGNER_NOT_FOUND_EXCEPTION)); | ||
return new DesignerInfoOpenChatDTO(designer.getKakaoOpenChatUrl(),designer.getProfileImgUrl(), designer.getHairShop().getName(), designer.getName(), designer.getIntroduction()); | ||
} |
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.
👍
Long designerId = hairServiceOfferRetrieveService.getDesignerApplicationId(offerId).designerId(); | ||
Long applicationId = hairServiceOfferRetrieveService.getDesignerApplicationId(offerId).applicationId(); | ||
|
||
OpenChatResponse openChatResponse = new OpenChatResponse(hairModelApplicationRetrieveService.getApplicationCaptureUrl(applicationId), designerRetrieveService.getDesignerOpenDetail(designerId).kakaoUrl(), designerRetrieveService.getDesignerOpenChatDetail(designerId)); |
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.
p2
applicationRetreieveService를 통해서 applicationCaptureUrl을 가져온 것은 좋습니다.
designerResponse를 반환할 때 designerRetrieveService에서 하는 것이 아닌 해당 로직에서 하는 것은 어떠나요?
아래 suggestion 코드의 변수 네이밍은 임의로 정한 것입니다! 코드를 반영하실 땐 적절한 네이밍으로 작성해주세요!
OpenChatResponse openChatResponse = new OpenChatResponse(hairModelApplicationRetrieveService.getApplicationCaptureUrl(applicationId), designerRetrieveService.getDesignerOpenDetail(designerId).kakaoUrl(), designerRetrieveService.getDesignerOpenChatDetail(designerId)); | |
String applicationCaptureUrl = hairModelApplicationRetrieveService.getApplicationCaptureUrl(applicationId); | |
DesignerInfoOpenChatDTO dto = designerRetrieveService.getDesignerOpenDetail(designerId); | |
DesignerInfoOpenChatResponse response = new DesignerInfoOpenChatResponse(dto.imgUrl(), dto.shopName(), dto.name(), dto.introduction()) | |
OpenChatResponse openChatResponse = new OpenChatResponse(applicationCaptureUrl, dto.kakaoUrl(), response); | |
return openChatResponse; |
|
||
public record DesignerInfoOpenChatDTO( | ||
String kakaoUrl, |
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.
p2
앱잼 때 DTO가 아닌 Dto로 명시하기로 정한 걸로 기억하고 있습니다..!
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.
수정사항 변경하느라 고생하셨습니다!
자잘한 코맨트 확인해주세요!
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class ModelRetrieveService { |
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.
p2
사용하지 않는 파일은 제거해주세요!
public DesignerInfoOpenChatDto getDesignerOpenDetail(final Long userId){ | ||
Designer designer = designerJpaRepository.findById(userId).orElseThrow(() -> new NotFoundException(ErrorCode.DESIGNER_NOT_FOUND_EXCEPTION)); |
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.
p2
userId 보다 designerId로 하는 것이 더욱 명시적일 것 같습니다!
|
||
public OpenChatResponse getOpenChatInfo(Long userId, Long offerId) { | ||
HairServiceOffer hairServiceOffer = hairServiceOfferJpaRepository.findById(offerId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUNT_OFFER_EXCEPTION)); |
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.
p3
해당 파라메터에도 final
을 붙이면 좋을 것 같습니다
@@ -73,6 +74,7 @@ public class ModelService { | |||
private final HairServiceRecordJpaRepository hairServiceRecordJpaRepository; | |||
private final AuthService authService; | |||
private final S3Service s3Service; | |||
private final DesignerRetrieveService designerRetrieveService; |
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.
p2
사용하지 않는 서비스는 제거해주세요!
+) import
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.
굳 좋습니다~!
@pkl0912 |
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.
구우욷... 고생하셨습니다..!!!
Designer랑 Application의 이미지 캡쳐만 가져오는데도 많은..파일 터치가 있네요.... 🫠
관련 이슈번호
해결하는 데 얼마나 걸렸나요? (예상 작업 시간 / 실제 작업 시간)
해결하려는 문제가 무엇인가요?
어떻게 해결했나요?
applicationUrl 외에 다른 건 다 designer관련입니다!
근데 offerId 로 application, designer 를 찾는 로직입니다