package com.fzm.mall.server.front.asset.model.vo.good;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fzm.mall.server.front.asset.model.vo.good.GoodSpuPropertyVO;
import com.fzm.mall.server.front.asset.model.vo.other.ClazzGoodVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
 * @author tdz
 * @date 2021/02/22 11:26
 */
@Data
@ApiModel("商品基础信息")
public class GoodSpuVO {
    @ApiModelProperty("商户编号")
    private String uid;
    @ApiModelProperty("商户名称")
    private String business;
    @ApiModelProperty("商品编号")
    private String gid;
    @ApiModelProperty("类目名称参数")
    private ClazzGoodVO clazz;
    @ApiModelProperty("商品名称")
    private String name;
    @ApiModelProperty("商品描述")
    private String description;
    @ApiModelProperty("商品类型，0->全新，1->转卖")
    private Integer type;
    @ApiModelProperty("商品属性")
    private List<GoodSpuPropertyVO> properties;
    @ApiModelProperty("视频地址")
    private String video;
    @ApiModelProperty("视频缩略图地址")
    private String videoThumb;
    @ApiModelProperty("缩略图地址")
    private String thumb;
    @ApiModelProperty("详情图片地址")
    private List<String> images;
    @ApiModelProperty("详情图文")
    private String detail;


    @JsonIgnore
    private String propertiesJson;
    @JsonIgnore
    private String imagesJson;

    public void setPropertiesJson(String propertiesJson) throws Exception {
        this.propertiesJson = propertiesJson;
        this.properties = JSON.parseArray(propertiesJson, GoodSpuPropertyVO.class);
    }

    public void setImagesJson(String imagesJson) throws Exception {
        this.imagesJson = imagesJson;
        this.images = JSON.parseArray(imagesJson, String.class);
    }
}
