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 lombok.NoArgsConstructor;

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

/**
 *
 * 封装front端短视频列表VO对象
 * @author wuxy
 */
@Data
@NoArgsConstructor
public class FrontVideoVO implements Serializable {

    private static final long serialVersionUID = 6956956489938070046L;
    @ApiModelProperty("标签列表")
    private List<VideoLabelVO> labelList;

    @ApiModelProperty("主题列表")
    private List<ThemeVO> themeList;

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

    @ApiModelProperty("当前登录会员头像")
    private String memberAvatar;

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

    public FrontVideoVO(List<VideoLabelVO> labelList, List<ThemeVO> themeList, List<VideoSearchVO> videoList, String memberAvatar, PagerInfo pager) {
        this.labelList = labelList;
        this.themeList = themeList;
        this.videoList = videoList;
        this.memberAvatar = memberAvatar;
        if (pager != null) {
            this.pagination = new Pagination(pager.getPageIndex(), pager.getPageSize(), pager.getRowsCount());
        }
    }

    @Data
    public static class ThemeVO implements Serializable {

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

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

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

        @ApiModelProperty("标签id")
        private Integer labelId;

        public ThemeVO(SvideoTheme svideoTheme) {
            this.themeId = svideoTheme.getThemeId();
            this.themeName = svideoTheme.getThemeName();
            this.carouselImage = FileUrlUtil.getFileUrl(svideoTheme.getCarouselImage(), null);
            this.labelId = svideoTheme.getLabelId();
        }
    }

    @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;
        }
    }
}
