package com.slodon.b2b2c.vo.goods;

import com.slodon.b2b2c.core.response.PagerInfo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 *
 * 封装商品分类树VO对象
 * @author wuxy
 */
@Data
public class GoodsCategoryTreeVO implements Serializable {

    private static final long serialVersionUID = -8248211718510653845L;
    @ApiModelProperty("分类列表")
    private List<CategoryInfoVO> categoryList;

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

    @ApiModelProperty("分页信息")
    private Pagination pagination;

    public GoodsCategoryTreeVO(List<CategoryInfoVO> categoryList, List<GoodsListVO> goodsList, PagerInfo pager) {
        this.categoryList = categoryList;
        this.goodsList = goodsList;
        if (pager != null) {
            this.pagination = new Pagination(pager.getPageIndex(), pager.getPageSize(), pager.getRowsCount());
        }
    }

    @Data
    public static class CategoryInfoVO implements Serializable {
        private static final long serialVersionUID = -3086953169223502087L;
        @ApiModelProperty("分类ID")
        private Integer categoryId;

        @ApiModelProperty("分类名称")
        private String categoryName;

        @ApiModelProperty("父类ID")
        private Integer pid;

        @ApiModelProperty("分类级别: 1-一级，2-二级，3-三级")
        private Integer grade;

        @ApiModelProperty("移动端分类图片路径（仅在二三级分类使用）")
        private String categoryImage;
    }

    @Data
    private class Pagination implements Serializable {

        private static final long serialVersionUID = 4732437527680993671L;
        @ApiModelProperty("当前页面位置")
        private Integer current;
        @ApiModelProperty("分页大小")
        private Integer pageSize;
        @ApiModelProperty("总数")
        private Integer total;

        private Pagination(Integer current, Integer pageSize, Integer total) {
            this.current = current;
            this.pageSize = pageSize;
            this.total = total;
        }
    }
}
