package com.ruoyi.demo.entity.vo;

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 com.ruoyi.demo.entity.Plan;
import com.ruoyi.demo.utils.StateUtil;
import lombok.Data;

import java.time.LocalDateTime;

@Data
public class PlanManageListVo {
    private String planId;
    private String appName;
    private String goodsImg;
    private String goodsName;
    private Float goodsPrice;
    private String commercialName;
    private Integer equipmentCount;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime planStartTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime planEndTime;
    private String state;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime planCreateTime;

    public PlanManageListVo(){}
    public PlanManageListVo(Plan plan){
        this.planId = plan.getPlanId();
        this.commercialName = plan.getCommercialName();
        this.appName = plan.getAppName();
        this.goodsImg = plan.getGoodsImg();
        this.goodsName = plan.getGoodsName();
        this.goodsPrice = plan.getGoodsPrice();
        this.planCreateTime = plan.getPlanCreateTime();
        this.planStartTime = plan.getPlanStartTime();
        this.planEndTime = plan.getPlanEndTime();
        this.state = StateUtil.getStateName(plan.getState());
    }
}
