Skip to content

Commit

Permalink
Merge pull request #19 from FinalDoubleTen/BE-66-Refactor-STOMP
Browse files Browse the repository at this point in the history
Be 66 refactor stomp
  • Loading branch information
Kim-Dong-Jun99 authored Jan 11, 2024
2 parents 2b7b339 + 4014212 commit 8808180
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
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

0 comments on commit 8808180

Please sign in to comment.