Skip to content

Commit

Permalink
MATE-93 : [FIX] 회원 타임라인 페이지 번호 문제 해결 matePostId 반환 추가 (#85)
Browse files Browse the repository at this point in the history
* MATE-93 : [CHORE] 사소한 import 정리

* MATE-86 : [FIX] 회원 타임라인 페이지 번호 계산 문제 해결 및 matePostId 반환 추가
  • Loading branch information
jooinjoo authored Dec 5, 2024
1 parent d62a418 commit 0972ef5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.example.mate.domain.match.entity;

import com.example.mate.domain.constant.StadiumInfo;
import com.example.mate.domain.constant.TeamInfo;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/com/example/mate/domain/mate/entity/MateReview.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,22 @@
import com.example.mate.common.BaseTimeEntity;
import com.example.mate.domain.constant.Rating;
import com.example.mate.domain.member.entity.Member;
import jakarta.persistence.*;
import lombok.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "mate_review")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class MyVisitResponse {
private String location;
private LocalDateTime matchTime;

// 메이트 게시글 정보
private Long matePostId;

// 리뷰 정보
@Builder.Default
private List<MateReviewResponse> reviews = new ArrayList<>();
Expand Down Expand Up @@ -54,12 +57,13 @@ public static MateReviewResponse from(Member member) {
}
}

public static MyVisitResponse of(Match match, List<MateReviewResponse> reviews) {
public static MyVisitResponse of(Match match, List<MateReviewResponse> reviews, Long matePostId) {
return MyVisitResponse.builder()
.homeTeamName(TeamInfo.getById(match.getHomeTeamId()).shortName)
.awayTeamName(TeamInfo.getById(match.getAwayTeamId()).shortName)
.location(match.getStadium().name)
.matchTime(match.getMatchTime())
.matePostId(matePostId)
.reviews(reviews)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private MyVisitResponse createVisitResponse(MyTimelineResponse response, Long me
// 각 메이트에 대한 리뷰 생성
List<MateReviewResponse> reviews = createMateReviews(response, mates, memberId);

return MyVisitResponse.of(match, reviews);
return MyVisitResponse.of(match, reviews, response.getMatePostId());
}

private List<MateReviewResponse> createMateReviews(MyTimelineResponse response, List<Member> mates, Long memberId) {
Expand All @@ -183,18 +183,14 @@ private PageResponse<MyVisitResponse> createPageResponse(Page<MyTimelineResponse
// 페이징 처리
int pageNumber = pageable.getPageNumber();
int pageSize = pageable.getPageSize();
int start = Math.min(pageNumber * pageSize, totalElements);
int end = Math.min(start + pageSize, totalElements);
List<MyVisitResponse> content = responses.subList(start, end);

return PageResponse.<MyVisitResponse>builder()
.content(content)
.content(responses)
.totalPages(totalPages)
.totalElements(totalElements)
.hasNext(pageNumber + 1 < totalPages)
.pageNumber(pageNumber)
.pageSize(pageSize)
.build();
}

}

0 comments on commit 0972ef5

Please sign in to comment.