Register PostNord shipments, admin notes, and guarded status transitions with customer emails. Expandable admin UI, V11 migration, serial E2E suite, and AGENTS.md Docker-only E2E guidance. Co-authored-by: Cursor <cursoragent@cursor.com>
162 lines
3.6 KiB
Java
162 lines
3.6 KiB
Java
package se.bilhalsning.entity;
|
|
|
|
import jakarta.persistence.Column;
|
|
import jakarta.persistence.Entity;
|
|
import jakarta.persistence.FetchType;
|
|
import jakarta.persistence.Id;
|
|
import jakarta.persistence.JoinColumn;
|
|
import jakarta.persistence.ManyToOne;
|
|
import jakarta.persistence.PrePersist;
|
|
import jakarta.persistence.PreUpdate;
|
|
import jakarta.persistence.Table;
|
|
import java.math.BigDecimal;
|
|
import java.time.Instant;
|
|
import java.util.UUID;
|
|
|
|
@Entity
|
|
@Table(name = "orders")
|
|
public class Order {
|
|
|
|
@Id
|
|
@Column(name = "id", columnDefinition = "uuid", nullable = false, updatable = false)
|
|
private UUID id;
|
|
|
|
@Column(name = "user_id", nullable = false, columnDefinition = "uuid")
|
|
private UUID userId;
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
|
@JoinColumn(name = "user_id", insertable = false, updatable = false)
|
|
private User user;
|
|
|
|
@Column(name = "plate", nullable = false, length = 10)
|
|
private String plate;
|
|
|
|
@Column(name = "letter_text", nullable = false, columnDefinition = "text")
|
|
private String letterText;
|
|
|
|
@Column(name = "status", nullable = false, length = 30)
|
|
private OrderStatus status = OrderStatus.PENDING_PAYMENT;
|
|
|
|
@Column(name = "amount_paid", precision = 10, scale = 2)
|
|
private BigDecimal amountPaid;
|
|
|
|
@Column(name = "tracking_id", length = 100)
|
|
private String trackingId;
|
|
|
|
@Column(name = "shipped_at")
|
|
private Instant shippedAt;
|
|
|
|
@Column(name = "admin_notes", columnDefinition = "text")
|
|
private String adminNotes;
|
|
|
|
@Column(name = "created_at", nullable = false)
|
|
private Instant createdAt;
|
|
|
|
@Column(name = "updated_at", nullable = false)
|
|
private Instant updatedAt;
|
|
|
|
@PrePersist
|
|
void onCreate() {
|
|
if (this.id == null) {
|
|
this.id = UUID.randomUUID();
|
|
}
|
|
Instant now = Instant.now();
|
|
if (this.createdAt == null) {
|
|
this.createdAt = now;
|
|
}
|
|
this.updatedAt = now;
|
|
}
|
|
|
|
@PreUpdate
|
|
void onUpdate() {
|
|
this.updatedAt = Instant.now();
|
|
}
|
|
|
|
public UUID getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(UUID id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public UUID getUserId() {
|
|
return userId;
|
|
}
|
|
|
|
public void setUserId(UUID userId) {
|
|
this.userId = userId;
|
|
}
|
|
|
|
public User getUser() {
|
|
return user;
|
|
}
|
|
|
|
public void setUser(User user) {
|
|
this.user = user;
|
|
}
|
|
|
|
public String getPlate() {
|
|
return plate;
|
|
}
|
|
|
|
public void setPlate(String plate) {
|
|
this.plate = plate;
|
|
}
|
|
|
|
public String getLetterText() {
|
|
return letterText;
|
|
}
|
|
|
|
public void setLetterText(String letterText) {
|
|
this.letterText = letterText;
|
|
}
|
|
|
|
public OrderStatus getStatus() {
|
|
return status;
|
|
}
|
|
|
|
public void setStatus(OrderStatus status) {
|
|
this.status = status;
|
|
}
|
|
|
|
public BigDecimal getAmountPaid() {
|
|
return amountPaid;
|
|
}
|
|
|
|
public void setAmountPaid(BigDecimal amountPaid) {
|
|
this.amountPaid = amountPaid;
|
|
}
|
|
|
|
public String getTrackingId() {
|
|
return trackingId;
|
|
}
|
|
|
|
public void setTrackingId(String trackingId) {
|
|
this.trackingId = trackingId;
|
|
}
|
|
|
|
public Instant getShippedAt() {
|
|
return shippedAt;
|
|
}
|
|
|
|
public void setShippedAt(Instant shippedAt) {
|
|
this.shippedAt = shippedAt;
|
|
}
|
|
|
|
public String getAdminNotes() {
|
|
return adminNotes;
|
|
}
|
|
|
|
public void setAdminNotes(String adminNotes) {
|
|
this.adminNotes = adminNotes;
|
|
}
|
|
|
|
public Instant getCreatedAt() {
|
|
return createdAt;
|
|
}
|
|
|
|
public Instant getUpdatedAt() {
|
|
return updatedAt;
|
|
}
|
|
}
|