trips: add controller, service, mappers, dtos etc.
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
package SuMoC.backend.trip.models;
|
||||
|
||||
|
||||
import SuMoC.backend.models.TripSegment;
|
||||
import SuMoC.backend.models.User;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Table(name = "trips")
|
||||
public class Trip {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "user_id", nullable = false)
|
||||
private User user;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String startPlace;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String endPlace;
|
||||
|
||||
@Column(nullable = false)
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Column(nullable = false)
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* Mobilityscore for the trip. TODO determine if this needs an own data type
|
||||
*/
|
||||
@Column(nullable = false)
|
||||
private float mobilityScore;
|
||||
|
||||
@Column(nullable = true)
|
||||
private float cost;
|
||||
|
||||
@OneToMany(mappedBy = "trip", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private Set<TripSegment> segments = new HashSet<>();
|
||||
|
||||
|
||||
public Trip() {}
|
||||
|
||||
public Trip(Long id, User user, String startPlace, String endPlace, LocalDateTime startTime, LocalDateTime endTime, float mobilityScore, float cost, Set<TripSegment> segments) {
|
||||
this.id = id;
|
||||
this.user = user;
|
||||
this.startPlace = startPlace;
|
||||
this.endPlace = endPlace;
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
this.mobilityScore = mobilityScore;
|
||||
this.cost = cost;
|
||||
this.segments = segments;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public String getStartPlace() {
|
||||
return startPlace;
|
||||
}
|
||||
|
||||
public void setStartPlace(String startPlace) {
|
||||
this.startPlace = startPlace;
|
||||
}
|
||||
|
||||
public String getEndPlace() {
|
||||
return endPlace;
|
||||
}
|
||||
|
||||
public void setEndPlace(String endPlace) {
|
||||
this.endPlace = endPlace;
|
||||
}
|
||||
|
||||
public LocalDateTime getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(LocalDateTime startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(LocalDateTime endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public float getMobilityScore() {
|
||||
return mobilityScore;
|
||||
}
|
||||
|
||||
public void setMobilityScore(float score) {
|
||||
this.mobilityScore = score;
|
||||
}
|
||||
|
||||
public float getCost() {
|
||||
return cost;
|
||||
}
|
||||
|
||||
public void setCost(float cost) {
|
||||
this.cost = cost;
|
||||
}
|
||||
|
||||
public Set<TripSegment> getSegments() {
|
||||
return segments;
|
||||
}
|
||||
|
||||
public void setSegments(Set<TripSegment> segments) {
|
||||
this.segments = segments;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user