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_evaluate")
@NoArgsConstructor
@AllArgsConstructor
public class DmEvaluate implements Serializable {
    @Id
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)//设置自增
    private Integer id;

    @Column(name = "total_point")
    @ApiModelProperty(value = "综合评分")
    private String totalPoint;

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

    @Column(name = "wd_point")
    @ApiModelProperty(value = "味道")
    private Integer wdPoint;

    @Column(name = "pz_point")
    @ApiModelProperty(value = "品种")
    private Integer pzPoint;

    @Column(name = "fl_point")
    @ApiModelProperty(value = "分量")
    private Integer flPoint;

    @Column(name = "fwtd_point")
    @ApiModelProperty(value = "服务态度")
    private Integer fwtdPoint;

    @Column(name = "hjws_point")
    @ApiModelProperty(value = "环境卫生")
    private Integer hjwsPoint;

    @Column(name = "zhfw_point")
    @ApiModelProperty(value = "综合服务")
    private Integer zhfwPoint;

    @Column(name = "cxgj_point")
    @ApiModelProperty(value = "持续改进")
    private Integer cxgjPoint;

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

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