package com.carmaintenance.entity; import lombok.Data; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; import javax.persistence.*; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; /** * 车辆档案实体 */ @Data @Entity @Table(name = "vehicles") @EntityListeners(AuditingEntityListener.class) public class Vehicle { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "vehicle_id") private Integer vehicleId; @Column(name = "customer_id", nullable = false) private Integer customerId; @Column(name = "license_plate", nullable = false, unique = true, length = 20) private String licensePlate; @Column(name = "brand", nullable = false, length = 50) private String brand; @Column(name = "model", nullable = false, length = 50) private String model; @Column(name = "color", length = 20) private String color; @Column(name = "vin", unique = true, length = 17) private String vin; @Column(name = "engine_no", length = 50) private String engineNo; @Column(name = "purchase_date") private LocalDate purchaseDate; @Column(name = "mileage", precision = 10, scale = 2) private BigDecimal mileage = BigDecimal.ZERO; @Column(name = "last_maintenance_date") private LocalDate lastMaintenanceDate; @Column(name = "next_maintenance_date") private LocalDate nextMaintenanceDate; @Enumerated(EnumType.STRING) @Column(name = "status") private VehicleStatus status = VehicleStatus.normal; @CreatedDate @Column(name = "create_time", updatable = false) private LocalDateTime createTime; @LastModifiedDate @Column(name = "update_time") private LocalDateTime updateTime; public enum VehicleStatus { normal, in_service, completed } }