package com.uas.platform.b2b.model;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

/**
 * 用户个人产品库
 *
 * Created by hejq on 2017-11-08.
 */
@Table(name = "product$users", indexes = {@Index(name = "UNIQUE_ENUU_USERUU_PRID", columnList = "pu_useruu,pu_enuu,pu_prid", unique = true)})
@Entity
public class ProductUsers implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = 1L;

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

    /**
     * 用户uu
     */
    @NotNull
    @Column(name = "pu_useruu")
    private Long useruu;

    /**
     * 企业uu，方便统计处理
     */
    @NotNull
    @Column(name = "pu_enuu")
    private Long enuu;

    /**
     * 物料id
     */
    @NotNull
    @Column(name = "pu_prid")
    private Long prid;

    /**
     * 产品
     */
    @OneToOne(cascade = { CascadeType.REFRESH })
    @JoinColumn(name = "pu_prid", insertable = false, updatable = false)
    private Product product;

    /**
     * 日期
     */
    @Column(name = "pu_date")
    private Date date;

    /**
     * 存在ERP同步过来数据的情况，记录id
     */
    @Column(name = "pu_erpid")
    private Long erpid;

    public ProductUsers() {

    }

    public ProductUsers(Long prId, Long enUU, Long userUU, Date date) {
        this.setPrid(prId);
        this.setEnuu(enUU);
        this.setUseruu(userUU);
        this.setDate(date);
    }

    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 getPrid() {
        return prid;
    }

    public void setPrid(Long prid) {
        this.prid = prid;
    }

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Long getErpid() {
        return erpid;
    }

    public void setErpid(Long erpid) {
        this.erpid = erpid;
    }
}
