Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.retrip.trip.application.in.request;

import com.retrip.trip.domain.entity.Trip;
import com.retrip.trip.domain.vo.HashTagInfo;
import com.retrip.trip.domain.vo.TripCategory;
import com.retrip.trip.domain.vo.TripDescription;
import com.retrip.trip.domain.vo.TripPeriod;
Expand All @@ -17,9 +18,9 @@
@Schema(description = "여행 생성 Request")
public record TripCreateRequest(

@Schema(description = "여행 위치 ID", example = "550e8400-e29b-41d4-a716-446655440001")
@Schema(description = "여행 위치 ID 목록")
@NotNull
UUID locationId,
List<UUID> locationIds,

@Schema(description = "여행 제목", example = "유럽 배낭여행")
@NotNull
Expand Down Expand Up @@ -48,24 +49,40 @@ public record TripCreateRequest(
@Schema(description = "여행 최대 참가 인원")
int maxParticipants,

@Schema(description = "HashTag")
List<String> hashTags,
@Schema(description = "HashTag 목록")
List<HashTagInput> hashTags,

@Schema(description = "여행 카테고리")
TripCategory category

) {
@Schema(description = "해시태그 입력")
public record HashTagInput(
@Schema(description = "해시태그 값", example = "10대")
String tag,

@Schema(description = "정렬 순서", example = "1")
int order
) {}

private List<HashTagInfo> toHashTagInfos() {
if (hashTags == null) return List.of();
return hashTags.stream()
.map(h -> new HashTagInfo(h.tag(), h.order()))
.toList();
}

public Trip to(UUID memberId) {
return Trip.create(
memberId,
locationId,
locationIds,
new TripTitle(title),
imageUrl,
new TripDescription(description),
new TripPeriod(start, end),
open,
maxParticipants,
hashTags,
toHashTagInfos(),
category,
TripStatus.RECRUITING
);
Expand All @@ -74,14 +91,14 @@ public Trip to(UUID memberId) {
public Trip toWithItineraries(UUID memberId) {
return Trip.createWithItineraries(
memberId,
locationId,
locationIds,
new TripTitle(title),
imageUrl,
new TripDescription(description),
new TripPeriod(start, end),
open,
maxParticipants,
hashTags,
toHashTagInfos(),
category,
TripStatus.RECRUITING
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public record TripCreateResponse(
@Schema(description = "여행 ID", example = "550e8400-e29b-41d4-a716-446655440000")
UUID id,

@Schema(description = "여행 목적지 ID", example = "550e8400-e29b-41d4-a716-446655440001")
UUID destinationId,
@Schema(description = "여행 목적지 ID 목록")
List<UUID> destinationIds,

@Schema(description = "여행 제목", example = "파리 여행")
String title,
Expand All @@ -35,8 +35,8 @@ public record TripCreateResponse(
@Schema(description = "여행 최대 참가 인원")
int maxParticipants,

@Schema(description = "여행 카테고리")
List<String> hashTags,
@Schema(description = "HashTag 목록")
List<HashTagResponse> hashTags,

@Schema(description = "여행 카테고리")
String category,
Expand All @@ -50,14 +50,16 @@ public record TripCreateResponse(
public static TripCreateResponse of(Trip trip) {
return new TripCreateResponse(
trip.getId(),
trip.getDestinationId(),
trip.getDestinations().getDestinationIds(),
trip.getTitle().getValue(),
trip.getDescription().getValue(),
trip.getPeriod().getStart(),
trip.getPeriod().getEnd(),
trip.isOpen(),
trip.getTripParticipants().getMaxParticipants(),
trip.getHashTags().getValues().stream().map(TripHashTag::getName).toList(),
trip.getHashTags().getValues().stream()
.map(h -> new HashTagResponse(h.getName(), h.getTagOrder()))
.toList(),
trip.getCategory().getViewName(),
trip.getImageUrl(),
trip.getItineraries() == null ? new ArrayList<>() :
Expand All @@ -67,6 +69,15 @@ public static TripCreateResponse of(Trip trip) {
);
}

@Schema(description = "해시태그 Response")
public record HashTagResponse(
@Schema(description = "해시태그")
String tag,

@Schema(description = "정렬 순서")
int order
) {}

@Schema(description = "여행 일정 Response")
private record ItineraryCreateResponse(
@Schema(description = "일정 ID")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ public record TripDetailResponse(
)
String tripStatusName,

@Schema(
description = "여행 목적지",
example = "부산 해운대"
)
String tripLocation,
@Schema(description = "여행 목적지 명 목록(아직 빈값 내려갈 예정)")
List<String> destinationNames,

@Schema(description = "여행 목적지 ID 목록")
List<UUID> destinationIds,

@Schema(
description = "여행 대표 이미지 URL",
Expand All @@ -85,15 +85,20 @@ public record TripDetailResponse(
)
String description,

@Schema(
description = "여행 해시태그 목록",
example = "[\"힐링\", \"바다\", \"맛집투어\"]"
)
List<String> hashTags,
@Schema(description = "여행 해시태그 목록")
List<HashTagResponse> hashTags,

@Schema(description = "여행 참가자 목록")
List<TripParticipantResponse> participants
) {
@Schema(description = "해시태그 응답")
public record HashTagResponse(
@Schema(description = "해시태그 값", example = "맛집투어")
String tag,

@Schema(description = "정렬 순서", example = "1")
int order
) {}

public static TripDetailResponse of(UUID memberId, Trip trip) {
return TripDetailResponse.builder()
Expand All @@ -106,10 +111,13 @@ public static TripDetailResponse of(UUID memberId, Trip trip) {
.maxParticipantCount(trip.getTripParticipants().getMaxParticipants())
.tripStatus(trip.getStatus())
.tripStatusName(trip.getStatus().getViewName())
.tripLocation("") // TODO : Location 구현 시 채울 예정
.destinationNames(List.of()) // TODO : Location 구현 시 채울 예정
.destinationIds(trip.getDestinations().getDestinationIds())
.imageUrl(trip.getImageUrl())
.description(trip.getDescription().getValue())
.hashTags(trip.getHashTags().getHashTagNames())
.hashTags(trip.getHashTags().getValues().stream()
.map(h -> new HashTagResponse(h.getName(), h.getTagOrder()))
.toList())
.participants(TripParticipantResponse.toList(trip.getTripParticipants().getValues()))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.swagger.v3.oas.annotations.media.Schema;

import java.time.LocalDate;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
Expand All @@ -19,8 +20,8 @@ public record TripResponse(
@Schema(description = "여행 제목")
String title,

@Schema(description = "목적지 ID")
UUID destinationId,
@Schema(description = "목적지 ID 목록")
List<UUID> destinationIds,

@Schema(description = "목적지 명 (예: 파리, 제주)")
String destinationName, // TODO: 추후 QueryDSL Join으로 데이터 채우기 구현 필요
Expand All @@ -47,20 +48,27 @@ public record TripResponse(
boolean open,

@Schema(description = "HashTag 목록")
List<String> hashTags
List<HashTagResponse> hashTags
) {

@Schema(description = "해시태그 응답")
public record HashTagResponse(
@Schema(description = "해시태그 값")
String tag,

@Schema(description = "정렬 순서")
int order
) {}

public static List<TripResponse> of(List<Trip> trips, List<TripHashTag> hashTags) {
Map<UUID, List<String>> tags = hashTags.stream()
.collect(Collectors.groupingBy(
h -> h.getTrip().getId(),
Collectors.mapping(TripHashTag::getName, Collectors.toList())
));
Map<UUID, List<TripHashTag>> tagMap = hashTags.stream()
.collect(Collectors.groupingBy(h -> h.getTrip().getId()));

return trips.stream()
.map(trip -> new TripResponse(
trip.getId(),
trip.getTitle().getValue(),
trip.getDestinationId(),
trip.getDestinations().getDestinationIds(),
"", // destinationName: 현재 Location 정보가 없으므로 빈 값 또는 추후 구현
trip.getImageUrl(),
trip.getStatus(),
Expand All @@ -69,7 +77,10 @@ public static List<TripResponse> of(List<Trip> trips, List<TripHashTag> hashTags
trip.getTripParticipants().getCurrentCount(),
trip.getTripParticipants().getMaxParticipants(),
trip.isOpen(),
tags.getOrDefault(trip.getId(), List.of())
tagMap.getOrDefault(trip.getId(), List.of()).stream()
.sorted(Comparator.comparingInt(TripHashTag::getTagOrder))
.map(h -> new HashTagResponse(h.getName(), h.getTagOrder()))
.toList()
))
.toList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class ImageService implements ImageManageUseCase {

private static final String IMAGE_DOMAIN_URL = "https://retrip-media.s3.ap-northeast-2.amazonaws.com";
private static final String FORDER_NAME = "media"; // 기존 오타 유지
private static final String FORDER_NAME = "media";
private static final Duration PRESIGN_DURATION = Duration.ofMinutes(5);

@Value("${cloud.s3.bucket}")
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/com/retrip/trip/domain/entity/Trip.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class Trip extends BaseEntity {
@Id
@Column(columnDefinition = "varbinary(16)")
private UUID id;
private UUID destinationId;

@Version
private long version;
Expand Down Expand Up @@ -73,22 +72,24 @@ public class Trip extends BaseEntity {
@Embedded
private TripHashTags hashTags;

@Embedded
private TripDestinations destinations;

public static Trip create(
UUID memberId,
UUID destinationId,
List<UUID> destinationIds,
TripTitle title,
String imageUrl,
TripDescription description,
TripPeriod period,
boolean open,
int maxParticipants,
List<String> hashTags,
List<HashTagInfo> hashTags,
TripCategory category,
TripStatus status
) {
Trip trip = Trip.builder()
.id(UUID.randomUUID())
.destinationId(destinationId)
.title(title)
.imageUrl(imageUrl)
.description(description)
Expand All @@ -97,27 +98,27 @@ public static Trip create(
.category(category)
.status(status)
.build();
trip.destinations = new TripDestinations(trip, destinationIds);
trip.tripParticipants = new TripParticipants(memberId, trip, maxParticipants);
trip.hashTags = new TripHashTags(trip, hashTags);
return trip;
}

public static Trip createWithItineraries(
UUID leaderId,
UUID destinationId,
List<UUID> destinationIds,
TripTitle title,
String imageUrl,
TripDescription description,
TripPeriod period,
boolean open,
int maxParticipants,
List<String> hashTags,
List<HashTagInfo> hashTags,
TripCategory category,
TripStatus status
) {
Trip trip = Trip.builder()
.id(UUID.randomUUID())
.destinationId(destinationId)
.title(title)
.imageUrl(imageUrl)
.description(description)
Expand All @@ -126,6 +127,7 @@ public static Trip createWithItineraries(
.category(category)
.status(status)
.build();
trip.destinations = new TripDestinations(trip, destinationIds);
trip.itineraries = new Itineraries(trip, period);
trip.tripParticipants = new TripParticipants(leaderId, trip, maxParticipants);
trip.hashTags = new TripHashTags(trip, hashTags);
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/com/retrip/trip/domain/entity/TripDestination.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.retrip.trip.domain.entity;

import static lombok.AccessLevel.PROTECTED;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Entity
@AllArgsConstructor
@NoArgsConstructor(access = PROTECTED)
public class TripDestination extends BaseEntity {

@Id
@Column(columnDefinition = "varbinary(16)")
private UUID id;

@Column(columnDefinition = "varbinary(16)", nullable = false)
private UUID destinationId;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(
name = "trip_id",
nullable = false,
columnDefinition = "varbinary(16)",
foreignKey = @ForeignKey(name = "fk_trip_destination_to_trip")
)
private Trip trip;

public static TripDestination of(Trip trip, UUID destinationId) {
return new TripDestination(UUID.randomUUID(), destinationId, trip);
}
}
Loading