-
Notifications
You must be signed in to change notification settings - Fork 1
fix(#396): 캠페인 제안 상세 조회에 제품 이름 추가 #397
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 1 commit
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 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,8 @@ | |||||||||||||||||
| import org.springframework.stereotype.Service; | ||||||||||||||||||
| import org.springframework.transaction.annotation.Transactional; | ||||||||||||||||||
|
|
||||||||||||||||||
| import com.example.RealMatch.brand.domain.entity.BrandAvailableSponsor; | ||||||||||||||||||
| import com.example.RealMatch.brand.domain.repository.BrandAvailableSponsorRepository; | ||||||||||||||||||
| import com.example.RealMatch.business.domain.entity.CampaignProposal; | ||||||||||||||||||
| import com.example.RealMatch.business.domain.repository.CampaignProposalRepository; | ||||||||||||||||||
| import com.example.RealMatch.business.exception.BusinessErrorCode; | ||||||||||||||||||
|
|
@@ -17,6 +19,7 @@ | |||||||||||||||||
| public class CampaignProposalQueryService { | ||||||||||||||||||
|
|
||||||||||||||||||
| private final CampaignProposalRepository campaignProposalRepository; | ||||||||||||||||||
| private final BrandAvailableSponsorRepository brandAvailableSponsorRepository; | ||||||||||||||||||
|
|
||||||||||||||||||
| public CampaignProposalDetailResponse getProposalDetail( | ||||||||||||||||||
| Long userId, | ||||||||||||||||||
|
|
@@ -25,6 +28,19 @@ public CampaignProposalDetailResponse getProposalDetail( | |||||||||||||||||
| CampaignProposal proposal = campaignProposalRepository.findByIdWithTags(proposalId) | ||||||||||||||||||
| .orElseThrow(() -> new CustomException(BusinessErrorCode.CAMPAIGN_PROPOSAL_NOT_FOUND)); | ||||||||||||||||||
|
Comment on lines
30
to
31
Contributor
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. The
Suggested change
Contributor
Author
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. 추후 권한 확인 로직 추가 예정 (데모데이 이후) |
||||||||||||||||||
|
|
||||||||||||||||||
| return CampaignProposalDetailResponse.from(proposal); | ||||||||||||||||||
| String productName = null; | ||||||||||||||||||
|
|
||||||||||||||||||
| // TODO: 데모데이 이후에 해당 제품이 없으면 에러 던지는 방향으로 수정 필요!! + 조회 권한 로직 추가 필요(본인만 조회 가능) | ||||||||||||||||||
| if (proposal.getProductId() != null) { | ||||||||||||||||||
| productName = brandAvailableSponsorRepository | ||||||||||||||||||
| .findByBrandIdAndId( | ||||||||||||||||||
| proposal.getBrand().getId(), | ||||||||||||||||||
| proposal.getProductId() | ||||||||||||||||||
| ) | ||||||||||||||||||
| .map(BrandAvailableSponsor::getName) | ||||||||||||||||||
| .orElse(null); | ||||||||||||||||||
| } | ||||||||||||||||||
|
||||||||||||||||||
|
|
||||||||||||||||||
| return CampaignProposalDetailResponse.from(proposal, productName); | ||||||||||||||||||
|
Comment on lines
+33
to
+40
Contributor
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. The if (!proposal.getSenderUserId().equals(userId) && !proposal.getReceiverUserId().equals(userId)) {
throw new CustomException(BusinessErrorCode.CAMPAIGN_PROPOSAL_USER_MISMATCH);
}
String productName = Optional.ofNullable(proposal.getProductId())
.flatMap(productId -> brandAvailableSponsorRepository
.findByBrandIdAndId(proposal.getBrand().getId(), productId))
.map(BrandAvailableSponsor::getName)
.orElse(null);
return CampaignProposalDetailResponse.from(proposal, productName); |
||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.