package com.slodon.b2b2c.vo.video;

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

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 *
 * 封装相关视频搜索VO对象
 * @author wuxy
 */
@Data
public class VideoSearchVO implements Serializable {

    private static final long serialVersionUID = 1879348356572752511L;
    @ApiModelProperty("视频id")
    private Integer videoId;

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

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

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

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

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

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

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

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

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

    @ApiModelProperty("评论数")
    private String commentNum;

    @ApiModelProperty("商品数")
    private Integer goodsNum;

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

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

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

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

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

    public VideoSearchVO(SvideoVideo svideoVideo) {
        this.videoId = svideoVideo.getVideoId();
        this.videoName = svideoVideo.getVideoName();
        this.videoPath = FileUrlUtil.getFileUrl(svideoVideo.getVideoPath(), null);
        this.videoImage = StringUtil.isEmpty(svideoVideo.getVideoThemeImage()) ? FileUrlUtil.getFileUrl(svideoVideo.getVideoImage(), null)
                : FileUrlUtil.getFileUrl(svideoVideo.getVideoThemeImage(), null);
        this.introduction = svideoVideo.getIntroduction();
        this.authorId = svideoVideo.getAuthorId();
        this.memberName = svideoVideo.getMemberName();
        this.memberNickname = svideoVideo.getMemberNickname();
        this.likeNum = svideoVideo.getLikeNum() < 10000 ? svideoVideo.getLikeNum().toString()
                : new BigDecimal(svideoVideo.getLikeNum()).divide(new BigDecimal(10000), 1, RoundingMode.FLOOR) + "w";
        this.commentNum = svideoVideo.getCommentNum() < 10000 ? svideoVideo.getCommentNum().toString()
                : new BigDecimal(svideoVideo.getCommentNum()).divide(new BigDecimal(10000), 1, RoundingMode.FLOOR) + "w";
        this.goodsNum = svideoVideo.getGoodsNum();
        this.clickNum = svideoVideo.getClickNum() < 10000 ? svideoVideo.getClickNum().toString()
                : new BigDecimal(svideoVideo.getClickNum()).divide(new BigDecimal(10000), 1, RoundingMode.FLOOR) + "w";
        this.videoType = svideoVideo.getVideoType();
        this.videoContent = svideoVideo.getVideoContent();
        this.width = svideoVideo.getWidth();
        this.height = svideoVideo.getHeight();
    }
}
