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
7 changes: 4 additions & 3 deletions src/main/java/com/retrip/trip/application/in/TripService.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,18 @@ public TripUpdateResponse updateTrip(UUID memberId, UUID tripId, TripUpdateReque
Trip trip = findTrip(tripId);

TripTitle tripTitle = request.toTripTitle();
TripDestinations destinations = request.toTripDestinations(trip);
TripDescription tripDescription = request.toTripDescription();
TripPeriod tripPeriod = request.toTripPeriod();
TripHashTags tripHashTags = request.toHashTags(trip);
TripHashTags hashTags = request.toHashTags(trip);

//List<Itinerary> itineraries = tripItineraryQueryRepository.findByIdsWithItineraryDetails(trip.getItinerariesIds());
trip.update(
memberId,
request.locationId(),
destinations,
tripTitle,
tripDescription,
tripHashTags,
hashTags,
request.maxParticipants(),
request.imageUrl(),
request.category()
Expand Down
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.entity.TripDestinations;
import com.retrip.trip.domain.entity.TripHashTags;
import com.retrip.trip.domain.vo.*;
import io.swagger.v3.oas.annotations.media.Schema;
Expand All @@ -22,7 +23,7 @@ public record TripUpdateRequest(

@Schema(description = "μ—¬ν–‰ μœ„μΉ˜ ID", example = "550e8400-e29b-41d4-a716-446655440001")
@NotNull
UUID locationId,
List<UUID> destinationIds,

@Schema(description = "μ—¬ν–‰ μ‹œμž‘ λ‚ μ§œ", example = "2025-06-15")
@FutureOrPresent
Expand All @@ -35,15 +36,32 @@ public record TripUpdateRequest(
@Schema(description = "μ—¬ν–‰ μ΅œλŒ€ μ°Έκ°€ 인원")
Integer maxParticipants,

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

@Schema(description = "μ—¬ν–‰ λŒ€ν‘œ 이미지 URL")
String imageUrl,

@Schema(description = "μ—¬ν–‰ μΉ΄ν…Œκ³ λ¦¬")
TripCategory category
) {
@Schema(description = "ν•΄μ‹œνƒœκ·Έ μž…λ ₯")
public record HashTagInput(
@Schema(description = "ν•΄μ‹œνƒœκ·Έ κ°’", example = "10λŒ€")
String tag,

@Schema(description = "μ •λ ¬ μˆœμ„œ", example = "1")
int order
) {
}

public TripDestinations toTripDestinations(Trip trip) {
if (destinationIds == null || destinationIds.isEmpty()) {
return null;
}
return new TripDestinations(trip, destinationIds);
}

public TripTitle toTripTitle() {
if (title != null) {
return new TripTitle(title);
Expand All @@ -66,9 +84,10 @@ public TripPeriod toTripPeriod() {
}

public TripHashTags toHashTags(Trip trip) {
if (hashTags != null) {
return new TripHashTags(trip, hashTags);
}
return null;
if (hashTags == null || hashTags.isEmpty()) return null;
return new TripHashTags(trip, hashTags.stream()
.map(h -> new HashTagInfo(h.tag(), h.order()))
.toList());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ private enum Gender {
}

public static UserContext mockOf() {

String hex = "99999999999999999999999999999991";

// λ°”λ‘œ λ³€ν™˜
UUID uuid = UUID.fromString(hex.replaceFirst("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5"));

return new UserContext(
UUID.randomUUID(),
uuid,
"Tester",
"test@naver.com",
"홍길동",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package com.retrip.trip.application.in.response;

import com.retrip.trip.domain.entity.Trip;
import com.retrip.trip.domain.entity.TripHashTag;
import io.swagger.v3.oas.annotations.media.Schema;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.UUID;

@Schema(description = "μ—¬ν–‰ 생성 Response")
@Schema(description = "μ—¬ν–‰ μˆ˜μ • Response")
public record TripUpdateResponse(
@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 λ“€", example = "550e8400-e29b-41d4-a716-446655440001")
List<UUID> destinationIds,

@Schema(description = "μ—¬ν–‰ 제λͺ©", example = "파리 μ—¬ν–‰")
String title,
Expand All @@ -33,7 +33,7 @@ public record TripUpdateResponse(
int maxParticipants,

@Schema(description = "μ—¬ν–‰ μΉ΄ν…Œκ³ λ¦¬")
List<String> hashTags,
List<HashTagResponse> hashTags,

@Schema(description = "μ—¬ν–‰ μΉ΄ν…Œκ³ λ¦¬")
String category,
Expand All @@ -44,25 +44,42 @@ public record TripUpdateResponse(
@Schema(description = "μ—¬ν–‰ 일정 리슀트")
List<ItineraryUpdateResponse> itineraries
) {

public static TripUpdateResponse of(Trip trip) {
return new TripUpdateResponse(
trip.getId(),
trip.getDestinationId(),
trip.getDestinations().getDestinationIds(),
trip.getTitle().getValue(),
trip.getDescription().getValue(),
trip.getPeriod().getStart(),
trip.getPeriod().getEnd(),
trip.getTripParticipants().getMaxParticipants(),
trip.getHashTags().getValues().stream().map(TripHashTag::getName).toList(),
trip.getHashTags().getValues().stream()
.map(hashtag -> new HashTagResponse(hashtag.getName(),
hashtag.getTagOrder()))
.sorted(Comparator.comparingInt(HashTagResponse::order))
.toList(),
trip.getCategory().getViewName(),
trip.getImageUrl(),
trip.getItineraries() == null ? new ArrayList<>() :
trip.getItineraries().getValues().stream()
.map(i -> new ItineraryUpdateResponse(i.getId(), i.getName(), i.getDate()))
.map(i -> new ItineraryUpdateResponse(i.getId(), i.getName(),
i.getDate()))
.toList()
);
}

@Schema(description = "ν•΄μ‹œνƒœκ·Έ Response")
public record HashTagResponse(
@Schema(description = "ν•΄μ‹œνƒœκ·Έ")
String tag,

@Schema(description = "μ •λ ¬ μˆœμ„œ")
int order
) {

}

@Schema(description = "μ—¬ν–‰ 일정 Response")
private record ItineraryUpdateResponse(
@Schema(description = "일정 ID")
Expand All @@ -74,5 +91,6 @@ private record ItineraryUpdateResponse(
@Schema(description = "일정 λ‚ μ§œ")
LocalDate date
) {

}
}
9 changes: 4 additions & 5 deletions src/main/java/com/retrip/trip/domain/entity/Trip.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public boolean isNotTripRecruitingStatus() {

public void update(
UUID memberId,
UUID destinationId,
TripDestinations destinations,
TripTitle tripTitle,
TripDescription tripDescription,
TripHashTags tripHashTags,
Expand All @@ -220,8 +220,8 @@ public void update(
throw new TripUpdateFailedException();
}

if (destinationId != null) {
this.destinationId = destinationId;
if (destinations != null) {
this.destinations.update(destinations.getValues());
}

if (tripTitle != null) {
Expand All @@ -232,8 +232,7 @@ public void update(
}

if (tripHashTags != null) {
this.hashTags.getValues().clear();
this.hashTags.getValues().addAll(tripHashTags.getValues());
this.hashTags.update(tripHashTags.getValues());
}

if (maxParticipants != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import jakarta.persistence.CascadeType;
import jakarta.persistence.Embeddable;
import jakarta.persistence.OneToMany;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import lombok.Getter;
import lombok.NoArgsConstructor;

Expand All @@ -30,4 +32,9 @@ public List<UUID> getDestinationIds() {
.map(TripDestination::getDestinationId)
.toList();
}

public void update(List<TripDestination> tripDestinations) {
this.values.clear();
this.values.addAll(tripDestinations);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import jakarta.persistence.OneToMany;

import jakarta.persistence.OrderBy;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;

import java.util.stream.Collectors;
Expand Down Expand Up @@ -51,4 +51,9 @@ public List<String> getHashTagNames() {
.map(TripHashTag::getName)
.collect(Collectors.toList());
}

public void update(List<TripHashTag> tripHashTags) {
this.values.clear();
this.values.addAll(tripHashTags);
}
}