-
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
Changes from 3 commits
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.moddy.server.controller.model.dto; | ||
|
||
public record DesignerInfoOpenChatDto( | ||
String kakaoUrl, | ||
String imgUrl, | ||
String shopName, | ||
String name, | ||
String introduction | ||
) { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.moddy.server.service.application; | ||
|
||
import com.moddy.server.common.exception.enums.ErrorCode; | ||
import com.moddy.server.common.exception.model.NotFoundException; | ||
import com.moddy.server.domain.hair_model_application.HairModelApplication; | ||
import com.moddy.server.domain.hair_model_application.repository.HairModelApplicationJpaRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class HairModelApplicationRetrieveService { | ||
|
||
private final HairModelApplicationJpaRepository hairModelApplicationJpaRepository; | ||
|
||
public String getApplicationCaptureUrl(Long applicationId){ | ||
HairModelApplication application = hairModelApplicationJpaRepository.findById(applicationId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_APPLICATION_EXCEPTION)); | ||
return application.getApplicationCaptureUrl(); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.moddy.server.service.designer; | ||
|
||
import com.moddy.server.common.exception.enums.ErrorCode; | ||
import com.moddy.server.common.exception.model.NotFoundException; | ||
import com.moddy.server.controller.model.dto.response.DesignerInfoOpenChatResponse; | ||
import com.moddy.server.controller.model.dto.DesignerInfoOpenChatDto; | ||
import com.moddy.server.domain.designer.Designer; | ||
import com.moddy.server.domain.designer.repository.DesignerJpaRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class DesignerRetrieveService { | ||
|
||
private final DesignerJpaRepository designerJpaRepository; | ||
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()); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.moddy.server.service.model; | ||
|
||
import com.moddy.server.controller.model.dto.response.OpenChatResponse; | ||
import com.moddy.server.service.application.HairModelApplicationRetrieveService; | ||
import com.moddy.server.service.designer.DesignerRetrieveService; | ||
import com.moddy.server.service.offer.HairServiceOfferRetrieveService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class ModelRetrieveService { | ||
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. p2 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. p2 |
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ | |
import com.moddy.server.domain.user.repository.UserRepository; | ||
import com.moddy.server.external.s3.S3Service; | ||
import com.moddy.server.service.auth.AuthService; | ||
import com.moddy.server.service.designer.DesignerRetrieveService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageRequest; | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. p2 |
||
|
||
|
||
public ModelMainResponse getModelMainInfo(Long userId, int page, int size) { | ||
|
@@ -167,19 +169,6 @@ public void updateOfferAgreeStatus(Long offerId) { | |
hairServiceOffer.setIsModelAgree(true); | ||
} | ||
|
||
public OpenChatResponse getOpenChatInfo(Long userId, Long offerId) { | ||
|
||
HairServiceOffer hairServiceOffer = hairServiceOfferJpaRepository.findById(offerId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUNT_OFFER_EXCEPTION)); | ||
HairModelApplication application = hairModelApplicationJpaRepository.findById(hairServiceOffer.getHairModelApplication().getId()).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_APPLICATION_EXCEPTION)); | ||
Designer designer = designerJpaRepository.findById(hairServiceOffer.getDesigner().getId()).orElseThrow(() -> new NotFoundException(ErrorCode.DESIGNER_NOT_FOUND_EXCEPTION)); | ||
|
||
DesignerInfoOpenChatResponse designerInfoOpenChatResponse = new DesignerInfoOpenChatResponse(designer.getProfileImgUrl(), designer.getHairShop().getName(), designer.getName(), designer.getIntroduction()); | ||
|
||
OpenChatResponse openChatResponse = new OpenChatResponse(application.getApplicationCaptureUrl(), designer.getKakaoOpenChatUrl(), designerInfoOpenChatResponse); | ||
|
||
return openChatResponse; | ||
} | ||
|
||
public ApplicationUserDetailResponse getUserDetailInApplication(final Long userId) { | ||
Model model = modelJpaRepository.findById(userId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_MODEL_INFO)); | ||
List<String> preferRegions = preferRegionJpaRepository.findAllByModelId(model.getId()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.moddy.server.service.offer; | ||
|
||
import com.moddy.server.common.exception.enums.ErrorCode; | ||
import com.moddy.server.common.exception.model.NotFoundException; | ||
import com.moddy.server.controller.model.dto.DesignerInfoOpenChatDto; | ||
import com.moddy.server.controller.model.dto.response.DesignerInfoOpenChatResponse; | ||
import com.moddy.server.controller.model.dto.response.OpenChatResponse; | ||
import com.moddy.server.domain.hair_service_offer.HairServiceOffer; | ||
import com.moddy.server.domain.hair_service_offer.repository.HairServiceOfferJpaRepository; | ||
import com.moddy.server.service.application.HairModelApplicationRetrieveService; | ||
import com.moddy.server.service.designer.DesignerRetrieveService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class HairServiceOfferRetrieveService { | ||
|
||
private final HairServiceOfferJpaRepository hairServiceOfferJpaRepository; | ||
private final DesignerRetrieveService designerRetrieveService; | ||
private final HairModelApplicationRetrieveService hairModelApplicationRetrieveService; | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. p3 |
||
|
||
Long designerId = hairServiceOffer.getDesigner().getId(); | ||
Long applicationId = hairServiceOffer.getHairModelApplication().getId(); | ||
|
||
DesignerInfoOpenChatDto openChatDto = designerRetrieveService.getDesignerOpenDetail(designerId); | ||
|
||
DesignerInfoOpenChatResponse response = new DesignerInfoOpenChatResponse(openChatDto.imgUrl(), openChatDto.shopName(), openChatDto.name(), openChatDto.introduction()); | ||
|
||
OpenChatResponse openChatResponse = new OpenChatResponse(hairModelApplicationRetrieveService.getApplicationCaptureUrl(applicationId), openChatDto.kakaoUrl(), response); | ||
|
||
return openChatResponse; | ||
} | ||
} |
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로 하는 것이 더욱 명시적일 것 같습니다!