package me.zhengjie.modules.dmApp.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import me.zhengjie.modules.dm.statement.domain.DmEvaluate;

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

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

    @Column(name = "name")
    @ApiModelProperty(value = "菜品名称")
    private String name;

    @Column(name = "picture")
    @ApiModelProperty(value = "菜品图片")
    private String picture;

    @Column(name = "user_code")
    @ApiModelProperty(value = "用户id")
    private String userCode;

    @Column(name = "bh")
    @ApiModelProperty(value = "订单编号")
    private String bh;

    @Column(name = "code")
    @ApiModelProperty(value = "菜品编号")
    private String code;

    @Column(name = "type")
    @ApiModelProperty(value = "菜品类型")
    private String type;

    @Column(name = "order_time")
    @ApiModelProperty(value = "下单时间")
    private Timestamp orderTime;

    public void copy(AppFoodPj source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
    @PrePersist
    public void prePersist() {
        this.orderTime = new Timestamp(new Date().getTime());
    }
}
