From fc99655d30e3b48696362d5523ca02bc850c7aad Mon Sep 17 00:00:00 2001 From: seungyeonnnnnni Date: Wed, 22 Nov 2023 23:13:29 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=EA=B5=AC=EB=8F=85=20=ED=9B=84=20?= =?UTF-8?q?=EA=B5=AC=EB=8F=85=EC=9E=90=20=EC=88=98=20=EB=A6=AC=ED=84=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/MemberCustomRepositoryImpl.java | 3 ++- .../domain/subscribe/application/dto/res/SubscribeRes.java | 7 +++++-- .../subscribe/application/service/SubscribeUseCase.java | 5 ++++- .../subscribe/application/service/UnSubscribeUseCase.java | 3 +-- .../subscribe/domain/service/SubscribeQueryService.java | 4 ++++ 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/gwangjang/server/domain/member/domain/repository/MemberCustomRepositoryImpl.java b/src/main/java/gwangjang/server/domain/member/domain/repository/MemberCustomRepositoryImpl.java index e969693..856af2f 100644 --- a/src/main/java/gwangjang/server/domain/member/domain/repository/MemberCustomRepositoryImpl.java +++ b/src/main/java/gwangjang/server/domain/member/domain/repository/MemberCustomRepositoryImpl.java @@ -3,8 +3,9 @@ import com.querydsl.jpa.impl.JPAQueryFactory; import jakarta.persistence.EntityManager; -import static gwangjang.server.domain.member.domain.entity.QMember.member; +import gwangjang.server.domain.member.domain.entity.QMember; +import static gwangjang.server.domain.member.domain.entity.QMember.member; public class MemberCustomRepositoryImpl implements MemberCustomRepository { diff --git a/src/main/java/gwangjang/server/domain/subscribe/application/dto/res/SubscribeRes.java b/src/main/java/gwangjang/server/domain/subscribe/application/dto/res/SubscribeRes.java index a8e6c36..0a86911 100644 --- a/src/main/java/gwangjang/server/domain/subscribe/application/dto/res/SubscribeRes.java +++ b/src/main/java/gwangjang/server/domain/subscribe/application/dto/res/SubscribeRes.java @@ -13,14 +13,17 @@ public class SubscribeRes { private Long issueId; private boolean status; + private Long subscribers; - public SubscribeRes setUnScribe() { + public SubscribeRes setUnScribe(Long subscribers) { this.status = Boolean.FALSE; + this.subscribers = subscribers; return this; } - public SubscribeRes setSubscribe() { + public SubscribeRes setSubscribe(Long subscribers) { this.status = Boolean.TRUE; + this.subscribers = subscribers; return this; } 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 6b07ebe..2c180a3 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 @@ -2,6 +2,7 @@ import gwangjang.server.domain.member.domain.entity.Member; import gwangjang.server.domain.member.domain.service.MemberQueryService; +import gwangjang.server.domain.subscribe.application.dto.res.IssueBySubscribersRes; import gwangjang.server.domain.subscribe.application.dto.res.SubscribeMemberDto; import gwangjang.server.domain.subscribe.application.dto.res.SubscribeRes; import gwangjang.server.domain.subscribe.application.mapper.SubscribeMapper; @@ -13,6 +14,8 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.util.List; + @Service @Transactional @RequiredArgsConstructor @@ -29,7 +32,7 @@ public SubscribeRes subscribe(String socialId,Long topicId, Long issueId) { if (subscribeQueryService.isAbleToSubscribe(member)) { Subscribe save = subscribeSaveService.save(subscribeMapper.mapToSubscribe(member, issueId)); - return subscribeMapper.mapToSubscribeRes(save).setSubscribe(); + return subscribeMapper.mapToSubscribeRes(save).setSubscribe(subscribeQueryService.getSubscribers(issueId)); }else{ throw new NoAccessSubscribe(); diff --git a/src/main/java/gwangjang/server/domain/subscribe/application/service/UnSubscribeUseCase.java b/src/main/java/gwangjang/server/domain/subscribe/application/service/UnSubscribeUseCase.java index fef444b..3279fcb 100644 --- a/src/main/java/gwangjang/server/domain/subscribe/application/service/UnSubscribeUseCase.java +++ b/src/main/java/gwangjang/server/domain/subscribe/application/service/UnSubscribeUseCase.java @@ -28,7 +28,6 @@ public SubscribeRes unSubscribe(String socialId, Long topicId, Long issueId) { Member member = memberQueryService.getMemberBySocialId(socialId); Subscribe subscribe = subscribeQueryService.findSubscribeByMemberAndTopic(member, topicId,issueId); subscribeDeleteService.delete(subscribe); - - return subscribeMapper.mapToSubscribeRes(subscribe).setUnScribe(); + return subscribeMapper.mapToSubscribeRes(subscribe).setUnScribe(subscribeQueryService.getSubscribers(issueId)); } } 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 936e347..6737e55 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 @@ -107,4 +107,8 @@ public List getMySubscribeList(Member member) { ); return mySubscribeList; } + + public Long getSubscribers(Long issueId) { + return subscribeRepository.findSubscribeCountsByIssue(issueId); + } }