From 5ce571db03325490a666e910467ed72ecd86d99b Mon Sep 17 00:00:00 2001 From: kdomo Date: Sun, 12 Nov 2023 13:45:20 +0900 Subject: [PATCH] =?UTF-8?q?[#136]=20fix:=20=EC=9C=A0=EC=A0=80=20=ED=83=9C?= =?UTF-8?q?=EA=B7=B8=20=ED=9E=88=EC=8A=A4=ED=86=A0=EB=A6=AC=20=EB=8F=84?= =?UTF-8?q?=EB=A9=94=EC=9D=B8=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adpater/UserTagHistoryCommandAdapter.java | 18 ---------- .../adpater/UserTagHistoryQueryAdapter.java | 19 ----------- .../usertaghistory/domain/UserTagHistory.java | 34 ------------------- .../port/UserTagHistoryCommandPort.java | 7 ---- .../port/UserTagHistoryQueryPort.java | 8 ----- .../repository/UserTagHistoryRepository.java | 9 ----- .../usecase/FailureRegisterUseCase.java | 6 ---- .../todaysfail/api/web/tag/TagController.java | 8 ----- .../usecase/UserTagHistoryQueryUseCase.java | 29 ---------------- 9 files changed, 138 deletions(-) delete mode 100644 TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/adpater/UserTagHistoryCommandAdapter.java delete mode 100644 TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/adpater/UserTagHistoryQueryAdapter.java delete mode 100644 TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/domain/UserTagHistory.java delete mode 100644 TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/port/UserTagHistoryCommandPort.java delete mode 100644 TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/port/UserTagHistoryQueryPort.java delete mode 100644 TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/repository/UserTagHistoryRepository.java delete mode 100644 TodaysFail-Interface/src/main/java/com/todaysfail/api/web/tag/usecase/UserTagHistoryQueryUseCase.java diff --git a/TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/adpater/UserTagHistoryCommandAdapter.java b/TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/adpater/UserTagHistoryCommandAdapter.java deleted file mode 100644 index a646152..0000000 --- a/TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/adpater/UserTagHistoryCommandAdapter.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.todaysfail.domains.usertaghistory.adpater; - -import com.todaysfail.common.annotation.Adapter; -import com.todaysfail.domains.usertaghistory.domain.UserTagHistory; -import com.todaysfail.domains.usertaghistory.port.UserTagHistoryCommandPort; -import com.todaysfail.domains.usertaghistory.repository.UserTagHistoryRepository; -import lombok.RequiredArgsConstructor; - -@Adapter -@RequiredArgsConstructor -public class UserTagHistoryCommandAdapter implements UserTagHistoryCommandPort { - private final UserTagHistoryRepository userTagHistoryRepository; - - @Override - public UserTagHistory save(UserTagHistory userTagHistory) { - return userTagHistoryRepository.save(userTagHistory); - } -} diff --git a/TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/adpater/UserTagHistoryQueryAdapter.java b/TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/adpater/UserTagHistoryQueryAdapter.java deleted file mode 100644 index ac1c24e..0000000 --- a/TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/adpater/UserTagHistoryQueryAdapter.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.todaysfail.domains.usertaghistory.adpater; - -import com.todaysfail.common.annotation.Adapter; -import com.todaysfail.domains.usertaghistory.domain.UserTagHistory; -import com.todaysfail.domains.usertaghistory.port.UserTagHistoryQueryPort; -import com.todaysfail.domains.usertaghistory.repository.UserTagHistoryRepository; -import java.util.List; -import lombok.RequiredArgsConstructor; - -@Adapter -@RequiredArgsConstructor -public class UserTagHistoryQueryAdapter implements UserTagHistoryQueryPort { - private final UserTagHistoryRepository userTagHistoryRepository; - - @Override - public List queryUserTagHistory(Long userId) { - return userTagHistoryRepository.findTop5ByUserIdOrderByCreatedAtDesc(userId); - } -} diff --git a/TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/domain/UserTagHistory.java b/TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/domain/UserTagHistory.java deleted file mode 100644 index 273c7de..0000000 --- a/TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/domain/UserTagHistory.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.todaysfail.domains.usertaghistory.domain; - -import com.todaysfail.common.BaseTimeEntity; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@Builder -@Entity(name = "tbl_user_tag_history") -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class UserTagHistory extends BaseTimeEntity { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "user_tag_history_id") - private Long id; - - private Long userId; - - private Long tagId; - - public static UserTagHistory registerUserTagHistory(Long userId, Long tagId) { - return new UserTagHistory(null, userId, tagId); - } -} diff --git a/TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/port/UserTagHistoryCommandPort.java b/TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/port/UserTagHistoryCommandPort.java deleted file mode 100644 index 8839311..0000000 --- a/TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/port/UserTagHistoryCommandPort.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.todaysfail.domains.usertaghistory.port; - -import com.todaysfail.domains.usertaghistory.domain.UserTagHistory; - -public interface UserTagHistoryCommandPort { - UserTagHistory save(UserTagHistory userTagHistory); -} diff --git a/TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/port/UserTagHistoryQueryPort.java b/TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/port/UserTagHistoryQueryPort.java deleted file mode 100644 index a22ce4c..0000000 --- a/TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/port/UserTagHistoryQueryPort.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.todaysfail.domains.usertaghistory.port; - -import com.todaysfail.domains.usertaghistory.domain.UserTagHistory; -import java.util.List; - -public interface UserTagHistoryQueryPort { - List queryUserTagHistory(Long userId); -} diff --git a/TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/repository/UserTagHistoryRepository.java b/TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/repository/UserTagHistoryRepository.java deleted file mode 100644 index b827d8e..0000000 --- a/TodaysFail-Domain/src/main/java/com/todaysfail/domains/usertaghistory/repository/UserTagHistoryRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.todaysfail.domains.usertaghistory.repository; - -import com.todaysfail.domains.usertaghistory.domain.UserTagHistory; -import java.util.List; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface UserTagHistoryRepository extends JpaRepository { - List findTop5ByUserIdOrderByCreatedAtDesc(Long userId); -} diff --git a/TodaysFail-Interface/src/main/java/com/todaysfail/api/web/failure/usecase/FailureRegisterUseCase.java b/TodaysFail-Interface/src/main/java/com/todaysfail/api/web/failure/usecase/FailureRegisterUseCase.java index f5e835b..a9ec498 100644 --- a/TodaysFail-Interface/src/main/java/com/todaysfail/api/web/failure/usecase/FailureRegisterUseCase.java +++ b/TodaysFail-Interface/src/main/java/com/todaysfail/api/web/failure/usecase/FailureRegisterUseCase.java @@ -11,8 +11,6 @@ import com.todaysfail.domains.failure.service.FailureDomainService; import com.todaysfail.domains.tag.domain.Tag; import com.todaysfail.domains.tag.service.TagDomainService; -import com.todaysfail.domains.usertaghistory.domain.UserTagHistory; -import com.todaysfail.domains.usertaghistory.port.UserTagHistoryCommandPort; import java.util.List; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; @@ -25,7 +23,6 @@ public class FailureRegisterUseCase { private final CategoryQueryPort categoryQueryPort; private final FailureDomainService failureDomainService; private final TagDomainService tagDomainService; - private final UserTagHistoryCommandPort userTagHistoryCommandPort; @Transactional public FailureResponse execute(FailureRegisterRequest request) { @@ -44,9 +41,6 @@ public FailureResponse execute(FailureRegisterRequest request) { .secret(request.secret()) .build(); Failure registeredFailure = failureDomainService.register(failure, category, tags); - tags.stream() - .map(tag -> UserTagHistory.registerUserTagHistory(currentUserId, tag.getId())) - .forEach(userTagHistoryCommandPort::save); return failureMapper.toFailureResponse(registeredFailure); } } diff --git a/TodaysFail-Interface/src/main/java/com/todaysfail/api/web/tag/TagController.java b/TodaysFail-Interface/src/main/java/com/todaysfail/api/web/tag/TagController.java index 9c5eeaa..32d8bf1 100644 --- a/TodaysFail-Interface/src/main/java/com/todaysfail/api/web/tag/TagController.java +++ b/TodaysFail-Interface/src/main/java/com/todaysfail/api/web/tag/TagController.java @@ -3,7 +3,6 @@ import com.todaysfail.api.web.tag.dto.response.TagResponse; import com.todaysfail.api.web.tag.usecase.TagPopularUseCase; import com.todaysfail.api.web.tag.usecase.TagSearchUseCase; -import com.todaysfail.api.web.tag.usecase.UserTagHistoryQueryUseCase; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; @@ -22,7 +21,6 @@ public class TagController { private final TagSearchUseCase tagSearchUseCase; private final TagPopularUseCase tagPopularUseCase; - private final UserTagHistoryQueryUseCase userTagHistoryQueryUseCase; @Operation(summary = "태그를 검색합니다. (5개)") @GetMapping("/search") @@ -39,10 +37,4 @@ public List popular() { // @Operation(summary = "추천 태그를 조회합니다.") // @GetMapping("/recommend") // TODO: 추천 태그 조회 API 구현 - - @Operation(summary = "유저 태그 히스토리를 조회합니다. (5개)") - @GetMapping("/history") - public List userTagHistory() { - return userTagHistoryQueryUseCase.execute(); - } } diff --git a/TodaysFail-Interface/src/main/java/com/todaysfail/api/web/tag/usecase/UserTagHistoryQueryUseCase.java b/TodaysFail-Interface/src/main/java/com/todaysfail/api/web/tag/usecase/UserTagHistoryQueryUseCase.java deleted file mode 100644 index 7d9c8df..0000000 --- a/TodaysFail-Interface/src/main/java/com/todaysfail/api/web/tag/usecase/UserTagHistoryQueryUseCase.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.todaysfail.api.web.tag.usecase; - -import com.todaysfail.api.web.tag.dto.response.TagResponse; -import com.todaysfail.api.web.tag.mapper.TagMapper; -import com.todaysfail.common.annotation.UseCase; -import com.todaysfail.config.security.SecurityUtils; -import com.todaysfail.domains.tag.domain.Tag; -import com.todaysfail.domains.tag.port.TagQueryPort; -import com.todaysfail.domains.usertaghistory.domain.UserTagHistory; -import com.todaysfail.domains.usertaghistory.port.UserTagHistoryQueryPort; -import java.util.List; -import lombok.RequiredArgsConstructor; - -@UseCase -@RequiredArgsConstructor -public class UserTagHistoryQueryUseCase { - private final TagMapper tagMapper; - private final UserTagHistoryQueryPort userTagHistoryQueryPort; - private final TagQueryPort tagQueryPort; - - public List execute() { - final Long userId = SecurityUtils.getCurrentUserId(); - List userTagHistories = userTagHistoryQueryPort.queryUserTagHistory(userId); - List tags = - tagQueryPort.queryAllByIds( - userTagHistories.stream().map(UserTagHistory::getTagId).toList()); - return tagMapper.toTagResponseList(tags); - } -}