Skip to content

Commit

Permalink
Merge pull request #26 from kusitms-28th-Meetup-E/feat/subscribe
Browse files Browse the repository at this point in the history
Feat/subscribe
  • Loading branch information
seungueonn authored Nov 22, 2023
2 parents 133cb53 + 5a74dcd commit c189815
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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;
}
}
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.SubscribeIssueFeignRes;
import gwangjang.server.domain.subscribe.application.mapper.SubscribeMapper;
import gwangjang.server.domain.subscribe.domain.service.SubscribeQueryService;
import jakarta.transaction.Transactional;
Expand All @@ -20,7 +21,7 @@ public class SubscribeContentsUseCase {
private final SubscribeQueryService subscribeQueryService;
private final SubscribeMapper subscribeMapper = new SubscribeMapper();

public List<Long> getMySubscribeIssueList(String memberId) {
public List<SubscribeIssueFeignRes> getMySubscribeIssueList(String memberId) {
Member member = memberQueryService.getMemberBySocialId(memberId);
return subscribeQueryService.getMySubscribeList(member);
}
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.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;

Expand All @@ -14,7 +15,7 @@ public interface SubscribeCustomRepository {
boolean findCountSubscribeByMember(Member member);
List<IssueBySubscribersRes> findIssueTop5BySubscribers();
Long findSubscribeCountsByIssue(Long issueId);
List<Long> findMySubscribeList(Member member);
List<SubscribeIssueFeignRes> findMySubscribeList(Member member);



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -85,11 +86,11 @@ public Long findSubscribeCountsByIssue(Long issueId) {
.fetchOne();
}

public List<Long> findMySubscribeList(Member member) {
public List<SubscribeIssueFeignRes> findMySubscribeList(Member member) {
return queryFactory
.select(
.select(Projections.constructor(SubscribeIssueFeignRes.class,
subscribe.issueId
)
))
.from(subscribe)
.where(subscribe.member.eq(member))
.fetch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,17 @@ public List<IssueBySubscribeRecommendRes> getIssueInfo(List<Long> issueIds) {

}

public List<Long> getMySubscribeList(Member member) {
return subscribeRepository.findMySubscribeList(member);
public List<SubscribeIssueFeignRes> getMySubscribeList(Member member) {
List<SubscribeIssueFeignRes> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public ResponseEntity<SuccessResponse<IssueSubscribeInfoRes>> getIssueSubscriber
* @return
*/
@GetMapping("/subscribe/contents")
public ResponseEntity<SuccessResponse<List<Long>>> getMySubscribeIssueList(@RequestHeader(value = "user-id") String socialId) {
public ResponseEntity<SuccessResponse<List<SubscribeIssueFeignRes>>> getMySubscribeIssueList(@RequestHeader(value = "user-id") String socialId) {
return ResponseEntity.ok(SuccessResponse.create(GET_MY_SUBSCRIBES_SUCCESS.getMessage(), this.subscribeContentsUseCase.getMySubscribeIssueList(socialId)));
}

Expand Down

0 comments on commit c189815

Please sign in to comment.