package com.slodon.b2b2c.vo.goods;

import com.slodon.b2b2c.core.constant.ImageSizeEnum;
import com.slodon.b2b2c.core.util.FileUrlUtil;
import com.slodon.b2b2c.goods.pojo.Goods;
import com.slodon.b2b2c.goods.pojo.GoodsRank;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 *
 * 封装更多榜单推荐VO对象
 * @author wuxy
 */
@Data
public class RankRecommendVO {

    @ApiModelProperty("榜单id")
    private Integer rankId;

    @ApiModelProperty("榜单名称")
    private String rankName;

    @ApiModelProperty("商品列表")
    private List<RankRecommendGoodsVO> goodsList;

    public RankRecommendVO(GoodsRank goodsRank) {
        this.rankId = goodsRank.getRankId();
        this.rankName = goodsRank.getRankName();
    }

    @Data
    public static class RankRecommendGoodsVO {

        @ApiModelProperty("商品id")
        private Long goodsId;

        @ApiModelProperty("商品名称")
        private String goodsName;

        @ApiModelProperty("商品图片")
        private String goodsImage;

        @ApiModelProperty("商品价格")
        private BigDecimal productPrice;

        @ApiModelProperty("货品id")
        private Long productId;

        public RankRecommendGoodsVO(Goods goods) {
            this.goodsId = goods.getGoodsId();
            this.goodsName = goods.getGoodsName();
            this.goodsImage = FileUrlUtil.getFileUrl(goods.getMainImage(), ImageSizeEnum._300x300);
            this.productPrice = goods.getGoodsPrice();
            this.productId = goods.getDefaultProductId();
        }
    }
}
