package com.ruoyi.demo.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.ZoneId;

@Data
@TableName("dl_goods")
public class Goods {
    @TableField("appkey")
    private String appkey;

    @TableField("app_name")
    private String appName;
    @TableField("vendor_id")
    private String vendorId;
    @TableField("vendor_name")
    private String vendorName;

    @TableField("goods_id")
    private String goodsId;
    @TableField("goods_img")
    private String goodsImg;
    @TableField("goods_name")
    private String goodsName;
    @TableField("goods_logo")
    private String goodsLogo;
    @TableField("goods_introduce")
    private String goodsIntroduce;
    @TableField("goods_price")
    private Float goodsPrice;
    @TableField("goods_classify")
    private String goodsClassify;
    @TableField("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime createTime;

    @TableField("deleted")
    private int deleted;

    public Goods(){}
    public Goods(Plan plan){
        this.appkey = plan.getAppkey();
        this.appName = plan.getAppName();

        this.vendorId = plan.getVendorId();
        this.vendorName = plan.getVendorName();

        this.goodsId = plan.getGoodsId();
        this.goodsImg = plan.getGoodsImg();
        this.goodsName = plan.getGoodsName();
        this.goodsLogo = plan.getGoodsLogo();
        this.goodsIntroduce = plan.getGoodsIntroduce();
        this.goodsPrice = plan.getGoodsPrice();
        this.goodsClassify = plan.getGoodsClassify();
        this.createTime = LocalDateTime.now(ZoneId.of("Asia/Shanghai"));
    }
}
