package com.uas.search.console.b2b.model;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by hejq on 2017-11-08.
 */
@Table(name = ProductUsersSimpleInfo.TABLE_NAME)
@Entity
public class ProductUsersSimpleInfo {

    public static final String TABLE_NAME = "PRODUCT$USERS";

    public static final String ID_FIELD = "pu_id";

    public static final String USERUU_FIELD = "pu_useruu";

    public static final String ENUU_FIELD = "pu_enuu";

    public static final String PRODUCT_FIELD= "pu_prid";

    public static final String DATE_FIELD = "pu_date";

    /**
     * id
     */
    @Id
    @Column(name = ID_FIELD)
    private Long id;

    /**
     * 用户uu号
     */
    @Column(name = USERUU_FIELD)
    private Long useruu;

    /**
     * 企业uu
     */
    @Column(name = ENUU_FIELD)
    private Long enuu;

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

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

    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 Date getDate() {
        return date;
    }

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

    public ProdSimpleInfo getProduct() {
        return product;
    }

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

    /**
     * 获取所有可以搜索的字段列名（索引的field名）
     *
     * @return 可以搜索的字段列名
     */
    public static List<String> getKeywordFields() {
        List<String> fields = new ArrayList<>();
        fields.add(PRODUCT_FIELD);
        return fields;
    }

    @Override
    public String toString() {
        return "ProductUsersSimpleInfo{" +
                "id=" + id +
                ", useruu=" + useruu +
                ", enuu=" + enuu +
                ", date=" + date +
                ", product=" + product +
                '}';
    }
}
