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;
import java.util.List;

@Data
public class PlanManageDetailVo {
    private String planId;
    private String appName;
    private String goodsName;
    private String goodsImg;
    private Float goodsPrice;
    private String goodsLogo;
    private String commercialName;
    private String state;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime planCreateTime;
    private List<PlanManageItemVo> planItems;

    public PlanManageDetailVo(){}
    public PlanManageDetailVo(Plan plan, List<PlanManageItemVo> itemVos){
        this.planId = plan.getPlanId();
        this.appName = plan.getAppName();
        this.goodsName = plan.getGoodsName();
        this.goodsImg = plan.getGoodsImg();
        this.goodsPrice = plan.getGoodsPrice();
        this.goodsLogo = plan.getGoodsLogo();
        this.commercialName = plan.getCommercialName();
        this.state = StateUtil.getStateName(plan.getState());
        this.planCreateTime = plan.getPlanCreateTime();
        this.planItems = itemVos;
    }
}
