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.Date;
import java.util.Set;

/**
 * 投标方提问单 （招标单关联）
 * Created by dongbw
 * 17/09/07 18:17.
 */
@Table(name = "sale$tenderquestion")
@Entity
public class PurchaseTenderQuestion implements Serializable {

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

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

    /**
     * 提问编号
     */
    @Column(name = "stq_code")
    private String code;

    /**
     * 投标企业UU
     */
    @Column(name = "stq_venduu")
    private Long vendUU;

    /**
     * 投标企业
     */
    @OneToOne
    @JoinColumn(name = "stq_venduu", insertable = false, updatable = false)
    private Enterprise vendor;

    /**
     * 提出时间
     */
    @Column(name = "stq_indate")
    private Date inDate;

    /**
     * 回复时间
     */
    @Column(name = "stq_replydate")
    private Date replyDate;

    /**
     * 提问主题
     */
    @Column(name = "stq_topic")
    private String topic;

    /**
     * 处理状态
     */
    @Column(name = "stq_status")
    private Short status;

    /**
     * 咨询内容
     */
    @Column(name = "stq_content")
    private String content;

    /**
     * 投标单id
     */
    @Column(name = "stq_stid")
    private Long stId;

    /**
     * 招标答疑单
     */
    @ManyToOne(cascade = CascadeType.REFRESH)
    @JoinColumn(name = "stq_ptaid", nullable = false)
    private PurchaseTenderAnswer purchaseTenderAnswer;

    /**
     * 提问附件
     */
    @OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.REFRESH})
    @JoinTable(name = "sale$tenderquestionattach", joinColumns = @JoinColumn(name = "stq_id", referencedColumnName = "stq_id"), inverseJoinColumns = @JoinColumn(name="at_id", referencedColumnName = "at_id"))
    private Set<Attach> questionAttaches;

    public Long getId() {
        return id;
    }

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

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }


    public Long getVendUU() {
        return vendUU;
    }

    public void setVendUU(Long vendUU) {
        this.vendUU = vendUU;
    }

    public Date getInDate() {
        return inDate;
    }

    public void setInDate(Date inDate) {
        this.inDate = inDate;
    }

    public Date getReplyDate() {
        return replyDate;
    }

    public void setReplyDate(Date replyDate) {
        this.replyDate = replyDate;
    }

    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }

    public Short getStatus() {
        return status;
    }

    public void setStatus(Short status) {
        this.status = status;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Enterprise getVendor() {
        return vendor;
    }

    public void setVendor(Enterprise vendor) {
        this.vendor = vendor;
    }

    @JsonIgnore
    @JSONField(serialize = false)
    public PurchaseTenderAnswer getPurchaseTenderAnswer() {
        return purchaseTenderAnswer;
    }

    public void setPurchaseTenderAnswer(PurchaseTenderAnswer purchaseTenderAnswer) {
        this.purchaseTenderAnswer = purchaseTenderAnswer;
    }

    public Set<Attach> getQuestionAttaches() {
        return questionAttaches;
    }

    public void setQuestionAttaches(Set<Attach> questionAttaches) {
        this.questionAttaches = questionAttaches;
    }

    public Long getStId() {
        return stId;
    }

    public void setStId(Long stId) {
        this.stId = stId;
    }
}
