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() { } - - - }