package com.slodon.b2b2c.vo.video;

import com.slodon.b2b2c.core.constant.VideoConst;
import com.slodon.b2b2c.core.util.FileUrlUtil;
import com.slodon.b2b2c.video.pojo.SvideoThemeVideo;
import com.slodon.b2b2c.video.pojo.SvideoVideo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

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

import static com.slodon.b2b2c.vo.video.VideoVO.dealImages;

/**
 *
 * 封装推荐主题的选择视频VO对象
 * @author wuxy
 */
@Data
public class SelectVideoVO implements Serializable {

    private static final long serialVersionUID = 6914650406195137357L;
    @ApiModelProperty("主题视频id")
    private Integer themeVideoId;

    @ApiModelProperty("视频id")
    private Integer videoId;

    @ApiModelProperty("视频名称")
    private String videoName;

    @ApiModelProperty("封面图地址")
    private String videoImage;

    @ApiModelProperty("视频地址")
    private String videoPath;

    @ApiModelProperty("视频简介")
    private String introduction;

    @ApiModelProperty("视频类型:1-视频;2-图文")
    private Integer videoType;

    @ApiModelProperty("视频类型:1-视频;2-图文")
    private String videoTypeValue;

    @ApiModelProperty("作者id")
    private Integer authorId;

    @ApiModelProperty("会员名称")
    private String memberName;

    @ApiModelProperty("会员昵称")
    private String memberNickname;

    @ApiModelProperty("会员头像")
    private String memberAvatar;

    @ApiModelProperty("点赞数")
    private Integer likeNum;

    @ApiModelProperty("点击数")
    private Integer clickNum;

    @ApiModelProperty("正文内容")
    private String videoContent;

    @ApiModelProperty("宽度")
    private Integer width;

    @ApiModelProperty("高度")
    private Integer height;

    @ApiModelProperty("图文图片列表")
    private List<String> imageList;

    public SelectVideoVO(SvideoThemeVideo svideoThemeVideo) {
        this.themeVideoId = svideoThemeVideo.getThemeVideoId();
        this.videoId = svideoThemeVideo.getVideoId();
        this.videoName = svideoThemeVideo.getVideoName();
        this.videoImage = FileUrlUtil.getFileUrl(svideoThemeVideo.getVideoImage(), null);
        this.videoPath = FileUrlUtil.getFileUrl(svideoThemeVideo.getVideoPath(), null);
        this.introduction = svideoThemeVideo.getIntroduction();
        this.videoType = svideoThemeVideo.getVideoType();
        this.videoTypeValue = VideoVO.dealVideoTypeValue(svideoThemeVideo.getVideoType());
    }

    public SelectVideoVO(SvideoThemeVideo svideoThemeVideo, SvideoVideo svideoVideo) {
        this.themeVideoId = svideoThemeVideo.getThemeVideoId();
        this.videoId = svideoThemeVideo.getVideoId();
        this.videoName = svideoThemeVideo.getVideoName();
        this.videoImage = FileUrlUtil.getFileUrl(svideoThemeVideo.getVideoImage(), null);
        this.videoPath = FileUrlUtil.getFileUrl(svideoThemeVideo.getVideoPath(), null);
        this.introduction = svideoThemeVideo.getIntroduction();
        this.videoType = svideoThemeVideo.getVideoType();
        this.videoTypeValue = VideoVO.dealVideoTypeValue(svideoThemeVideo.getVideoType());
        this.authorId = svideoVideo.getAuthorId();
        this.memberName = svideoVideo.getMemberName();
        this.memberNickname = svideoVideo.getMemberNickname();
        this.memberAvatar = svideoVideo.getMemberAvatar().startsWith("http") ? svideoVideo.getMemberAvatar() : FileUrlUtil.getFileUrl(svideoVideo.getMemberAvatar(), null);
        this.likeNum = svideoVideo.getLikeNum();
        this.clickNum = svideoVideo.getClickNum();
        this.videoContent = svideoVideo.getVideoContent();
        this.width = svideoVideo.getWidth();
        this.height = svideoVideo.getHeight();
        if (svideoVideo.getVideoType() == VideoConst.SVIDEO_TYPE_2) {
            this.imageList = dealImages(svideoVideo.getVideoImage());
        }
    }
}
