Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : 구독 후 구독자 수 리턴 #27

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -13,6 +14,8 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Transactional
@RequiredArgsConstructor
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,8 @@ public List<SubscribeIssueFeignRes> getMySubscribeList(Member member) {
);
return mySubscribeList;
}

public Long getSubscribers(Long issueId) {
return subscribeRepository.findSubscribeCountsByIssue(issueId);
}
}