Skip to content

Commit

Permalink
Merge branch 'develop/be' into feature/be/#541
Browse files Browse the repository at this point in the history
  • Loading branch information
slimsha2dy authored Oct 21, 2024
2 parents e963c32 + ff555a3 commit a89a0db
Show file tree
Hide file tree
Showing 24 changed files with 626 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import kr.touroot.global.auth.dto.MemberAuth;
import kr.touroot.global.exception.dto.ExceptionResponse;
import kr.touroot.member.dto.request.ProfileUpdateRequest;
import kr.touroot.member.dto.response.MyLikeTravelogueResponse;
import kr.touroot.member.dto.response.MyTravelogueResponse;
import kr.touroot.member.dto.response.ProfileResponse;
import kr.touroot.member.service.MyPageFacadeService;
Expand Down Expand Up @@ -103,6 +104,30 @@ public ResponseEntity<Page<PlanResponse>> readTravelPlans(
return ResponseEntity.ok(data);
}

@Operation(summary = "내가 좋아요 한 여행기 조회")
@ApiResponses(value = {
@ApiResponse(
responseCode = "200",
description = "내가 좋아요 한 여행기 조회에 성공했을 때"
),
@ApiResponse(
responseCode = "401",
description = "로그인하지 않은 사용자가 조회를 시도할 때",
content = @Content(schema = @Schema(implementation = ExceptionResponse.class))
)
})
@PageableAsQueryParam
@GetMapping("/likes")
public ResponseEntity<Page<MyLikeTravelogueResponse>> readLikes(
@NotNull MemberAuth memberAuth,
@Parameter(hidden = true)
@PageableDefault(size = 5, sort = "id", direction = Sort.Direction.DESC)
Pageable pageable
) {
Page<MyLikeTravelogueResponse> data = myPageFacadeService.readLikes(memberAuth, pageable);
return ResponseEntity.ok(data);
}

@Operation(summary = "나의 프로필 정보 수정")
@ApiResponses(value = {
@ApiResponse(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package kr.touroot.member.dto.response;

import java.time.format.DateTimeFormatter;
import kr.touroot.travelogue.domain.Travelogue;
import lombok.Builder;

@Builder
public record MyLikeTravelogueResponse(
long id,
String title,
String thumbnailUrl,
String createdAt,
String authorName,
String authorProfileImageUrl
) {

public static MyLikeTravelogueResponse from(Travelogue travelogue) {
String createdAt = travelogue.getCreatedAt()
.toLocalDate()
.format(DateTimeFormatter.ofPattern("yyyy.MM.dd"));

return MyLikeTravelogueResponse.builder()
.id(travelogue.getId())
.title(travelogue.getTitle())
.thumbnailUrl(travelogue.getThumbnail())
.createdAt(createdAt)
.authorName(travelogue.getAuthorNickname())
.authorProfileImageUrl(travelogue.getAuthorProfileImageUrl())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
import kr.touroot.global.auth.dto.MemberAuth;
import kr.touroot.member.domain.Member;
import kr.touroot.member.dto.request.ProfileUpdateRequest;
import kr.touroot.member.dto.response.MyLikeTravelogueResponse;
import kr.touroot.member.dto.response.MyTravelogueResponse;
import kr.touroot.member.dto.response.ProfileResponse;
import kr.touroot.travelogue.domain.Travelogue;
import kr.touroot.travelogue.domain.TravelogueLike;
import kr.touroot.travelogue.service.TravelogueLikeService;
import kr.touroot.travelogue.service.TravelogueService;
import kr.touroot.travelplan.domain.TravelPlan;
import kr.touroot.travelplan.dto.response.PlanResponse;
Expand All @@ -23,6 +26,7 @@ public class MyPageFacadeService {
private final MemberService memberService;
private final TravelogueService travelogueService;
private final TravelPlanService travelPlanService;
private final TravelogueLikeService travelogueLikeService;

@Transactional(readOnly = true)
public ProfileResponse readProfile(MemberAuth memberAuth) {
Expand All @@ -46,6 +50,15 @@ public Page<PlanResponse> readTravelPlans(MemberAuth memberAuth, Pageable pageab
return travelPlans.map(PlanResponse::from);
}

@Transactional(readOnly = true)
public Page<MyLikeTravelogueResponse> readLikes(MemberAuth memberAuth, Pageable pageable) {
Member member = memberService.getMemberById(memberAuth.memberId());

return travelogueLikeService.findByLiker(member, pageable)
.map(TravelogueLike::getTravelogue)
.map(MyLikeTravelogueResponse::from);
}

@Transactional
public ProfileResponse updateProfile(ProfileUpdateRequest request, MemberAuth memberAuth) {
return memberService.updateProfile(request, memberAuth);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package kr.touroot.travelogue.domain;

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 kr.touroot.travelogue.domain.search.CountryCode;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@EqualsAndHashCode(of = "id", callSuper = false)
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Entity
public class TravelogueCountry {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@JoinColumn(nullable = false)
@ManyToOne(fetch = FetchType.LAZY)
private Travelogue travelogue;

@Column(nullable = false)
@Enumerated(EnumType.STRING)
private CountryCode countryCode;

@Column(nullable = false)
private Integer count;

public TravelogueCountry(Travelogue travelogue, CountryCode countryCode, Integer count) {
this.travelogue = travelogue;
this.countryCode = countryCode;
this.count = count;
}
}
Loading

0 comments on commit a89a0db

Please sign in to comment.