package me.zhengjie.modules.dm.statement.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

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

@Entity
@Data
@Table(name="dm_statement")
public class DmStatement implements Serializable {
    @Id
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)//设置自增
    private Integer id;

    @Column(name = "name")
    @ApiModelProperty(value = "组织名称")
    private String name;

    @Column(name = "money")
    @ApiModelProperty(value = "消费金额")
    private String money;

    @Column(name = "avg_money")
    @ApiModelProperty(value = "人均消费")
    private String avgMoney;

    @Column(name = "order_time")
    @ApiModelProperty(value = "统计时段")
    private Timestamp orderTime;


    public void copy(DmStatement source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }

    @PrePersist
    public void prePersist() {
        this.orderTime = new Timestamp(new Date().getTime());
    }
}
