Implemented story 1 and missing utils
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
package de.etecture.ga.model;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.jdbc.core.mapping.AggregateReference;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
|
||||
import de.etecture.ga.util.DateTimeUtil;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -17,46 +16,48 @@ import lombok.experimental.Accessors;
|
||||
@Data
|
||||
@Accessors(fluent = true, chain = true)
|
||||
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
|
||||
public class Appointment implements Comparable<Appointment>{
|
||||
public class Appointment implements Comparable<Appointment> {
|
||||
|
||||
@Id
|
||||
@EqualsAndHashCode.Include
|
||||
private Long id;
|
||||
|
||||
|
||||
@Column("GARAGE_ID")
|
||||
private AggregateReference<Garage, Long> garageId;
|
||||
|
||||
|
||||
@Column("SERVICE_ID")
|
||||
private AggregateReference<MDService, Long> serviceId;
|
||||
|
||||
|
||||
@EqualsAndHashCode.Include
|
||||
private String serviceCode;
|
||||
|
||||
|
||||
private String serviceName;
|
||||
|
||||
|
||||
@EqualsAndHashCode.Include
|
||||
private Date appointmentTime;
|
||||
|
||||
|
||||
@EqualsAndHashCode.Include
|
||||
private Integer slot = 1;
|
||||
|
||||
|
||||
private Duration duration = Duration.ZERO;
|
||||
|
||||
|
||||
|
||||
public LocalDateTime appointmentStart() {
|
||||
return Instant.ofEpochMilli(this.appointmentTime().getTime())
|
||||
.atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
if (this.appointmentTime == null)
|
||||
return null;
|
||||
return DateTimeUtil.toLocalDateTime(this.appointmentTime);
|
||||
}
|
||||
|
||||
|
||||
public LocalDateTime appointmentEnd() {
|
||||
if (this.appointmentTime == null)
|
||||
return null;
|
||||
return this.appointmentStart().plus(this.duration());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(Appointment o) {
|
||||
if(o == null || o.appointmentTime() == null) return 1;
|
||||
|
||||
if (o == null || o.appointmentTime() == null)
|
||||
return 1;
|
||||
|
||||
return this.appointmentTime().compareTo(o.appointmentTime());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user