From c7822d5be4616f002af65ad1016897a6e8890400 Mon Sep 17 00:00:00 2001 From: seungyeonnnnnni Date: Thu, 23 Nov 2023 19:59:35 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=EA=B5=AC=EB=8F=85=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subscribe/application/service/SubscribeUseCase.java | 8 ++++++++ .../domain/repository/SubscribeCustomRepository.java | 1 + .../domain/repository/SubscribeCustomRepositoryImpl.java | 7 ++++++- .../subscribe/domain/service/SubscribeQueryService.java | 3 --- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/gwangjang/server/domain/subscribe/application/service/SubscribeUseCase.java b/src/main/java/gwangjang/server/domain/subscribe/application/service/SubscribeUseCase.java index 9e2dcef..cb04f98 100644 --- a/src/main/java/gwangjang/server/domain/subscribe/application/service/SubscribeUseCase.java +++ b/src/main/java/gwangjang/server/domain/subscribe/application/service/SubscribeUseCase.java @@ -34,7 +34,15 @@ public SubscribeRes subscribe(String socialId,Long topicId, Long issueId) { Member member = memberQueryService.getMemberBySocialId(socialId); if (subscribeQueryService.isAbleToSubscribe(member)) { + + if (member.getSubscribeList().stream() + .anyMatch(subscribe -> subscribe.getIssueId().equals(issueId))) { + + throw new NoAccessSubscribe(); + + } Subscribe save = subscribeSaveService.save(subscribeMapper.mapToSubscribe(member, issueId)); + member.getSubscribeList().add(save); // publishSubscribeChange.publishMemberChange(); diff --git a/src/main/java/gwangjang/server/domain/subscribe/domain/repository/SubscribeCustomRepository.java b/src/main/java/gwangjang/server/domain/subscribe/domain/repository/SubscribeCustomRepository.java index b55bc87..2953e76 100644 --- a/src/main/java/gwangjang/server/domain/subscribe/domain/repository/SubscribeCustomRepository.java +++ b/src/main/java/gwangjang/server/domain/subscribe/domain/repository/SubscribeCustomRepository.java @@ -24,4 +24,5 @@ public interface SubscribeCustomRepository { + } diff --git a/src/main/java/gwangjang/server/domain/subscribe/domain/repository/SubscribeCustomRepositoryImpl.java b/src/main/java/gwangjang/server/domain/subscribe/domain/repository/SubscribeCustomRepositoryImpl.java index b8e166a..8d7b2b2 100644 --- a/src/main/java/gwangjang/server/domain/subscribe/domain/repository/SubscribeCustomRepositoryImpl.java +++ b/src/main/java/gwangjang/server/domain/subscribe/domain/repository/SubscribeCustomRepositoryImpl.java @@ -51,7 +51,7 @@ public SubscribeMemberDto findAllSubscribeByMember(Member member) { .fetchOne(); } - public Subscribe findSubscribeByMemberAndTopic(Member member,Long issueId) { + public Subscribe findSubscribeByMemberAndTopic(Member member, Long issueId) { return queryFactory .select(subscribe) .from(subscribe) @@ -114,4 +114,9 @@ public List getIssueBySubscribers() { } + + } + + + diff --git a/src/main/java/gwangjang/server/domain/subscribe/domain/service/SubscribeQueryService.java b/src/main/java/gwangjang/server/domain/subscribe/domain/service/SubscribeQueryService.java index 7f6d833..19b5eba 100644 --- a/src/main/java/gwangjang/server/domain/subscribe/domain/service/SubscribeQueryService.java +++ b/src/main/java/gwangjang/server/domain/subscribe/domain/service/SubscribeQueryService.java @@ -121,7 +121,4 @@ public List getIssueBySubscribers() { } - - - }