package com.uas.platform.b2b.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.uas.platform.b2b.erp.model.SaleTenderErp;
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:10.
 */
@Table(name = "sale$tenderquestion")
@Entity
public class SaleTenderQuestion 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;

    /**
     * 投标单
     */
    @ManyToOne(cascade = CascadeType.REFRESH)
    @JoinColumn(name = "stq_stid", nullable = false)
    private SaleTenderErp saleTender;

    /**
     * 招标答疑单
     */
    @ManyToOne(cascade = {CascadeType.REFRESH, CascadeType.MERGE})
    @JoinColumn(name = "stq_ptaid", nullable = false)
    private SaleTenderAnswer saleTenderAnswer;

    /**
     * 提问附件
     */
    @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 Enterprise getVendor() {
        return vendor;
    }

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

    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 Set<Attach> getQuestionAttaches() {
        return questionAttaches;
    }

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

    public SaleTenderAnswer getSaleTenderAnswer() {
        return saleTenderAnswer;
    }

    public void setSaleTenderAnswer(SaleTenderAnswer saleTenderAnswer) {
        this.saleTenderAnswer = saleTenderAnswer;
    }

    @JsonIgnore
    @JSONField(serialize = false)
    public SaleTenderErp getSaleTender() {
        return saleTender;
    }

    public void setSaleTender(SaleTenderErp saleTender) {
        this.saleTender = saleTender;
    }
}
