From 9ac3cc8f7a22feac333360d39a4de7f423f67c2b Mon Sep 17 00:00:00 2001 From: seungyeonnnnnni Date: Mon, 20 Nov 2023 13:00:00 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix=20:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8?= =?UTF-8?q?=ED=95=9C=20=EC=82=AC=EC=9A=A9=EC=9E=90=20=EA=B5=AC=EB=8F=85?= =?UTF-8?q?=ED=95=9C=20=EC=9D=B4=EC=8A=88=20title=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MemberCustomRepositoryImpl.java | 86 +++++++++---------- .../dto/res/SubscribeIssueFeignRes.java | 23 +++++ .../service/SubscribeContentsUseCase.java | 3 +- .../repository/SubscribeCustomRepository.java | 3 +- .../SubscribeCustomRepositoryImpl.java | 7 +- .../domain/service/SubscribeQueryService.java | 14 ++- .../presentation/SubscribeController.java | 2 +- 7 files changed, 87 insertions(+), 51 deletions(-) create mode 100644 src/main/java/gwangjang/server/domain/subscribe/application/dto/res/SubscribeIssueFeignRes.java 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..3c9a9e3 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 @@ -1,43 +1,43 @@ -package gwangjang.server.domain.member.domain.repository; - -import com.querydsl.jpa.impl.JPAQueryFactory; -import jakarta.persistence.EntityManager; - -import static gwangjang.server.domain.member.domain.entity.QMember.member; - - -public class MemberCustomRepositoryImpl implements MemberCustomRepository { - - private final JPAQueryFactory queryFactory; - - public MemberCustomRepositoryImpl(EntityManager em) { - this.queryFactory = new JPAQueryFactory(em); - } - - @Override - public boolean checkNickname(String nickname) { - return queryFactory - .selectOne() - .from(member) - .where(member.nickname.eq(nickname)) - .fetchFirst() != null; - } - - @Override - public boolean checkEmail(String email) { - return queryFactory - .selectOne() - .from(member) - .where(member.email.eq(email)) - .fetchFirst() != null; - } - @Override - public boolean checkLoginId(String loginId) { - return queryFactory - .selectOne() - .from(member) - .where(member.loginId.eq(loginId)) - .fetchFirst() != null; - } - -} +//package gwangjang.server.domain.member.domain.repository; +// +//import com.querydsl.jpa.impl.JPAQueryFactory; +//import jakarta.persistence.EntityManager; +// +//import static gwangjang.server.domain.member.domain.entity.QMember.member; +// +// +//public class MemberCustomRepositoryImpl implements MemberCustomRepository { +// +// private final JPAQueryFactory queryFactory; +// +// public MemberCustomRepositoryImpl(EntityManager em) { +// this.queryFactory = new JPAQueryFactory(em); +// } +// +// @Override +// public boolean checkNickname(String nickname) { +// return queryFactory +// .selectOne() +// .from(member) +// .where(member.nickname.eq(nickname)) +// .fetchFirst() != null; +// } +// +// @Override +// public boolean checkEmail(String email) { +// return queryFactory +// .selectOne() +// .from(member) +// .where(member.email.eq(email)) +// .fetchFirst() != null; +// } +// @Override +// public boolean checkLoginId(String loginId) { +// return queryFactory +// .selectOne() +// .from(member) +// .where(member.loginId.eq(loginId)) +// .fetchFirst() != null; +// } +// +//} diff --git a/src/main/java/gwangjang/server/domain/subscribe/application/dto/res/SubscribeIssueFeignRes.java b/src/main/java/gwangjang/server/domain/subscribe/application/dto/res/SubscribeIssueFeignRes.java new file mode 100644 index 0000000..cf97124 --- /dev/null +++ b/src/main/java/gwangjang/server/domain/subscribe/application/dto/res/SubscribeIssueFeignRes.java @@ -0,0 +1,23 @@ +package gwangjang.server.domain.subscribe.application.dto.res; + + +import lombok.*; + +@Builder +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +public class SubscribeIssueFeignRes { + + private String issue; + private Long issueId; + + public SubscribeIssueFeignRes(Long issueId) { + this.issueId = issueId; + } + + public void updateIssue(String issue) { + this.issue = issue; + } +} diff --git a/src/main/java/gwangjang/server/domain/subscribe/application/service/SubscribeContentsUseCase.java b/src/main/java/gwangjang/server/domain/subscribe/application/service/SubscribeContentsUseCase.java index d99678a..0c08281 100644 --- a/src/main/java/gwangjang/server/domain/subscribe/application/service/SubscribeContentsUseCase.java +++ b/src/main/java/gwangjang/server/domain/subscribe/application/service/SubscribeContentsUseCase.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.SubscribeIssueFeignRes; import gwangjang.server.domain.subscribe.application.mapper.SubscribeMapper; import gwangjang.server.domain.subscribe.domain.service.SubscribeQueryService; import jakarta.transaction.Transactional; @@ -20,7 +21,7 @@ public class SubscribeContentsUseCase { private final SubscribeQueryService subscribeQueryService; private final SubscribeMapper subscribeMapper = new SubscribeMapper(); - public List getMySubscribeIssueList(String memberId) { + public List getMySubscribeIssueList(String memberId) { Member member = memberQueryService.getMemberBySocialId(memberId); return subscribeQueryService.getMySubscribeList(member); } 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 9da0c28..48d36b0 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 @@ -2,6 +2,7 @@ import gwangjang.server.domain.member.domain.entity.Member; 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; import gwangjang.server.domain.subscribe.domain.entity.Subscribe; @@ -14,7 +15,7 @@ public interface SubscribeCustomRepository { boolean findCountSubscribeByMember(Member member); List findIssueTop5BySubscribers(); Long findSubscribeCountsByIssue(Long issueId); - List findMySubscribeList(Member member); + List findMySubscribeList(Member member); 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 080727d..3ba3e6d 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 @@ -6,6 +6,7 @@ import gwangjang.server.domain.member.domain.entity.Member; import gwangjang.server.domain.member.domain.entity.QMember; 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; import gwangjang.server.domain.subscribe.application.dto.res.SubscribeMyPageRes; import gwangjang.server.domain.subscribe.domain.entity.Subscribe; @@ -85,11 +86,11 @@ public Long findSubscribeCountsByIssue(Long issueId) { .fetchOne(); } - public List findMySubscribeList(Member member) { + public List findMySubscribeList(Member member) { return queryFactory - .select( + .select(Projections.constructor(SubscribeIssueFeignRes.class, subscribe.issueId - ) + )) .from(subscribe) .where(subscribe.member.eq(member)) .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 1b62c2e..936e347 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 @@ -94,7 +94,17 @@ public List getIssueInfo(List issueIds) { } - public List getMySubscribeList(Member member) { - return subscribeRepository.findMySubscribeList(member); + public List getMySubscribeList(Member member) { + List mySubscribeList = subscribeRepository.findMySubscribeList(member); + mySubscribeList.stream().forEach( + mySubscribe->{ + Long issueId = mySubscribe.getIssueId(); + + IssueDto issueDto = findKeywordFeignClient. + getIssueByIssueId(issueId).getBody().getData(); + mySubscribe.updateIssue(issueDto.getIssueTitle()); + } + ); + return mySubscribeList; } } diff --git a/src/main/java/gwangjang/server/domain/subscribe/presentation/SubscribeController.java b/src/main/java/gwangjang/server/domain/subscribe/presentation/SubscribeController.java index c523ff4..ada1373 100644 --- a/src/main/java/gwangjang/server/domain/subscribe/presentation/SubscribeController.java +++ b/src/main/java/gwangjang/server/domain/subscribe/presentation/SubscribeController.java @@ -74,7 +74,7 @@ public ResponseEntity> getIssueSubscriber * @return */ @GetMapping("/subscribe/contents") - public ResponseEntity>> getMySubscribeIssueList(@RequestHeader(value = "user-id") String socialId) { + public ResponseEntity>> getMySubscribeIssueList(@RequestHeader(value = "user-id") String socialId) { return ResponseEntity.ok(SuccessResponse.create(GET_MY_SUBSCRIBES_SUCCESS.getMessage(), this.subscribeContentsUseCase.getMySubscribeIssueList(socialId))); } From 5a74dcd16934db89251c3773a67a759103d6e0ab Mon Sep 17 00:00:00 2001 From: seungyeonnnnnni Date: Wed, 22 Nov 2023 19:27:16 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix=20:=20=EB=82=B4=EA=B0=80=20=EA=B5=AC?= =?UTF-8?q?=EB=8F=85=ED=95=98=EA=B3=A0=20=EC=9E=88=EB=8A=94=20=EC=A3=BC?= =?UTF-8?q?=EC=A0=9C=20=EB=A6=AC=ED=84=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MemberCustomRepositoryImpl.java | 86 +++++++++---------- 1 file changed, 43 insertions(+), 43 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 3c9a9e3..e969693 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 @@ -1,43 +1,43 @@ -//package gwangjang.server.domain.member.domain.repository; -// -//import com.querydsl.jpa.impl.JPAQueryFactory; -//import jakarta.persistence.EntityManager; -// -//import static gwangjang.server.domain.member.domain.entity.QMember.member; -// -// -//public class MemberCustomRepositoryImpl implements MemberCustomRepository { -// -// private final JPAQueryFactory queryFactory; -// -// public MemberCustomRepositoryImpl(EntityManager em) { -// this.queryFactory = new JPAQueryFactory(em); -// } -// -// @Override -// public boolean checkNickname(String nickname) { -// return queryFactory -// .selectOne() -// .from(member) -// .where(member.nickname.eq(nickname)) -// .fetchFirst() != null; -// } -// -// @Override -// public boolean checkEmail(String email) { -// return queryFactory -// .selectOne() -// .from(member) -// .where(member.email.eq(email)) -// .fetchFirst() != null; -// } -// @Override -// public boolean checkLoginId(String loginId) { -// return queryFactory -// .selectOne() -// .from(member) -// .where(member.loginId.eq(loginId)) -// .fetchFirst() != null; -// } -// -//} +package gwangjang.server.domain.member.domain.repository; + +import com.querydsl.jpa.impl.JPAQueryFactory; +import jakarta.persistence.EntityManager; + +import static gwangjang.server.domain.member.domain.entity.QMember.member; + + +public class MemberCustomRepositoryImpl implements MemberCustomRepository { + + private final JPAQueryFactory queryFactory; + + public MemberCustomRepositoryImpl(EntityManager em) { + this.queryFactory = new JPAQueryFactory(em); + } + + @Override + public boolean checkNickname(String nickname) { + return queryFactory + .selectOne() + .from(member) + .where(member.nickname.eq(nickname)) + .fetchFirst() != null; + } + + @Override + public boolean checkEmail(String email) { + return queryFactory + .selectOne() + .from(member) + .where(member.email.eq(email)) + .fetchFirst() != null; + } + @Override + public boolean checkLoginId(String loginId) { + return queryFactory + .selectOne() + .from(member) + .where(member.loginId.eq(loginId)) + .fetchFirst() != null; + } + +}