package com.slodon.b2b2c.vo.video;

import com.slodon.b2b2c.core.response.PagerInfo;
import com.slodon.b2b2c.core.util.FileUrlUtil;
import com.slodon.b2b2c.video.pojo.SvideoTheme;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

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

/**
 *
 * 封装前端主题VO对象
 * @author wuxy
 */
@Data
public class FrontThemeVO implements Serializable {

    private static final long serialVersionUID = 3937022098777373236L;
    @ApiModelProperty("主题信息")
    private ThemeInfoVO themeInfo;

    @ApiModelProperty("视频列表")
    private List<SelectVideoVO> videoList;

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

    public FrontThemeVO(ThemeInfoVO themeInfo, List<SelectVideoVO> videoList, PagerInfo pager) {
        this.themeInfo = themeInfo;
        this.videoList = videoList;
        if (pager != null) {
            this.pagination = new Pagination(pager.getPageIndex(), pager.getPageSize(), pager.getRowsCount());
        }
    }

    @Data
    public static class ThemeInfoVO implements Serializable {

        private static final long serialVersionUID = -842250605843887679L;
        @ApiModelProperty("主题id")
        private Integer themeId;

        @ApiModelProperty("主题名称")
        private String themeName;

        @ApiModelProperty("主题图片")
        private String image;

        @ApiModelProperty("封面图，用于轮播")
        private String carouselImage;

        public ThemeInfoVO(SvideoTheme svideoTheme) {
            this.themeId = svideoTheme.getThemeId();
            this.themeName = svideoTheme.getThemeName();
            this.image = FileUrlUtil.getFileUrl(svideoTheme.getImage(), null);
            this.carouselImage = FileUrlUtil.getFileUrl(svideoTheme.getCarouselImage(), null);
        }
    }

    @Data
    private class Pagination implements Serializable {

        private static final long serialVersionUID = -8013874439184854287L;
        @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;
        }
    }
}