-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Refactor: Briefing V2 API Facade 추가
- Loading branch information
Showing
4 changed files
with
56 additions
and
35 deletions.
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
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
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
47 changes: 47 additions & 0 deletions
47
src/main/java/briefing/briefing/application/BriefingV2Facade.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,47 @@ | ||
package briefing.briefing.application; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import briefing.briefing.api.BriefingConverter; | ||
import briefing.briefing.application.dto.BriefingRequestParam; | ||
import briefing.briefing.application.dto.BriefingResponseDTO; | ||
import briefing.briefing.application.service.BriefingQueryService; | ||
import briefing.briefing.domain.Briefing; | ||
import briefing.common.enums.APIVersion; | ||
import briefing.member.domain.Member; | ||
import briefing.scrap.application.ScrapQueryService; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class BriefingV2Facade { | ||
|
||
private final BriefingQueryService briefingQueryService; | ||
private final ScrapQueryService scrapQueryService; | ||
private static final APIVersion version = APIVersion.V2; | ||
|
||
@Transactional(readOnly = true) | ||
public BriefingResponseDTO.BriefingPreviewListDTOV2 findBriefings( | ||
BriefingRequestParam.BriefingPreviewListParam params) { | ||
List<Briefing> briefingList = briefingQueryService.findBriefings(params, version); | ||
return BriefingConverter.toBriefingPreviewListDTOV2(params.getDate(), briefingList); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public BriefingResponseDTO.BriefingDetailDTOV2 findBriefing(final Long id, Member member) { | ||
Boolean isScrap = | ||
Optional.ofNullable(member) | ||
.map(m -> scrapQueryService.existsByMemberIdAndBriefingId(m.getId(), id)) | ||
.orElseGet(() -> Boolean.FALSE); | ||
|
||
Boolean isBriefingOpen = false; | ||
Boolean isWarning = false; | ||
|
||
return BriefingConverter.toBriefingDetailDTOV2( | ||
briefingQueryService.findBriefing(id, version), isScrap, isBriefingOpen, isWarning); | ||
} | ||
} |