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.LocalDateTime;

/**
 * 配件库存实体
 */
@Data
@Entity
@Table(name = "parts_inventory")
@EntityListeners(AuditingEntityListener.class)
public class PartsInventory {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "part_id")
    private Integer partId;

    @Column(name = "part_no", nullable = false, unique = true, length = 50)
    private String partNo;

    @Column(name = "part_name", nullable = false, length = 100)
    private String partName;

    @Column(name = "category", length = 50)
    private String category;

    @Column(name = "brand", length = 50)
    private String brand;

    @Column(name = "model", length = 100)
    private String model;

    @Column(name = "unit", length = 20)
    private String unit = "个";

    @Column(name = "unit_price", nullable = false, precision = 10, scale = 2)
    private BigDecimal unitPrice;

    @Column(name = "stock_quantity")
    private Integer stockQuantity = 0;

    @Column(name = "min_stock")
    private Integer minStock = 10;

    @Column(name = "supplier", length = 100)
    private String supplier;

    @Column(name = "warehouse_location", length = 50)
    private String warehouseLocation;

    @Column(name = "status")
    private Integer status = 1;

    @Column(name = "remark", columnDefinition = "TEXT")
    private String remark;

    @CreatedDate
    @Column(name = "create_time", updatable = false)
    private LocalDateTime createTime;

    @LastModifiedDate
    @Column(name = "update_time")
    private LocalDateTime updateTime;
}
