package com.uas.platform.b2b.model;

import com.alibaba.fastjson.annotation.JSONField;
import org.codehaus.jackson.annotate.JsonIgnore;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Set;

/**
 * 招标单产品信息
 *
 * Created by dongbw
 * 17/03/30 10:00.
 */
@Table( name = "purc$tenderprod")
@Entity
public class PurchaseTenderProd implements Serializable {

    /**
     * 序列号
     */
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "tp_id")
    private Long id;

    /**
     * 序号，用于按序显示
     */
    @Column(name = "tp_index")
    private Short index;

    /**
     * 物料名称
     */
    @Column(name = "tp_prodtitle")
    private String prodTitle;

    /**
     * 物料规格
     */
    @Column(name = "tp_prodspec")
    private String prodSpec;

    /**
     * 物料型号
     */
    @Column(name = "tp_prodcode")
    private String prodCode;

    /**
     * 品牌
     */
    @Column(name = "tp_brand")
    private String brand;

    /**
     * 单位
     */
    @Column(name = "tp_unit")
    private String unit;

    /**
     * 采购数量
     */
    @Column(name = "tp_qty")
    private Long qty;

    /**
     * 招标单
     */
    @ManyToOne(cascade = {CascadeType.REFRESH,CascadeType.PERSIST,CascadeType.MERGE})
    @JoinColumn(name = "tp_ptid", nullable = false)
    private PurchaseTenderSave tender;

    /**
     * 投标明细
     */
    @OneToMany(mappedBy = "tenderProd", cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
    @OrderBy("id")
    private Set<SaleTenderItem> saleTenderItems;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Short getIndex() {
        return index;
    }

    public void setIndex(Short index) {
        this.index = index;
    }

    public String getProdTitle() {
        return prodTitle;
    }

    public void setProdTitle(String prodTitle) {
        this.prodTitle = prodTitle;
    }

    public String getProdCode() {
        return prodCode;
    }

    public void setProdCode(String prodCode) {
        this.prodCode = prodCode;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public Long getQty() {
        return qty;
    }

    public void setQty(Long qty) {
        this.qty = qty;
    }

    public String getProdSpec() {
        return prodSpec;
    }

    public void setProdSpec(String prodSpec) {
        this.prodSpec = prodSpec;
    }

    @JsonIgnore
    @JSONField(serialize = false)
    public PurchaseTenderSave getTender() {
        return tender;
    }

    public void setTender(PurchaseTenderSave tender) {
        this.tender = tender;
    }


    public Set<SaleTenderItem> getSaleTenderItems() {
        return saleTenderItems;
    }

    public void setSaleTenderItems(Set<SaleTenderItem> saleTenderItems) {
        this.saleTenderItems = saleTenderItems;
    }
}
