-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/com/moddy/server/controller/model/dto/DesignerInfoOpenChatDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) { | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/moddy/server/service/application/HairModelApplicationRetrieveService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/moddy/server/service/designer/DesignerRetrieveService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 designerId){ | ||
Designer designer = designerJpaRepository.findById(designerId).orElseThrow(() -> new NotFoundException(ErrorCode.DESIGNER_NOT_FOUND_EXCEPTION)); | ||
return new DesignerInfoOpenChatDto(designer.getKakaoOpenChatUrl(),designer.getProfileImgUrl(), designer.getHairShop().getName(), designer.getName(), designer.getIntroduction()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/com/moddy/server/service/offer/HairServiceOfferRetrieveService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(final Long userId, final Long offerId) { | ||
HairServiceOffer hairServiceOffer = hairServiceOfferJpaRepository.findById(offerId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUNT_OFFER_EXCEPTION)); | ||
|
||
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; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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