diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/annotation/Adapter.java b/Briefing-Api/src/main/java/com/example/briefingapi/annotation/Adapter.java new file mode 100644 index 0000000..7861bf7 --- /dev/null +++ b/Briefing-Api/src/main/java/com/example/briefingapi/annotation/Adapter.java @@ -0,0 +1,16 @@ +package com.example.briefingapi.annotation; + +import org.springframework.core.annotation.AliasFor; +import org.springframework.stereotype.Component; + +import java.lang.annotation.*; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Component +public @interface Adapter { + // 스프링 빈의 이름을 지정 + @AliasFor(annotation = Component.class) + String value() default ""; +} \ No newline at end of file diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/aop/annotation/CacheEvictByBriefingId.java b/Briefing-Api/src/main/java/com/example/briefingapi/annotation/CacheEvictByBriefingId.java similarity index 88% rename from Briefing-Api/src/main/java/com/example/briefingapi/aop/annotation/CacheEvictByBriefingId.java rename to Briefing-Api/src/main/java/com/example/briefingapi/annotation/CacheEvictByBriefingId.java index 2229df6..bda51c1 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/aop/annotation/CacheEvictByBriefingId.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/annotation/CacheEvictByBriefingId.java @@ -1,4 +1,4 @@ -package com.example.briefingapi.aop.annotation; +package com.example.briefingapi.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/aop/aspect/CacheEvictByBriefingIdAspect.java b/Briefing-Api/src/main/java/com/example/briefingapi/aop/CacheEvictByBriefingIdAspect.java similarity index 95% rename from Briefing-Api/src/main/java/com/example/briefingapi/aop/aspect/CacheEvictByBriefingIdAspect.java rename to Briefing-Api/src/main/java/com/example/briefingapi/aop/CacheEvictByBriefingIdAspect.java index 73624af..d3b22f5 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/aop/aspect/CacheEvictByBriefingIdAspect.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/aop/CacheEvictByBriefingIdAspect.java @@ -1,8 +1,8 @@ -package com.example.briefingapi.aop.aspect; +package com.example.briefingapi.aop; import java.util.Optional; -import com.example.briefingapi.aop.annotation.CacheEvictByBriefingId; +import com.example.briefingapi.annotation.CacheEvictByBriefingId; import com.example.briefingcommon.domain.repository.article.BriefingRepository; import com.example.briefingcommon.entity.Briefing; import org.aspectj.lang.JoinPoint; diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingConverter.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingMapper.java similarity index 93% rename from Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingConverter.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingMapper.java index c2fda6e..3ebcbcc 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingConverter.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingMapper.java @@ -9,8 +9,11 @@ import com.example.briefingcommon.entity.Article; import com.example.briefingcommon.entity.Briefing; import com.example.briefingcommon.entity.enums.BriefingType; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; -public class BriefingConverter { +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class BriefingMapper { public static BriefingResponseDTO.BriefingPreviewDTOV2 toBriefingPreviewDTOV2( Briefing briefing) { @@ -46,7 +49,7 @@ private static LocalDateTime getPreviewListDTOCreatedAt( public static BriefingResponseDTO.BriefingPreviewListDTOV2 toBriefingPreviewListDTOV2( final LocalDate date, List briefingList) { final List briefingPreviewDTOList = - briefingList.stream().map(BriefingConverter::toBriefingPreviewDTOV2).toList(); + briefingList.stream().map(BriefingMapper::toBriefingPreviewDTOV2).toList(); return BriefingResponseDTO.BriefingPreviewListDTOV2.builder() .createdAt(getPreviewListDTOCreatedAt(date, briefingList)) @@ -57,7 +60,7 @@ public static BriefingResponseDTO.BriefingPreviewListDTOV2 toBriefingPreviewList public static BriefingResponseDTO.BriefingPreviewListDTO toBriefingPreviewListDTO( final LocalDate date, List briefingList) { final List briefingPreviewDTOList = - briefingList.stream().map(BriefingConverter::toBriefingPreviewDTO).toList(); + briefingList.stream().map(BriefingMapper::toBriefingPreviewDTO).toList(); return BriefingResponseDTO.BriefingPreviewListDTO.builder() .createdAt(getPreviewListDTOCreatedAt(date, briefingList)) @@ -80,7 +83,7 @@ public static BriefingResponseDTO.BriefingDetailDTO toBriefingDetailDTO( List articleResponseDTOList = briefing.getArticles().stream() - .map(BriefingConverter::toArticleResponseDTO) + .map(BriefingMapper::toArticleResponseDTO) .toList(); return BriefingResponseDTO.BriefingDetailDTO.builder() @@ -102,7 +105,7 @@ public static BriefingResponseDTO.BriefingDetailDTOV2 toBriefingDetailDTOV2( List articleResponseDTOList = briefing.getArticles().stream() - .map(BriefingConverter::toArticleResponseDTO) + .map(BriefingMapper::toArticleResponseDTO) .toList(); return BriefingResponseDTO.BriefingDetailDTOV2.builder() @@ -188,7 +191,7 @@ public static BriefingResponseDTO.BriefingPreviewV2TempDTO toBriefingPreviewV2Te public static BriefingResponseDTO.BriefingV2PreviewListDTO toBriefingPreviewV2TempListDTO( final LocalDate date, List temp, BriefingType briefingType) { List tempDTOList = - temp.stream().map(BriefingConverter::toBriefingPreviewV2TempDTO).toList(); + temp.stream().map(BriefingMapper::toBriefingPreviewV2TempDTO).toList(); return BriefingResponseDTO.BriefingV2PreviewListDTO.builder() .createdAt(date.atTime(3, 0)) diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingFacade.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingService.java similarity index 65% rename from Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingFacade.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingService.java index 9b526dc..d57821c 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingFacade.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingService.java @@ -3,78 +3,79 @@ import java.util.List; import java.util.Optional; -import com.example.briefingapi.briefing.implement.service.ArticleCommandService; -import com.example.briefingapi.briefing.implement.service.BriefingCommandService; -import com.example.briefingapi.briefing.implement.service.BriefingQueryService; +import com.example.briefingapi.briefing.implement.service.ArticleCommandAdapter; +import com.example.briefingapi.briefing.implement.service.BriefingCommandAdapter; +import com.example.briefingapi.briefing.implement.service.BriefingQueryAdapter; import com.example.briefingapi.briefing.presentation.dto.BriefingRequestDTO; import com.example.briefingapi.briefing.presentation.dto.BriefingRequestParam; import com.example.briefingapi.briefing.presentation.dto.BriefingResponseDTO; -import com.example.briefingapi.scrap.implement.ScrapQueryService; +import com.example.briefingapi.scrap.implement.ScrapQueryAdapter; import com.example.briefingcommon.entity.Article; import com.example.briefingcommon.entity.Briefing; import com.example.briefingcommon.entity.Member; import com.example.briefingcommon.entity.enums.APIVersion; import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import lombok.RequiredArgsConstructor; -@Component +@Service @RequiredArgsConstructor -public class BriefingFacade { - private final ScrapQueryService scrapQueryService; - private final BriefingQueryService briefingQueryService; - private final BriefingCommandService briefingCommandService; - private final ArticleCommandService articleCommandService; +public class BriefingService { + private final ScrapQueryAdapter scrapQueryAdapter; + private final BriefingQueryAdapter briefingQueryAdapter; + private final BriefingCommandAdapter briefingCommandAdapter; + private final ArticleCommandAdapter articleCommandAdapter; private static final APIVersion version = APIVersion.V1; @Transactional(readOnly = true) public BriefingResponseDTO.BriefingPreviewListDTO findBriefings( BriefingRequestParam.BriefingPreviewListParam params) { - List briefingList = briefingQueryService.findBriefings(params, version); - return BriefingConverter.toBriefingPreviewListDTO(params.getDate(), briefingList); + List briefingList = briefingQueryAdapter.findBriefings(params, version); + return BriefingMapper.toBriefingPreviewListDTO(params.getDate(), briefingList); } @Transactional public BriefingResponseDTO.BriefingDetailDTO findBriefing(final Long id, Member member) { - briefingCommandService.increaseViewCountById(id); + briefingCommandAdapter.increaseViewCountById(id); Boolean isScrap = Optional.ofNullable(member) - .map(m -> scrapQueryService.existsByMemberIdAndBriefingId(m.getId(), id)) + .map(m -> scrapQueryAdapter.existsByMemberIdAndBriefingId(m.getId(), id)) .orElseGet(() -> Boolean.FALSE); Boolean isBriefingOpen = false; Boolean isWarning = false; - return BriefingConverter.toBriefingDetailDTO( - briefingQueryService.findBriefing(id, version), isScrap, isBriefingOpen, isWarning); + return BriefingMapper.toBriefingDetailDTO( + briefingQueryAdapter.findBriefing(id, version), isScrap, isBriefingOpen, isWarning); } @Transactional public void createBriefing(final BriefingRequestDTO.BriefingCreate request) { Briefing createdBriefing = - briefingCommandService.create(BriefingConverter.toBriefing(request)); + briefingCommandAdapter.create(BriefingMapper.toBriefing(request)); final List
articles = request.getArticles().stream() .map(articleCreateDto -> { - Article article = BriefingConverter.toArticle(articleCreateDto); + Article article = BriefingMapper.toArticle(articleCreateDto); article.setBriefing(createdBriefing); return article; }).toList(); - List
createdArticles = articleCommandService.createAll(articles); + List
createdArticles = articleCommandAdapter.createAll(articles); createdBriefing.setArticles(createdArticles); } @Transactional public BriefingResponseDTO.BriefingUpdateDTO updateBriefing( Long id, final BriefingRequestDTO.BriefingUpdateDTO request) { - Briefing briefing = briefingQueryService.findBriefing(id, APIVersion.V1); + Briefing briefing = briefingQueryAdapter.findBriefing(id, APIVersion.V1); Briefing updatedBriefing = - briefingCommandService.update( + briefingCommandAdapter.update( briefing, request.getTitle(), request.getSubTitle(), request.getContent()); - return BriefingConverter.toBriefingUpdateDTO(updatedBriefing); + return BriefingMapper.toBriefingUpdateDTO(updatedBriefing); } } diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingV2Facade.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingV2Service.java similarity index 64% rename from Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingV2Facade.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingV2Service.java index 7a04796..81c236f 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingV2Facade.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingV2Service.java @@ -3,47 +3,48 @@ import java.util.List; import java.util.Optional; -import com.example.briefingapi.briefing.implement.service.BriefingCommandService; -import com.example.briefingapi.briefing.implement.service.BriefingQueryService; +import com.example.briefingapi.briefing.implement.service.BriefingCommandAdapter; +import com.example.briefingapi.briefing.implement.service.BriefingQueryAdapter; import com.example.briefingapi.briefing.presentation.dto.BriefingRequestParam; import com.example.briefingapi.briefing.presentation.dto.BriefingResponseDTO; -import com.example.briefingapi.scrap.implement.ScrapQueryService; +import com.example.briefingapi.scrap.implement.ScrapQueryAdapter; import com.example.briefingcommon.entity.Briefing; import com.example.briefingcommon.entity.Member; import com.example.briefingcommon.entity.enums.APIVersion; import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import lombok.RequiredArgsConstructor; -@Component +@Service @RequiredArgsConstructor -public class BriefingV2Facade { +public class BriefingV2Service { - private final BriefingQueryService briefingQueryService; - private final BriefingCommandService briefingCommandService; - private final ScrapQueryService scrapQueryService; + private final BriefingQueryAdapter briefingQueryAdapter; + private final BriefingCommandAdapter briefingCommandAdapter; + private final ScrapQueryAdapter scrapQueryAdapter; private static final APIVersion version = APIVersion.V2; @Transactional(readOnly = true) public BriefingResponseDTO.BriefingPreviewListDTOV2 findBriefings( BriefingRequestParam.BriefingPreviewListParam params) { - List briefingList = briefingQueryService.findBriefings(params, version); - return BriefingConverter.toBriefingPreviewListDTOV2(params.getDate(), briefingList); + List briefingList = briefingQueryAdapter.findBriefings(params, version); + return BriefingMapper.toBriefingPreviewListDTOV2(params.getDate(), briefingList); } @Transactional public BriefingResponseDTO.BriefingDetailDTOV2 findBriefing(final Long id, Member member) { - briefingCommandService.increaseViewCountById(id); + briefingCommandAdapter.increaseViewCountById(id); Boolean isScrap = Optional.ofNullable(member) - .map(m -> scrapQueryService.existsByMemberIdAndBriefingId(m.getId(), id)) + .map(m -> scrapQueryAdapter.existsByMemberIdAndBriefingId(m.getId(), id)) .orElseGet(() -> Boolean.FALSE); Boolean isBriefingOpen = false; Boolean isWarning = false; - return BriefingConverter.toBriefingDetailDTOV2( - briefingQueryService.findBriefing(id, version), isScrap, isBriefingOpen, isWarning); + return BriefingMapper.toBriefingDetailDTOV2( + briefingQueryAdapter.findBriefing(id, version), isScrap, isBriefingOpen, isWarning); } } diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/ArticleCommandService.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/ArticleCommandAdapter.java similarity index 84% rename from Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/ArticleCommandService.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/ArticleCommandAdapter.java index 810ba1d..0f242b5 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/ArticleCommandService.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/ArticleCommandAdapter.java @@ -2,6 +2,7 @@ import java.util.List; +import com.example.briefingapi.annotation.Adapter; import com.example.briefingcommon.domain.repository.article.ArticleRepository; import com.example.briefingcommon.entity.Article; import org.springframework.stereotype.Service; @@ -9,9 +10,9 @@ import lombok.RequiredArgsConstructor; -@Service +@Adapter @RequiredArgsConstructor -public class ArticleCommandService { +public class ArticleCommandAdapter { private final ArticleRepository articleRepository; public List
createAll(final List
articles) { diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingCommandService.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingCommandAdapter.java similarity index 89% rename from Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingCommandService.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingCommandAdapter.java index 6c4be1b..c86c24d 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingCommandService.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingCommandAdapter.java @@ -1,14 +1,15 @@ package com.example.briefingapi.briefing.implement.service; +import com.example.briefingapi.annotation.Adapter; import com.example.briefingcommon.domain.repository.article.BriefingRepository; import com.example.briefingcommon.entity.Briefing; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; -@Service +@Adapter @RequiredArgsConstructor -public class BriefingCommandService { +public class BriefingCommandAdapter { private final BriefingRepository briefingRepository; diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingQueryService.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingQueryAdapter.java similarity index 93% rename from Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingQueryService.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingQueryAdapter.java index 201903b..a0213e6 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingQueryService.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingQueryAdapter.java @@ -2,6 +2,7 @@ import java.util.List; +import com.example.briefingapi.annotation.Adapter; import com.example.briefingapi.briefing.implement.context.BriefingQueryContext; import com.example.briefingapi.briefing.implement.context.BriefingQueryContextFactory; import com.example.briefingapi.briefing.presentation.dto.BriefingRequestParam; @@ -12,9 +13,9 @@ import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; -@Service +@Adapter @RequiredArgsConstructor -public class BriefingQueryService { +public class BriefingQueryAdapter { private final BriefingQueryContextFactory briefingQueryContextFactory; diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/BriefingApi.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/BriefingApi.java index dedd814..7e56b64 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/BriefingApi.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/BriefingApi.java @@ -1,6 +1,6 @@ package com.example.briefingapi.briefing.presentation; -import com.example.briefingapi.briefing.business.BriefingFacade; +import com.example.briefingapi.briefing.business.BriefingService; import com.example.briefingapi.briefing.presentation.dto.BriefingRequestDTO; import com.example.briefingapi.briefing.presentation.dto.BriefingRequestParam; import com.example.briefingapi.briefing.presentation.dto.BriefingResponseDTO; @@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.*; -import com.example.briefingapi.aop.annotation.CacheEvictByBriefingId; +import com.example.briefingapi.annotation.CacheEvictByBriefingId; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -26,14 +26,14 @@ @RequiredArgsConstructor public class BriefingApi { - private final BriefingFacade briefingFacade; + private final BriefingService briefingService; @GetMapping("/briefings") @Parameter(name = "timeOfDay", hidden = true) @Operation(summary = "03-01Briefing \uD83D\uDCF0 브리핑 목록 조회 V1", description = "") public CommonResponse findBriefings( @ParameterObject @ModelAttribute BriefingRequestParam.BriefingPreviewListParam params) { - return CommonResponse.onSuccess(briefingFacade.findBriefings(params)); + return CommonResponse.onSuccess(briefingService.findBriefings(params)); } @GetMapping("/briefings/{id}") @@ -41,7 +41,7 @@ public CommonResponse findBriefings( @Operation(summary = "03-02Briefing \uD83D\uDCF0 브리핑 단건 조회 V1", description = "") public CommonResponse findBriefing( @PathVariable final Long id, @AuthMember Member member) { - return CommonResponse.onSuccess(briefingFacade.findBriefing(id, member)); + return CommonResponse.onSuccess(briefingService.findBriefing(id, member)); } @CacheEvict(value = "findBriefingsV2", key = "#request.getBriefingType()") @@ -49,7 +49,7 @@ public CommonResponse findBriefing( @ResponseStatus(HttpStatus.CREATED) @Operation(summary = "03-03Briefing \uD83D\uDCF0 브리핑 등록", description = "") public void createBriefing(@RequestBody final BriefingRequestDTO.BriefingCreate request) { - briefingFacade.createBriefing(request); + briefingService.createBriefing(request); } /* @@ -69,6 +69,6 @@ public void createBriefing(@RequestBody final BriefingRequestDTO.BriefingCreate public CommonResponse patchBriefingContent( @PathVariable(name = "id") Long id, @RequestBody @Valid BriefingRequestDTO.BriefingUpdateDTO request) { - return CommonResponse.onSuccess(briefingFacade.updateBriefing(id, request)); + return CommonResponse.onSuccess(briefingService.updateBriefing(id, request)); } } diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/BriefingV2Api.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/BriefingV2Api.java index ffed107..48a4e4f 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/BriefingV2Api.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/BriefingV2Api.java @@ -1,6 +1,6 @@ package com.example.briefingapi.briefing.presentation; -import com.example.briefingapi.briefing.business.BriefingV2Facade; +import com.example.briefingapi.briefing.business.BriefingV2Service; import com.example.briefingapi.briefing.presentation.dto.BriefingRequestParam; import com.example.briefingapi.briefing.presentation.dto.BriefingResponseDTO; import com.example.briefingapi.security.handler.annotation.AuthMember; @@ -20,14 +20,14 @@ @RequiredArgsConstructor @RequestMapping("/v2") public class BriefingV2Api { - private final BriefingV2Facade briefingFacade; + private final BriefingV2Service briefingV2Service; @GetMapping("/briefings") @Operation(summary = "03-01Briefing \uD83D\uDCF0 브리핑 목록 조회 V2", description = "") @Cacheable(value = "findBriefingsV2", key = "#params.getType()") public CommonResponse findBriefingsV2( @ParameterObject @ModelAttribute BriefingRequestParam.BriefingPreviewListParam params) { - return CommonResponse.onSuccess(briefingFacade.findBriefings(params)); + return CommonResponse.onSuccess(briefingV2Service.findBriefings(params)); } @GetMapping("/briefings/{id}") @@ -35,6 +35,6 @@ public CommonResponse findBriefing @Parameter(name = "member", hidden = true) public CommonResponse findBriefingV2( @PathVariable final Long id, @AuthMember Member member) { - return CommonResponse.onSuccess(briefingFacade.findBriefing(id, member)); + return CommonResponse.onSuccess(briefingV2Service.findBriefing(id, member)); } } diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/member/business/MemberConverter.java b/Briefing-Api/src/main/java/com/example/briefingapi/member/business/MemberMapper.java similarity index 94% rename from Briefing-Api/src/main/java/com/example/briefingapi/member/business/MemberConverter.java rename to Briefing-Api/src/main/java/com/example/briefingapi/member/business/MemberMapper.java index 8e72224..7d8ae95 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/member/business/MemberConverter.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/member/business/MemberMapper.java @@ -8,14 +8,15 @@ import com.example.briefingcommon.entity.enums.MemberStatus; import com.example.briefingcommon.entity.enums.SocialType; import com.example.briefinginfra.feign.oauth.google.dto.GoogleUserInfo; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.springframework.stereotype.Component; import lombok.RequiredArgsConstructor; -@RequiredArgsConstructor -@Component -public class MemberConverter { +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class MemberMapper { public static MemberResponse.LoginDTO toLoginDTO( Member member, String accessToken, String refreshToken) { diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/member/business/MemberFacade.java b/Briefing-Api/src/main/java/com/example/briefingapi/member/business/MemberService.java similarity index 80% rename from Briefing-Api/src/main/java/com/example/briefingapi/member/business/MemberFacade.java rename to Briefing-Api/src/main/java/com/example/briefingapi/member/business/MemberService.java index bc1554a..683cc83 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/member/business/MemberFacade.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/member/business/MemberService.java @@ -3,8 +3,8 @@ import java.util.List; import com.example.briefingapi.fcm.implementation.FcmCommandService; -import com.example.briefingapi.member.implement.MemberCommandService; -import com.example.briefingapi.member.implement.MemberQueryService; +import com.example.briefingapi.member.implement.MemberCommandAdapter; +import com.example.briefingapi.member.implement.MemberQueryAdapter; import com.example.briefingapi.member.presentation.dto.MemberRequest; import com.example.briefingapi.member.presentation.dto.MemberResponse; import com.example.briefingapi.security.provider.TokenProvider; @@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -25,11 +26,11 @@ import lombok.RequiredArgsConstructor; -@Component +@Service @RequiredArgsConstructor -public class MemberFacade { - private final MemberQueryService memberQueryService; - private final MemberCommandService memberCommandService; +public class MemberService { + private final MemberQueryAdapter memberQueryAdapter; + private final MemberCommandAdapter memberCommandAdapter; private final TokenProvider tokenProvider; private final FcmCommandService fcmCommandService; private final RedisService redisService; @@ -45,10 +46,10 @@ public class MemberFacade { private Member loginWithGoogle(String identityToken) { GoogleUserInfo googleUserInfo = googleOauth2Client.verifyToken(identityToken); Member member = - memberQueryService + memberQueryAdapter .findBySocialIdAndSocialType(googleUserInfo.getSub(), SocialType.GOOGLE) - .orElseGet(() -> MemberConverter.toMember(googleUserInfo)); - return memberCommandService.save(member); + .orElseGet(() -> MemberMapper.toMember(googleUserInfo)); + return memberCommandAdapter.save(member); } @Transactional @@ -58,7 +59,7 @@ public MemberResponse.LoginDTO login( Member member = socialType == SocialType.GOOGLE ? loginWithGoogle(request.getIdentityToken()) - : memberCommandService.login(request); + : memberCommandAdapter.login(request); String accessToken = tokenProvider.createAccessToken( member.getId(), @@ -69,11 +70,11 @@ public MemberResponse.LoginDTO login( redisService .generateRefreshToken(member.getSocialId(), member.getSocialType()) .getToken(); - return MemberConverter.toLoginDTO(member, accessToken, refreshToken); + return MemberMapper.toLoginDTO(member, accessToken, refreshToken); } public MemberResponse.TestTokenDTO getTestToken(){ - Member member = memberQueryService.findById(63L); + Member member = memberQueryAdapter.findById(63L); return MemberResponse.TestTokenDTO.builder() .token( @@ -88,30 +89,30 @@ public MemberResponse.TestTokenDTO getTestToken(){ public MemberResponse.ReIssueTokenDTO reIssueToken(final MemberRequest.ReissueDTO request) { RefreshToken refreshToken = redisService.reGenerateRefreshToken(request); - Member parsedMember = memberQueryService.parseRefreshToken(refreshToken); + Member parsedMember = memberQueryAdapter.parseRefreshToken(refreshToken); String accessToken = tokenProvider.createAccessToken( parsedMember.getId(), parsedMember.getSocialType().toString(), parsedMember.getSocialId(), List.of(new SimpleGrantedAuthority(parsedMember.getRole().toString()))); - return MemberConverter.toReIssueTokenDTO( + return MemberMapper.toReIssueTokenDTO( parsedMember.getId(), accessToken, refreshToken.getToken()); } public MemberResponse.QuitDTO quit(final Long memberId) { - memberCommandService.deleteMember(memberId); - return MemberConverter.toQuitDTO(); + memberCommandAdapter.deleteMember(memberId); + return MemberMapper.toQuitDTO(); } public void subScribeDailyPush(MemberRequest.ToggleDailyPushAlarmDTO request, Member member){ if(request.getPermit().equals(permitFlag)){ - memberCommandService.storeFcmToken(request.getFcmToken(),member); + memberCommandAdapter.storeFcmToken(request.getFcmToken(),member); fcmCommandService.subScribe(dailyPushTopic, request.getFcmToken()); } else { - memberCommandService.abortFcmToken(request.getFcmToken(), member); + memberCommandAdapter.abortFcmToken(request.getFcmToken(), member); fcmCommandService.unSubScribe(dailyPushTopic,request.getFcmToken()); } } diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/member/implement/MemberCommandService.java b/Briefing-Api/src/main/java/com/example/briefingapi/member/implement/MemberCommandAdapter.java similarity index 94% rename from Briefing-Api/src/main/java/com/example/briefingapi/member/implement/MemberCommandService.java rename to Briefing-Api/src/main/java/com/example/briefingapi/member/implement/MemberCommandAdapter.java index 82b7ab0..ca42182 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/member/implement/MemberCommandService.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/member/implement/MemberCommandAdapter.java @@ -5,10 +5,10 @@ import java.security.PublicKey; import java.security.spec.RSAPublicKeySpec; import java.util.Base64; -import java.util.List; import java.util.Optional; -import com.example.briefingapi.member.business.MemberConverter; +import com.example.briefingapi.annotation.Adapter; +import com.example.briefingapi.member.business.MemberMapper; import com.example.briefingcommon.domain.repository.FcmTokenRepository; import com.example.briefingcommon.domain.repository.member.MemberRepository; import com.example.briefingapi.member.presentation.dto.MemberRequest; @@ -33,9 +33,9 @@ import io.jsonwebtoken.Jwts; import lombok.RequiredArgsConstructor; -@Service +@Adapter @RequiredArgsConstructor -public class MemberCommandService { +public class MemberCommandAdapter { private final MemberRepository memberRepository; private final AppleOauth2Client appleOauth2Client; @@ -43,7 +43,7 @@ public class MemberCommandService { private final FcmTokenRepository fcmTokenRepository; - Logger logger = LoggerFactory.getLogger(MemberCommandService.class); + Logger logger = LoggerFactory.getLogger(MemberCommandAdapter.class); public Member login(MemberRequest.LoginDTO request) { return loginWithApple(request); @@ -92,7 +92,7 @@ private Member loginWithApple(MemberRequest.LoginDTO request) { String nickName = nickNameGenerator.getOneRandomNickName(); return foundMember.isEmpty() - ? memberRepository.save(MemberConverter.toMember(appleSocialId, nickName)) + ? memberRepository.save(MemberMapper.toMember(appleSocialId, nickName)) : foundMember.get(); } diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/member/implement/MemberQueryService.java b/Briefing-Api/src/main/java/com/example/briefingapi/member/implement/MemberQueryAdapter.java similarity index 95% rename from Briefing-Api/src/main/java/com/example/briefingapi/member/implement/MemberQueryService.java rename to Briefing-Api/src/main/java/com/example/briefingapi/member/implement/MemberQueryAdapter.java index 3e71533..047e7de 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/member/implement/MemberQueryService.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/member/implement/MemberQueryAdapter.java @@ -2,6 +2,7 @@ import java.util.Optional; +import com.example.briefingapi.annotation.Adapter; import com.example.briefingcommon.domain.repository.member.MemberRepository; import com.example.briefingcommon.common.exception.MemberException; import com.example.briefingcommon.common.exception.common.ErrorCode; @@ -14,9 +15,9 @@ import lombok.RequiredArgsConstructor; -@Service +@Adapter @RequiredArgsConstructor -public class MemberQueryService { +public class MemberQueryAdapter { private final MemberRepository memberRepository; public Member findById(Long memberId) { diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/MemberApi.java b/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/MemberApi.java index 8aa05ab..95c6dce 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/MemberApi.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/MemberApi.java @@ -1,6 +1,6 @@ package com.example.briefingapi.member.presentation; -import com.example.briefingapi.member.business.MemberFacade; +import com.example.briefingapi.member.business.MemberService; import com.example.briefingapi.member.presentation.dto.MemberRequest; import com.example.briefingapi.member.presentation.dto.MemberResponse; import com.example.briefingapi.security.handler.annotation.AuthMember; @@ -34,13 +34,13 @@ content = @Content(schema = @Schema(implementation = CommonResponse.class))), }) public class MemberApi { - private final MemberFacade memberFacade; + private final MemberService memberService; @Operation(summary = "02-05 Member\uD83D\uDC64 [테스트] 테스트를 위한 토큰 발급 API", description = "테스트 용") @GetMapping("/members/auth/test") public CommonResponse testGenerateToken() { - return CommonResponse.onSuccess(memberFacade.getTestToken()); + return CommonResponse.onSuccess(memberService.getTestToken()); } @Operation(summary = "02-01 Member\uD83D\uDC64 소셜 로그인 V1", description = "구글, 애플 소셜로그인 API입니다.") @@ -56,7 +56,7 @@ public CommonResponse login( @Parameter(description = "소셜로그인 종류", example = "google") @PathVariable final SocialType socialType, @RequestBody final MemberRequest.LoginDTO request) { - return CommonResponse.onSuccess(memberFacade.login(socialType, request)); + return CommonResponse.onSuccess(memberService.login(socialType, request)); } @Operation( @@ -80,7 +80,7 @@ public CommonResponse login( @PostMapping("/members/auth/token") public CommonResponse reissueToken( @Valid @RequestBody MemberRequest.ReissueDTO request) { - return CommonResponse.onSuccess(memberFacade.reIssueToken(request)); + return CommonResponse.onSuccess(memberService.reIssueToken(request)); } @Operation(summary = "02-03 Member\uD83D\uDC64 회원 탈퇴 V1", description = "회원 탈퇴 API 입니다.") @@ -114,7 +114,7 @@ public CommonResponse reissueToken( }) public CommonResponse quitMember( @AuthMember Member member, @CheckSameMember @PathVariable Long memberId) { - return CommonResponse.onSuccess(memberFacade.quit(memberId)); + return CommonResponse.onSuccess(memberService.quit(memberId)); } @Operation(summary = "02-04 Member\uD83D\uDC64 푸쉬 알람 허용/거부 설정 ", description = "푸쉬 알람 허용/거부 설정입니다.") @@ -143,7 +143,7 @@ public CommonResponse subscribeDailyPush( @Parameter(hidden = true) @AuthMember Member member ){ - memberFacade.subScribeDailyPush(request,member); + memberService.subScribeDailyPush(request,member); return CommonResponse.onSuccess(); } } diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/MemberV2Api.java b/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/MemberV2Api.java index dc824c0..a2ece1d 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/MemberV2Api.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/MemberV2Api.java @@ -1,6 +1,6 @@ package com.example.briefingapi.member.presentation; -import com.example.briefingapi.member.business.MemberFacade; +import com.example.briefingapi.member.business.MemberService; import com.example.briefingapi.member.presentation.dto.MemberRequest; import com.example.briefingapi.member.presentation.dto.MemberResponse; import com.example.briefingapi.security.handler.annotation.AuthMember; @@ -36,7 +36,7 @@ }) @RequestMapping("/v2") public class MemberV2Api { - private final MemberFacade memberFacade; + private final MemberService memberService; @Operation(summary = "02-01 Member\uD83D\uDC64 소셜 로그인 V2", description = "구글, 애플 소셜로그인 API입니다.") @PostMapping("/members/auth/{socialType}") @@ -44,7 +44,7 @@ public CommonResponse loginV2( @Parameter(description = "소셜로그인 종류", example = "google") @PathVariable final SocialType socialType, @RequestBody final MemberRequest.LoginDTO request) { - return CommonResponse.onSuccess(memberFacade.login(socialType, request)); + return CommonResponse.onSuccess(memberService.login(socialType, request)); } @Operation(summary = "02-04 Member\uD83D\uDC64 푸쉬 알람 허용/거부 설정 V2 ", description = "푸쉬 알람 허용/거부 설정입니다.") @@ -72,7 +72,7 @@ public CommonResponse subscribeDailyPush( @Valid @RequestBody MemberRequest.ToggleDailyPushAlarmDTO request, @Parameter(hidden = true) @AuthMember Member member ){ - memberFacade.subScribeDailyPush(request,member); + memberService.subScribeDailyPush(request,member); return CommonResponse.onSuccess(); } @@ -97,7 +97,7 @@ public CommonResponse subscribeDailyPush( @PostMapping("/members/auth/token") public CommonResponse reissueTokenV2( @Valid @RequestBody MemberRequest.ReissueDTO request) { - return CommonResponse.onSuccess(memberFacade.reIssueToken(request)); + return CommonResponse.onSuccess(memberService.reIssueToken(request)); } @Operation(summary = "02-01 Member\uD83D\uDC64 회원 탈퇴 V2", description = "회원 탈퇴 API 입니다.") @@ -131,6 +131,6 @@ public CommonResponse reissueTokenV2( }) public CommonResponse quitMemberV2( @AuthMember Member member, @CheckSameMember @PathVariable Long memberId) { - return CommonResponse.onSuccess(memberFacade.quit(memberId)); + return CommonResponse.onSuccess(memberService.quit(memberId)); } } diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapConverter.java b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapMapper.java similarity index 95% rename from Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapConverter.java rename to Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapMapper.java index e48b8bd..2add06d 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapConverter.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapMapper.java @@ -6,8 +6,11 @@ import com.example.briefingcommon.entity.Briefing; import com.example.briefingcommon.entity.Member; import com.example.briefingcommon.entity.Scrap; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; -public class ScrapConverter { +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class ScrapMapper { public static ScrapResponse.CreateDTO toCreateDTO(Scrap createdScrap) { return ScrapResponse.CreateDTO.builder() .scrapId(createdScrap.getId()) diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapFacade.java b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapService.java similarity index 54% rename from Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapFacade.java rename to Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapService.java index 6f5ef15..51fd263 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapFacade.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapService.java @@ -2,10 +2,10 @@ import java.util.List; -import com.example.briefingapi.briefing.implement.service.BriefingQueryService; -import com.example.briefingapi.member.implement.MemberQueryService; -import com.example.briefingapi.scrap.implement.ScrapCommandService; -import com.example.briefingapi.scrap.implement.ScrapQueryService; +import com.example.briefingapi.briefing.implement.service.BriefingQueryAdapter; +import com.example.briefingapi.member.implement.MemberQueryAdapter; +import com.example.briefingapi.scrap.implement.ScrapCommandAdapter; +import com.example.briefingapi.scrap.implement.ScrapQueryAdapter; import com.example.briefingapi.scrap.presentation.dto.ScrapRequest; import com.example.briefingapi.scrap.presentation.dto.ScrapResponse; import com.example.briefingcommon.common.exception.common.ErrorCode; @@ -14,46 +14,47 @@ import com.example.briefingcommon.entity.Scrap; import com.example.briefingcommon.entity.enums.APIVersion; import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.example.briefingcommon.common.exception.ScrapException; import lombok.RequiredArgsConstructor; -@Component +@Service @RequiredArgsConstructor -public class ScrapFacade { - private final ScrapQueryService scrapQueryService; - private final ScrapCommandService scrapCommandService; - private final MemberQueryService memberQueryService; - private final BriefingQueryService briefingQueryService; +public class ScrapService { + private final ScrapQueryAdapter scrapQueryAdapter; + private final ScrapCommandAdapter scrapCommandAdapter; + private final MemberQueryAdapter memberQueryAdapter; + private final BriefingQueryAdapter briefingQueryAdapter; @Transactional public ScrapResponse.CreateDTO create(final ScrapRequest.CreateDTO request) { if (Boolean.TRUE.equals( - scrapQueryService.existsByMemberIdAndBriefingId( + scrapQueryAdapter.existsByMemberIdAndBriefingId( request.getMemberId(), request.getBriefingId()))) throw new ScrapException(ErrorCode.SCRAP_ALREADY_EXISTS); - Member member = memberQueryService.findById(request.getMemberId()); + Member member = memberQueryAdapter.findById(request.getMemberId()); Briefing briefing = - briefingQueryService.findBriefing(request.getBriefingId(), APIVersion.V1); + briefingQueryAdapter.findBriefing(request.getBriefingId(), APIVersion.V1); - Scrap scrap = ScrapConverter.toScrap(member, briefing); - Scrap createdScrap = scrapCommandService.create(scrap); - return ScrapConverter.toCreateDTO(createdScrap); + Scrap scrap = ScrapMapper.toScrap(member, briefing); + Scrap createdScrap = scrapCommandAdapter.create(scrap); + return ScrapMapper.toCreateDTO(createdScrap); } @Transactional public ScrapResponse.DeleteDTO delete(final Long briefingId, final Long memberId) { - Scrap scrap = scrapQueryService.getScrapByBriefingIdAndMemberId(briefingId, memberId); - Scrap deletedScrap = scrapCommandService.delete(scrap); - return ScrapConverter.toDeleteDTO(deletedScrap); + Scrap scrap = scrapQueryAdapter.getScrapByBriefingIdAndMemberId(briefingId, memberId); + Scrap deletedScrap = scrapCommandAdapter.delete(scrap); + return ScrapMapper.toDeleteDTO(deletedScrap); } @Transactional(readOnly = true) public List getScrapsByMemberId(final Long memberId) { - List scraps = scrapQueryService.getScrapsByMemberId(memberId); - return scraps.stream().map(ScrapConverter::toReadDTO).toList(); + List scraps = scrapQueryAdapter.getScrapsByMemberId(memberId); + return scraps.stream().map(ScrapMapper::toReadDTO).toList(); } } diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapV2Facade.java b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapV2Service.java similarity index 51% rename from Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapV2Facade.java rename to Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapV2Service.java index d6e2040..bda8d90 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapV2Facade.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapV2Service.java @@ -2,10 +2,10 @@ import java.util.List; -import com.example.briefingapi.briefing.implement.service.BriefingQueryService; -import com.example.briefingapi.member.implement.MemberQueryService; -import com.example.briefingapi.scrap.implement.ScrapCommandService; -import com.example.briefingapi.scrap.implement.ScrapQueryService; +import com.example.briefingapi.briefing.implement.service.BriefingQueryAdapter; +import com.example.briefingapi.member.implement.MemberQueryAdapter; +import com.example.briefingapi.scrap.implement.ScrapCommandAdapter; +import com.example.briefingapi.scrap.implement.ScrapQueryAdapter; import com.example.briefingapi.scrap.presentation.dto.ScrapRequest; import com.example.briefingapi.scrap.presentation.dto.ScrapResponse; import com.example.briefingcommon.common.exception.common.ErrorCode; @@ -14,49 +14,50 @@ import com.example.briefingcommon.entity.Scrap; import com.example.briefingcommon.entity.enums.APIVersion; import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.example.briefingcommon.common.exception.ScrapException; import lombok.RequiredArgsConstructor; -@Component +@Service @RequiredArgsConstructor -public class ScrapV2Facade { - private final ScrapQueryService scrapQueryService; - private final ScrapCommandService scrapCommandService; - private final MemberQueryService memberQueryService; - private final BriefingQueryService briefingQueryService; +public class ScrapV2Service { + private final ScrapQueryAdapter scrapQueryAdapter; + private final ScrapCommandAdapter scrapCommandAdapter; + private final MemberQueryAdapter memberQueryAdapter; + private final BriefingQueryAdapter briefingQueryAdapter; @Transactional public ScrapResponse.CreateDTOV2 create(final ScrapRequest.CreateDTO request) { if (Boolean.TRUE.equals( - scrapQueryService.existsByMemberIdAndBriefingId( + scrapQueryAdapter.existsByMemberIdAndBriefingId( request.getMemberId(), request.getBriefingId()))) throw new ScrapException(ErrorCode.SCRAP_ALREADY_EXISTS); - Member member = memberQueryService.findById(request.getMemberId()); + Member member = memberQueryAdapter.findById(request.getMemberId()); Briefing briefing = - briefingQueryService.findBriefing(request.getBriefingId(), APIVersion.V2); + briefingQueryAdapter.findBriefing(request.getBriefingId(), APIVersion.V2); - Scrap scrap = ScrapConverter.toScrap(member, briefing); - Scrap createdScrap = scrapCommandService.create(scrap); + Scrap scrap = ScrapMapper.toScrap(member, briefing); + Scrap createdScrap = scrapCommandAdapter.create(scrap); - Integer scrapCount = scrapQueryService.countByBriefingId(request.getBriefingId()); + Integer scrapCount = scrapQueryAdapter.countByBriefingId(request.getBriefingId()); - return ScrapConverter.toCreateDTOV2(createdScrap, scrapCount); + return ScrapMapper.toCreateDTOV2(createdScrap, scrapCount); } @Transactional public ScrapResponse.DeleteDTOV2 delete(final Long briefingId, final Long memberId) { - Scrap scrap = scrapQueryService.getScrapByBriefingIdAndMemberId(briefingId, memberId); - Scrap deletedScrap = scrapCommandService.delete(scrap); - Integer scrapCount = scrapQueryService.countByBriefingId(briefingId); - return ScrapConverter.toDeleteDTOV2(deletedScrap, scrapCount); + Scrap scrap = scrapQueryAdapter.getScrapByBriefingIdAndMemberId(briefingId, memberId); + Scrap deletedScrap = scrapCommandAdapter.delete(scrap); + Integer scrapCount = scrapQueryAdapter.countByBriefingId(briefingId); + return ScrapMapper.toDeleteDTOV2(deletedScrap, scrapCount); } @Transactional(readOnly = true) public List getScrapsByMemberId(final Long memberId) { - List scraps = scrapQueryService.getScrapsByMemberId(memberId); - return scraps.stream().map(ScrapConverter::toReadDTOV2).toList(); + List scraps = scrapQueryAdapter.getScrapsByMemberId(memberId); + return scraps.stream().map(ScrapMapper::toReadDTOV2).toList(); } } diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/scrap/implement/ScrapCommandService.java b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/implement/ScrapCommandAdapter.java similarity index 90% rename from Briefing-Api/src/main/java/com/example/briefingapi/scrap/implement/ScrapCommandService.java rename to Briefing-Api/src/main/java/com/example/briefingapi/scrap/implement/ScrapCommandAdapter.java index 94cbb6b..6f426a0 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/scrap/implement/ScrapCommandService.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/implement/ScrapCommandAdapter.java @@ -1,5 +1,6 @@ package com.example.briefingapi.scrap.implement; +import com.example.briefingapi.annotation.Adapter; import com.example.briefingcommon.domain.repository.scrap.ScrapRepository; import com.example.briefingcommon.common.exception.common.ErrorCode; import com.example.briefingcommon.entity.Scrap; @@ -9,9 +10,9 @@ import com.example.briefingcommon.common.exception.ScrapException; import lombok.RequiredArgsConstructor; -@Service +@Adapter @RequiredArgsConstructor -public class ScrapCommandService { +public class ScrapCommandAdapter { private final ScrapRepository scrapRepository; diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/scrap/implement/ScrapQueryService.java b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/implement/ScrapQueryAdapter.java similarity index 92% rename from Briefing-Api/src/main/java/com/example/briefingapi/scrap/implement/ScrapQueryService.java rename to Briefing-Api/src/main/java/com/example/briefingapi/scrap/implement/ScrapQueryAdapter.java index 7665584..56b2df1 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/scrap/implement/ScrapQueryService.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/implement/ScrapQueryAdapter.java @@ -2,6 +2,7 @@ import java.util.List; +import com.example.briefingapi.annotation.Adapter; import com.example.briefingcommon.domain.repository.scrap.ScrapRepository; import com.example.briefingcommon.common.exception.common.ErrorCode; import com.example.briefingcommon.entity.Scrap; @@ -10,9 +11,9 @@ import com.example.briefingcommon.common.exception.ScrapException; import lombok.RequiredArgsConstructor; -@Service +@Adapter @RequiredArgsConstructor -public class ScrapQueryService { +public class ScrapQueryAdapter { private final ScrapRepository scrapRepository; diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/ScrapApi.java b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/ScrapApi.java index e9ff992..b602e9f 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/ScrapApi.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/ScrapApi.java @@ -1,7 +1,7 @@ package com.example.briefingapi.scrap.presentation; import java.util.List; -import com.example.briefingapi.scrap.business.ScrapFacade; +import com.example.briefingapi.scrap.business.ScrapService; import com.example.briefingapi.scrap.presentation.dto.ScrapRequest; import com.example.briefingapi.scrap.presentation.dto.ScrapResponse; import com.example.briefingcommon.common.presentation.response.CommonResponse; @@ -19,7 +19,7 @@ @RestController @RequiredArgsConstructor public class ScrapApi { - private final ScrapFacade scrapFacade; + private final ScrapService scrapService; @Operation(summary = "05-01 Scrap📁 스크랩하기 V1", description = "브리핑을 스크랩하는 API입니다.") @PostMapping("/scraps/briefings") @@ -44,7 +44,7 @@ public class ScrapApi { }) public CommonResponse create( @RequestBody final ScrapRequest.CreateDTO request) { - return CommonResponse.onSuccess(scrapFacade.create(request)); + return CommonResponse.onSuccess(scrapService.create(request)); } @Operation(summary = "05-02 Scrap📁 스크랩 취소 V1", description = "스크랩을 취소하는 API입니다.") @@ -70,7 +70,7 @@ public CommonResponse create( }) public CommonResponse delete( @PathVariable final Long briefingId, @PathVariable final Long memberId) { - return CommonResponse.onSuccess(scrapFacade.delete(briefingId, memberId)); + return CommonResponse.onSuccess(scrapService.delete(briefingId, memberId)); } @Operation(summary = "05-03 Scrap📁 내 스크랩 조회 V1", description = "내 스크랩을 조회하는 API입니다.") @@ -96,6 +96,6 @@ public CommonResponse delete( }) public CommonResponse> getScrapsByMember( @PathVariable final Long memberId) { - return CommonResponse.onSuccess(scrapFacade.getScrapsByMemberId(memberId)); + return CommonResponse.onSuccess(scrapService.getScrapsByMemberId(memberId)); } } diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/ScrapV2Api.java b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/ScrapV2Api.java index ac62315..726ea1c 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/ScrapV2Api.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/ScrapV2Api.java @@ -1,7 +1,7 @@ package com.example.briefingapi.scrap.presentation; import java.util.List; -import com.example.briefingapi.scrap.business.ScrapV2Facade; +import com.example.briefingapi.scrap.business.ScrapV2Service; import com.example.briefingapi.scrap.presentation.dto.ScrapRequest; import com.example.briefingapi.scrap.presentation.dto.ScrapResponse; import com.example.briefingcommon.common.presentation.response.CommonResponse; @@ -11,7 +11,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import org.springframework.web.bind.annotation.*; -import com.example.briefingapi.aop.annotation.CacheEvictByBriefingId; +import com.example.briefingapi.annotation.CacheEvictByBriefingId; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; @@ -21,7 +21,7 @@ @RequiredArgsConstructor @RequestMapping("/v2") public class ScrapV2Api { - private final ScrapV2Facade scrapFacade; + private final ScrapV2Service scrapV2Service; @CacheEvictByBriefingId(value = "findBriefingsV2", briefingId = "#request.getBriefingId()") @Operation(summary = "05-01 Scrap📁 스크랩하기 V2", description = "브리핑을 스크랩하는 API입니다.") @@ -47,7 +47,7 @@ public class ScrapV2Api { }) public CommonResponse createV2( @RequestBody final ScrapRequest.CreateDTO request) { - return CommonResponse.onSuccess(scrapFacade.create(request)); + return CommonResponse.onSuccess(scrapV2Service.create(request)); } @CacheEvictByBriefingId(value = "findBriefingsV2", briefingId = "#briefingId") @@ -74,7 +74,7 @@ public CommonResponse createV2( }) public CommonResponse deleteV2( @PathVariable final Long briefingId, @PathVariable final Long memberId) { - return CommonResponse.onSuccess(scrapFacade.delete(briefingId, memberId)); + return CommonResponse.onSuccess(scrapV2Service.delete(briefingId, memberId)); } @Operation(summary = "05-03 Scrap📁 내 스크랩 조회 V2", description = "내 스크랩을 조회하는 API입니다.") @@ -100,6 +100,6 @@ public CommonResponse deleteV2( }) public CommonResponse> getScrapsByMemberV2( @PathVariable final Long memberId) { - return CommonResponse.onSuccess(scrapFacade.getScrapsByMemberId(memberId)); + return CommonResponse.onSuccess(scrapV2Service.getScrapsByMemberId(memberId)); } } diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/security/handler/annotation/AuthUserArgumentResolver.java b/Briefing-Api/src/main/java/com/example/briefingapi/security/handler/annotation/AuthUserArgumentResolver.java index c26e069..e4a9b50 100644 --- a/Briefing-Api/src/main/java/com/example/briefingapi/security/handler/annotation/AuthUserArgumentResolver.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/security/handler/annotation/AuthUserArgumentResolver.java @@ -1,14 +1,11 @@ package com.example.briefingapi.security.handler.annotation; -import com.example.briefingapi.member.implement.MemberQueryService; +import com.example.briefingapi.member.implement.MemberQueryAdapter; import com.example.briefingapi.security.provider.TokenProvider; import com.example.briefingcommon.entity.Member; import jakarta.servlet.http.HttpServletRequest; import org.springframework.core.MethodParameter; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; import org.springframework.web.bind.support.WebDataBinderFactory; @@ -22,7 +19,7 @@ @RequiredArgsConstructor public class AuthUserArgumentResolver implements HandlerMethodArgumentResolver { - private final MemberQueryService memberQueryService; + private final MemberQueryAdapter memberQueryAdapter; private final TokenProvider tokenProvider; @Override @@ -56,7 +53,7 @@ public Object resolveArgument( && tokenProvider.validateToken(jwt, TokenProvider.TokenType.ACCESS)) { // 토큰에서 사용자 ID (subject) 추출 String userId = tokenProvider.getAuthentication(jwt).getName(); - return memberQueryService.findById(Long.valueOf(userId)); + return memberQueryAdapter.findById(Long.valueOf(userId)); } return null; // 토큰이 없거나 유효하지 않은 경우 }