diff --git a/build.gradle b/build.gradle index f2e929b..9bad213 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ plugins { id 'java' id 'org.springframework.boot' version '3.0.11' id 'io.spring.dependency-management' version '1.1.3' + } group = 'gwangjang' @@ -100,3 +101,18 @@ bootJar{ archiveVersion = "0.0.1" } +// === Querydsl 빌드 옵션 (선택사항) === + +def querydslDir = "src/main/generated/querydsl" + +sourceSets { + main.java.srcDirs += [ querydslDir ] +} + +tasks.withType(JavaCompile) { + options.annotationProcessorGeneratedSourcesDirectory = file(querydslDir) +} + +clean.doLast { + file(querydslDir).deleteDir() +} \ No newline at end of file diff --git a/src/main/java/gwangjang/server/MemberServiceApplication.java b/src/main/java/gwangjang/server/MemberServiceApplication.java index 4b18cbf..bf4adb7 100644 --- a/src/main/java/gwangjang/server/MemberServiceApplication.java +++ b/src/main/java/gwangjang/server/MemberServiceApplication.java @@ -6,6 +6,8 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.FeignAutoConfiguration; +import org.springframework.cloud.stream.annotation.EnableBinding; +import org.springframework.cloud.stream.messaging.Source; import org.springframework.context.annotation.ComponentScan; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.web.bind.annotation.CrossOrigin; diff --git a/src/main/java/gwangjang/server/domain/auth/application/mapper/MemberMapper.java b/src/main/java/gwangjang/server/domain/auth/application/mapper/MemberMapper.java index 5c440ec..475f9ae 100644 --- a/src/main/java/gwangjang/server/domain/auth/application/mapper/MemberMapper.java +++ b/src/main/java/gwangjang/server/domain/auth/application/mapper/MemberMapper.java @@ -39,6 +39,7 @@ public Member createLocalMember(LocalSignUpRequest localSignUpRequest) { .gender(localSignUpRequest.getGender()) .loginId(localSignUpRequest.getId()) .loginPw(localSignUpRequest.getPw()) + .profileImage("https://gwang-jang.s3.ap-northeast-2.amazonaws.com/%EA%B8%B0%EB%B3%B8%ED%94%84%EB%A1%9C%ED%95%84.png") .build(); } diff --git a/src/main/java/gwangjang/server/domain/member/adapter/consumer/message/CommunityChannels.java b/src/main/java/gwangjang/server/domain/member/adapter/consumer/message/CommunityChannels.java deleted file mode 100644 index 2a21f8b..0000000 --- a/src/main/java/gwangjang/server/domain/member/adapter/consumer/message/CommunityChannels.java +++ /dev/null @@ -1,44 +0,0 @@ -package gwangjang.server.domain.member.adapter.consumer.message; -import gwangjang.server.domain.auth.application.mapper.MemberMapper; -import gwangjang.server.global.feign.dto.response.MemberDto; -import gwangjang.server.domain.member.domain.entity.Member; -import gwangjang.server.domain.member.domain.service.MemberQueryService; -import lombok.RequiredArgsConstructor; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.util.function.Function; - -@Configuration -@RequiredArgsConstructor -public class CommunityChannels { - - private final MemberQueryService memberQueryService; - private final MemberMapper memberMapper; - -// @Bean -// public Function uppercase() { // 메시지를 받아 처리한 후 결과를 반환 -// return message -> { -// // 메시지 처리 로직 -// return message.toUpperCase(); -// }; -//} -// @Bean -// public Consumer receiveFromCommunity(Long memberId) { //메시지를 받아 처리하는 데 사용되지만 반환 값이 없 -// return message -> { -// // 메시지 처리 로직 ( 역직렬화 ) -// System.out.println("Member Received: " + message); -// }; -// } - - @Bean - public Function receiveFromCommunity() { - return memberId -> { - // memberId를 사용하여 Member 객체를 조회 - Member member = memberQueryService.getMemberBySocialId(memberId); - - return memberMapper.mapToMemberDto(member); - - }; - } -} diff --git a/src/main/java/gwangjang/server/domain/member/adapter/consumer/message/model/CommunityCustomDeserializer.java b/src/main/java/gwangjang/server/domain/member/adapter/consumer/message/model/CommunityCustomDeserializer.java deleted file mode 100644 index e283870..0000000 --- a/src/main/java/gwangjang/server/domain/member/adapter/consumer/message/model/CommunityCustomDeserializer.java +++ /dev/null @@ -1,43 +0,0 @@ -package gwangjang.server.domain.member.adapter.consumer.message.model; - -import com.fasterxml.jackson.databind.ObjectMapper; -import gwangjang.server.global.feign.dto.response.MemberDto; -import lombok.RequiredArgsConstructor; -import org.apache.kafka.common.header.Headers; -import org.apache.kafka.common.serialization.Deserializer; - -import java.util.Map; - -@RequiredArgsConstructor -public class CommunityCustomDeserializer implements Deserializer { - - private final ObjectMapper objectMapper; - - @Override - public void configure(Map configs, boolean isKey) { - Deserializer.super.configure(configs, isKey); - } - - @Override - public MemberDto deserialize(String topic, byte[] data) { - if (data == null) { - return null; - } - - try { - return objectMapper.readValue(data, MemberDto.class); - } catch (Exception e) { - throw new RuntimeException("Deserialization error: " + e.getMessage(), e); - } - } - - @Override - public MemberDto deserialize(String topic, Headers headers, byte[] data) { - return Deserializer.super.deserialize(topic, headers, data); - } - - @Override - public void close() { - Deserializer.super.close(); - } -} diff --git a/src/main/java/gwangjang/server/domain/member/adapter/producer/message/MemberChannels.java b/src/main/java/gwangjang/server/domain/member/adapter/producer/message/MemberChannels.java deleted file mode 100644 index ee916fb..0000000 --- a/src/main/java/gwangjang/server/domain/member/adapter/producer/message/MemberChannels.java +++ /dev/null @@ -1,27 +0,0 @@ -package gwangjang.server.domain.member.adapter.producer.message; -import gwangjang.server.global.feign.dto.response.MemberDto; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.messaging.Message; -import org.springframework.messaging.support.MessageBuilder; - -import java.util.function.Supplier; - -@Slf4j -@Configuration -public class MemberChannels { - - @Bean - public Supplier> sendToCommunity() { // 메시지를 주기적으로 생성하고 보내는 데 사용 - return () -> { - - log.info("send To Community !!!!"); - // 메시지 생성 로직 - MemberDto memberInfo = new MemberDto("LOCAL-323","nickname", "https://img"); - // dto to string - return MessageBuilder.withPayload(memberInfo).build(); - }; - } - -} 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/adapter/PublishSubscribeChange.java b/src/main/java/gwangjang/server/domain/subscribe/adapter/PublishSubscribeChange.java new file mode 100644 index 0000000..8f29a64 --- /dev/null +++ b/src/main/java/gwangjang/server/domain/subscribe/adapter/PublishSubscribeChange.java @@ -0,0 +1,26 @@ +//package gwangjang.server.domain.subscribe.adapter; +// +//import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribeData; +//import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribersByIssueDto; +//import gwangjang.server.domain.subscribe.application.service.SubscribeReadUseCase; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.cloud.stream.messaging.Source; +//import org.springframework.messaging.support.MessageBuilder; +//import org.springframework.stereotype.Component; +// +//import java.util.List; +// +//@Component +//public class PublishSubscribeChange { +// +// @Autowired +// private Source source; +// @Autowired +// private SubscribeReadUseCase subscribeReadUseCase; +// +// public void publishMemberChange() { +// List allIssueBySubscribers = subscribeReadUseCase.getAllIssueBySubscribers(); +// +// source.output().send(MessageBuilder.withPayload(allIssueBySubscribers).build()); +// } +//} diff --git a/src/main/java/gwangjang/server/domain/subscribe/adapter/consumer/message/KeywordChannels.java b/src/main/java/gwangjang/server/domain/subscribe/adapter/consumer/message/KeywordChannels.java new file mode 100644 index 0000000..2cf3131 --- /dev/null +++ b/src/main/java/gwangjang/server/domain/subscribe/adapter/consumer/message/KeywordChannels.java @@ -0,0 +1,53 @@ +//package gwangjang.server.domain.subscribe.adapter.consumer.message; +//import gwangjang.server.domain.auth.application.mapper.MemberMapper; +//import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribeData; +//import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribersByIssueDto; +//import gwangjang.server.global.feign.dto.response.MemberDto; +//import gwangjang.server.domain.member.domain.entity.Member; +//import gwangjang.server.domain.member.domain.service.MemberQueryService; +//import lombok.RequiredArgsConstructor; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +// +//import java.util.List; +//import java.util.function.Consumer; +//import java.util.function.Function; +// +//@Configuration +//@RequiredArgsConstructor +//public class KeywordChannels { +// +// private final MemberQueryService memberQueryService; +// private final MemberMapper memberMapper; +// +//// @Bean +//// public Function uppercase() { // 메시지를 받아 처리한 후 결과를 반환 +//// return message -> { +//// // 메시지 처리 로직 +//// return message.toUpperCase(); +//// }; +////} +// @Bean +// public Consumer> receiveFromKeyword() { //메시지를 받아 처리하는 데 사용되지만 반환 값이 없 +// return message -> { +// // 메시지 처리 로직 ( 역직렬화 ) +//// System.out.println("Member Received: " + message); +// +// +// System.out.println("hihi"+message); +// }; +// } +// +//// @Bean +//// public Function receiveFromKeyword() { +//// return memberId -> { +//// // memberId를 사용하여 Member 객체를 조회 +//// +//// +//// Member member = memberQueryService.getMemberBySocialId(memberId); +//// +//// return memberMapper.mapToMemberDto(member); +//// +//// }; +//// } +//} diff --git a/src/main/java/gwangjang/server/domain/subscribe/adapter/consumer/message/model/KeywordCustomDeserializer.java b/src/main/java/gwangjang/server/domain/subscribe/adapter/consumer/message/model/KeywordCustomDeserializer.java new file mode 100644 index 0000000..5c16323 --- /dev/null +++ b/src/main/java/gwangjang/server/domain/subscribe/adapter/consumer/message/model/KeywordCustomDeserializer.java @@ -0,0 +1,43 @@ +//package gwangjang.server.domain.subscribe.adapter.consumer.message.model; +// +//import com.fasterxml.jackson.databind.ObjectMapper; +//import gwangjang.server.global.feign.dto.response.MemberDto; +//import lombok.RequiredArgsConstructor; +//import org.apache.kafka.common.header.Headers; +//import org.apache.kafka.common.serialization.Deserializer; +// +//import java.util.Map; +// +//@RequiredArgsConstructor +//public class KeywordCustomDeserializer implements Deserializer { +// +// private final ObjectMapper objectMapper; +// +// @Override +// public void configure(Map configs, boolean isKey) { +// Deserializer.super.configure(configs, isKey); +// } +// +// @Override +// public MemberDto deserialize(String topic, byte[] data) { +// if (data == null) { +// return null; +// } +// +// try { +// return objectMapper.readValue(data, MemberDto.class); +// } catch (Exception e) { +// throw new RuntimeException("Deserialization error: " + e.getMessage(), e); +// } +// } +// +// @Override +// public MemberDto deserialize(String topic, Headers headers, byte[] data) { +// return Deserializer.super.deserialize(topic, headers, data); +// } +// +// @Override +// public void close() { +// Deserializer.super.close(); +// } +//} diff --git a/src/main/java/gwangjang/server/domain/member/adapter/producer/client/KafkaConsumer.java b/src/main/java/gwangjang/server/domain/subscribe/adapter/producer/client/KafkaConsumer.java similarity index 86% rename from src/main/java/gwangjang/server/domain/member/adapter/producer/client/KafkaConsumer.java rename to src/main/java/gwangjang/server/domain/subscribe/adapter/producer/client/KafkaConsumer.java index 61ee6a4..37f74d1 100644 --- a/src/main/java/gwangjang/server/domain/member/adapter/producer/client/KafkaConsumer.java +++ b/src/main/java/gwangjang/server/domain/subscribe/adapter/producer/client/KafkaConsumer.java @@ -1,4 +1,4 @@ -package gwangjang.server.domain.member.adapter.producer.client;//package gwangjang.server.domain.adapter.out.client; +package gwangjang.server.domain.subscribe.adapter.producer.client;//package gwangjang.server.domain.adapter.out.client; // //import gwangjang.server.domain.domain.repository.CommunityRepository; //import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/gwangjang/server/domain/member/adapter/producer/client/KafkaConsumerConfig.java b/src/main/java/gwangjang/server/domain/subscribe/adapter/producer/client/KafkaConsumerConfig.java similarity index 94% rename from src/main/java/gwangjang/server/domain/member/adapter/producer/client/KafkaConsumerConfig.java rename to src/main/java/gwangjang/server/domain/subscribe/adapter/producer/client/KafkaConsumerConfig.java index 78a6bda..e91f8d8 100644 --- a/src/main/java/gwangjang/server/domain/member/adapter/producer/client/KafkaConsumerConfig.java +++ b/src/main/java/gwangjang/server/domain/subscribe/adapter/producer/client/KafkaConsumerConfig.java @@ -1,4 +1,4 @@ -package gwangjang.server.domain.member.adapter.producer.client;//package gwangjang.server.domain.adapter.out.client; +package gwangjang.server.domain.subscribe.adapter.producer.client;//package gwangjang.server.domain.adapter.out.client; // // //import org.apache.kafka.clients.consumer.ConsumerConfig; diff --git a/src/main/java/gwangjang/server/domain/subscribe/adapter/producer/message/SubscribeChannels.java b/src/main/java/gwangjang/server/domain/subscribe/adapter/producer/message/SubscribeChannels.java new file mode 100644 index 0000000..c3e629d --- /dev/null +++ b/src/main/java/gwangjang/server/domain/subscribe/adapter/producer/message/SubscribeChannels.java @@ -0,0 +1,39 @@ +//package gwangjang.server.domain.subscribe.adapter.producer.message; +//import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribeData; +//import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribersByIssueDto; +//import gwangjang.server.domain.subscribe.application.service.SubscribeReadUseCase; +//import gwangjang.server.global.feign.dto.response.MemberDto; +//import lombok.RequiredArgsConstructor; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +//import org.springframework.messaging.Message; +//import org.springframework.messaging.support.MessageBuilder; +// +//import java.util.List; +//import java.util.function.Supplier; +// +//@Slf4j +//@Configuration +//@RequiredArgsConstructor +//public class SubscribeChannels { +// +// private final SubscribeReadUseCase subscribeReadUseCase; +// +// @Bean +// public Supplier>> sendToKeyword() { // 메시지를 주기적으로 생성하고 보내는 데 사용 +// return () -> { +// +// log.info("send To Keyword !!!!"); +// +// +// List allIssueBySubscribers = subscribeReadUseCase.getAllIssueBySubscribers(); +// // 메시지 생성 로직 +//// MemberDto memberInfo = new MemberDto("LOCAL-323","nickname", "https://img"); +// // dto to string +// return MessageBuilder.withPayload(allIssueBySubscribers).build(); +// }; +// } +// +//} diff --git a/src/main/java/gwangjang/server/domain/subscribe/adapter/producer/web/dto/MainBubbleData.java b/src/main/java/gwangjang/server/domain/subscribe/adapter/producer/web/dto/MainBubbleData.java new file mode 100644 index 0000000..e4914e5 --- /dev/null +++ b/src/main/java/gwangjang/server/domain/subscribe/adapter/producer/web/dto/MainBubbleData.java @@ -0,0 +1,14 @@ +package gwangjang.server.domain.subscribe.adapter.producer.web.dto; + +import lombok.*; + +@Setter +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MainBubbleData { + private String name; + private Long value; +} + diff --git a/src/main/java/gwangjang/server/domain/subscribe/adapter/producer/web/dto/MainBubbleRes.java b/src/main/java/gwangjang/server/domain/subscribe/adapter/producer/web/dto/MainBubbleRes.java new file mode 100644 index 0000000..a47001a --- /dev/null +++ b/src/main/java/gwangjang/server/domain/subscribe/adapter/producer/web/dto/MainBubbleRes.java @@ -0,0 +1,15 @@ +package gwangjang.server.domain.subscribe.adapter.producer.web.dto; + +import lombok.*; + +import java.util.List; + +@Setter +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MainBubbleRes { + private String name; + private List data; +} \ No newline at end of file diff --git a/src/main/java/gwangjang/server/domain/subscribe/adapter/producer/web/dto/SubscribeData.java b/src/main/java/gwangjang/server/domain/subscribe/adapter/producer/web/dto/SubscribeData.java new file mode 100644 index 0000000..516a9ed --- /dev/null +++ b/src/main/java/gwangjang/server/domain/subscribe/adapter/producer/web/dto/SubscribeData.java @@ -0,0 +1,13 @@ +package gwangjang.server.domain.subscribe.adapter.producer.web.dto; + +import lombok.*; + +@Setter +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SubscribeData { + private Long issueId; + private Long count; +} diff --git a/src/main/java/gwangjang/server/domain/subscribe/adapter/producer/web/dto/SubscribersByIssueDto.java b/src/main/java/gwangjang/server/domain/subscribe/adapter/producer/web/dto/SubscribersByIssueDto.java new file mode 100644 index 0000000..7e094ae --- /dev/null +++ b/src/main/java/gwangjang/server/domain/subscribe/adapter/producer/web/dto/SubscribersByIssueDto.java @@ -0,0 +1,19 @@ +package gwangjang.server.domain.subscribe.adapter.producer.web.dto; + +import lombok.*; + +import java.util.List; + +@Setter +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SubscribersByIssueDto { + + private List data; +} + + + + 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/SubscribeReadUseCase.java b/src/main/java/gwangjang/server/domain/subscribe/application/service/SubscribeReadUseCase.java index 031ba21..ed2f10b 100644 --- a/src/main/java/gwangjang/server/domain/subscribe/application/service/SubscribeReadUseCase.java +++ b/src/main/java/gwangjang/server/domain/subscribe/application/service/SubscribeReadUseCase.java @@ -1,5 +1,7 @@ package gwangjang.server.domain.subscribe.application.service; +import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribeData; +import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribersByIssueDto; import gwangjang.server.domain.subscribe.application.dto.res.IssueBySubscribersRes; import gwangjang.server.domain.subscribe.application.dto.res.IssueBySubscribeRecommendRes; import gwangjang.server.domain.subscribe.application.dto.res.IssueSubscribeInfoRes; @@ -28,5 +30,10 @@ public IssueSubscribeInfoRes getSubscribeIssueInfo(Long issueId) { return subscribeQueryService.getIssueInfo(issueId); } + public List getAllIssueBySubscribers() { + return subscribeQueryService.getIssueBySubscribers(); + } + + } 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..9e2dcef 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 @@ -24,12 +27,18 @@ public class SubscribeUseCase { private final SubscribeMapper subscribeMapper = new SubscribeMapper(); +// private final PublishSubscribeChange publishSubscribeChange; + + public SubscribeRes subscribe(String socialId,Long topicId, Long issueId) { Member member = memberQueryService.getMemberBySocialId(socialId); if (subscribeQueryService.isAbleToSubscribe(member)) { Subscribe save = subscribeSaveService.save(subscribeMapper.mapToSubscribe(member, issueId)); - return subscribeMapper.mapToSubscribeRes(save).setSubscribe(); + +// publishSubscribeChange.publishMemberChange(); + + 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/repository/SubscribeCustomRepository.java b/src/main/java/gwangjang/server/domain/subscribe/domain/repository/SubscribeCustomRepository.java index 48d36b0..b55bc87 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 @@ -1,6 +1,9 @@ package gwangjang.server.domain.subscribe.domain.repository; import gwangjang.server.domain.member.domain.entity.Member; +import gwangjang.server.domain.subscribe.adapter.producer.web.dto.MainBubbleRes; +import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribeData; +import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribersByIssueDto; import gwangjang.server.domain.subscribe.application.dto.res.IssueBySubscribersRes; import gwangjang.server.domain.subscribe.application.dto.res.SubscribeIssueFeignRes; import gwangjang.server.domain.subscribe.application.dto.res.SubscribeMemberDto; @@ -17,6 +20,8 @@ public interface SubscribeCustomRepository { Long findSubscribeCountsByIssue(Long issueId); List findMySubscribeList(Member member); + List getIssueBySubscribers(); + } 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 3ba3e6d..b8e166a 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 @@ -5,6 +5,9 @@ import com.querydsl.jpa.impl.JPAQueryFactory; import gwangjang.server.domain.member.domain.entity.Member; import gwangjang.server.domain.member.domain.entity.QMember; +import gwangjang.server.domain.subscribe.adapter.producer.web.dto.MainBubbleRes; +import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribeData; +import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribersByIssueDto; import gwangjang.server.domain.subscribe.application.dto.res.IssueBySubscribersRes; import gwangjang.server.domain.subscribe.application.dto.res.SubscribeIssueFeignRes; import gwangjang.server.domain.subscribe.application.dto.res.SubscribeMemberDto; @@ -96,4 +99,19 @@ public List findMySubscribeList(Member member) { .fetch(); } + public List getIssueBySubscribers() { + + return queryFactory + .select(Projections.constructor(SubscribeData.class, + subscribe.issueId, + subscribe.member.count() + )) + .from(subscribe) + .groupBy(subscribe.issueId) + .orderBy(subscribe.member.count().desc()) + .limit(10) + .fetch(); + + } + } 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..7f6d833 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 @@ -2,6 +2,9 @@ import gwangjang.server.domain.FindKeywordFeignClient; import gwangjang.server.domain.member.domain.entity.Member; +import gwangjang.server.domain.subscribe.adapter.producer.web.dto.MainBubbleRes; +import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribeData; +import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribersByIssueDto; import gwangjang.server.domain.subscribe.application.dto.res.*; import gwangjang.server.domain.subscribe.domain.entity.Subscribe; import gwangjang.server.domain.subscribe.domain.repository.SubscribeRepository; @@ -107,4 +110,18 @@ public List getMySubscribeList(Member member) { ); return mySubscribeList; } + + public Long getSubscribers(Long issueId) { + return subscribeRepository.findSubscribeCountsByIssue(issueId); + } + + + public List getIssueBySubscribers() { + return subscribeRepository.getIssueBySubscribers(); + } + + + + + }