package com.uas.platform.b2b.model;

import com.uas.platform.core.model.Status;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * 记录客户单据的未读状态
 *
 * Created by wangmh on 2017/7/21.
 */
@Table(name = "purc$userorders", indexes = { @Index(name = "puo_enuu_idx", columnList = "puo_enuu"), @Index(name = "puo_useruu_idx", columnList = "puo_useruu"),
        @Index(name = "puo_category_idx", columnList = "puo_category"), @Index(name = "puo_table_idx", columnList = "puo_table"),
        @Index(name = "puo_readstatus_idx", columnList = "puo_readstatus")})
@Entity
public class UserOrders {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "puo_id")
    private Long id;

    /**
     * 客户UU号
     */
    @NotNull
    @Column(name = "puo_useruu")
    private Long userUU;

    /**
     * 客户企业UU号
     */
    @NotNull
    @Column(name = "puo_enuu")
    private Long enUU;

    /**
     * 单据id（用于查询单据属性）
     */
    @NotNull
    @Column(name = "puo_sourceid")
    private Long sourceId;

    /**
     * 单据分类（purc or sale）
     */
    @NotNull
    @Column(name = "puo_category")
    private String category;

    /**
     * 单据表名（用于区分单据）、
     */
    @NotNull
    @Column(name = "puo_table")
    private String table;

    /**
     * 阅读状态（201表示已读, 200表示未读）
     */
    @NotNull
    @Column(name = "puo_readstatus")
    private Short readStatus = (short) Status.NOT_READ.value();

    /**
     * 单据阅读时间（用于定期删除）
     */
    @Column(name = "puo_readdate")
    private Date readDate;

    public UserOrders() {
    }

    public UserOrders(Long userUU, Long enUU, Long sourceId, String category, String table) {
        this.userUU = userUU;
        this.enUU = enUU;
        this.sourceId = sourceId;
        this.category = category;
        this.table = table;
        this.readStatus = (short) Status.NOT_READ.value();
    }

    public Long getId() {
        return id;
    }

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

    public Long getUserUU() {
        return userUU;
    }

    public void setUserUU(Long userUU) {
        this.userUU = userUU;
    }

    public Long getEnUU() {
        return enUU;
    }

    public void setEnUU(Long enUU) {
        this.enUU = enUU;
    }

    public Long getSourceId() {
        return sourceId;
    }

    public void setSourceId(Long sourceId) {
        this.sourceId = sourceId;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getTable() {
        return table;
    }

    public void setTable(String table) {
        this.table = table;
    }

    public Short getReadStatus() {
        return readStatus;
    }

    public void setReadStatus(Short readStatus) {
        this.readStatus = readStatus;
    }

    public Date getReadDate() {
        return readDate;
    }

    public void setReadDate(Date readDate) {
        this.readDate = readDate;
    }
}
