package com.ff.weijinxiao.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.ff.weijinxiao.util.jsonfilter.DateSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * 客户
 */
@Data
@Entity
@Table(name = "tb_paybacksupplier")
public class SupplierPayBack implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "tid")
    private Integer id;

    @ManyToOne(cascade=CascadeType.ALL)
    @JoinColumn(name = "supplier_id",referencedColumnName="onlyID",foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private Supplier supplier;

    @Column(name = "payAmount")
    @ApiModelProperty(value = "还款金额")
    private Float payAmount;

    @Column(name = "payWay")
    @ApiModelProperty(value = "付款方式 1=现金 2=刷卡 3=支付宝 4=微信")
    private Integer payWay;

    @Column(name = "isDelete")
    @ApiModelProperty(value = "是否是删除状态(0:否；1:是)")
    private Integer isDelete = 0;

    @Column(name = "uid")
    @ApiModelProperty(value = "用户登录uid（所有数据查询需要根据人员账号查询）")
    private String uid;

    @Transient
    @ApiModelProperty(value = "创建者姓名")
    private String userName;

    @Column(name = "create_time")
    @ApiModelProperty(value = "创建时间")
    @org.hibernate.annotations.CreationTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = DateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")//json序列化实体类处理
    private Date createTime;

    @Column(name = "update_time")
    @ApiModelProperty(value = "更新时间")
    @org.hibernate.annotations.UpdateTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = DateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")//json序列化实体类处理
    private Date modifyTime;

    @Column(name = "onlyID")
    @ApiModelProperty(value = "onlyID")
    private String onlyID;

    @OneToOne
    @JoinColumn(name = "book_id",referencedColumnName="id",foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    @ApiModelProperty(value = "激活账本ID")
    private AccountBook accountBook;
}
