Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #20

Merged
merged 3 commits into from
Jan 11, 2024
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,13 +1,10 @@
package org.tenten.tentenstomp.domain.trip.dto.request;

import org.tenten.tentenstomp.global.common.enums.TripStatus;

public record TripUpdateMsg(
String startDate,
String endDate,
Long numberOfPeople,
String tripName,
TripStatus tripStatus,
String area,
String subarea,
Long budget
Expand Down
28 changes: 22 additions & 6 deletions src/main/java/org/tenten/tentenstomp/domain/trip/entity/Trip.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import java.util.Map;

import static jakarta.persistence.CascadeType.REMOVE;
import static jakarta.persistence.EnumType.STRING;
import static jakarta.persistence.FetchType.LAZY;
import static jakarta.persistence.GenerationType.IDENTITY;
import static jakarta.persistence.InheritanceType.JOINED;
import static org.tenten.tentenstomp.global.common.enums.TripStatus.*;

@Entity
@Getter
Expand All @@ -39,8 +39,6 @@ public class Trip extends BaseTimeEntity {
private LocalDate endDate;
private String area;
private String subarea;
@Enumerated(STRING)
private TripStatus tripStatus;
private Boolean isDeleted;
private String tripName;
private Long budget;
Expand All @@ -66,17 +64,35 @@ public TripInfoMsg changeTripInfo(TripUpdateMsg request) {
this.endDate = LocalDate.parse(request.endDate());
this.numberOfPeople = request.numberOfPeople();
this.tripName = request.tripName();
this.tripStatus = request.tripStatus();
this.area = request.area();
this.subarea = request.subarea();
this.budget = request.budget();
LocalDate currentDate = LocalDate.now();

return new TripInfoMsg(this.getId(), request.startDate(), request.endDate(), this.getNumberOfPeople(), this.getTripName(), this.getTripStatus(),
TripStatus tripStatus = null;
if (currentDate.isBefore(this.startDate)) {
tripStatus = BEFORE;
} else if (currentDate.isAfter(this.endDate)) {
tripStatus = AFTER;
} else {
tripStatus = ING;
}

return new TripInfoMsg(this.getId(), request.startDate(), request.endDate(), this.getNumberOfPeople(), this.getTripName(), tripStatus,
this.getArea(), this.getSubarea(), this.getBudget());
}

public TripInfoMsg toTripInfo() {
return new TripInfoMsg(this.getId(), this.startDate.toString(), this.endDate.toString(), this.getNumberOfPeople(), this.getTripName(), this.getTripStatus(),
LocalDate currentDate = LocalDate.now();
TripStatus tripStatus = null;
if (currentDate.isBefore(this.startDate)) {
tripStatus = BEFORE;
} else if (currentDate.isAfter(this.endDate)) {
tripStatus = AFTER;
} else {
tripStatus = ING;
}
return new TripInfoMsg(this.getId(), this.startDate.toString(), this.endDate.toString(), this.getNumberOfPeople(), this.getTripName(), tripStatus,
this.getArea(), this.getSubarea(), this.getBudget());
}

Expand Down