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.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

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

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

    @Column(name = "zg_name")
    @ApiModelProperty(value = "菜品受欢迎前三-菜品名称")
    private String zgName;

    @Column(name = "zg_num")
    @ApiModelProperty(value = "菜品受欢迎前三-购买次数")
    private String zgNum;

    @Column(name = "zd_name")
    @ApiModelProperty(value = "最不受欢迎菜品")
    private String zdName;

    @Column(name = "zd_num")
    @ApiModelProperty(value = "最不受欢迎菜品-购买次数")
    private String zdNum;

    @Column(name = "money")
    @ApiModelProperty(value = "最不受欢迎菜品-总消费")
    private String money;

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

    @Column(name = "week_time")
    @ApiModelProperty(value = "周-统计时段")
    private String weekTime;


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

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