package com.tzld.piaoquan.api.model.vo.contentplatform;

import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformUploadVideo;
import com.tzld.piaoquan.api.util.CdnUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

@Data
public class UploadVideoItemVO {
    @ApiModelProperty(value = "id")
    private Long id;
    @ApiModelProperty(value = "视频Id")
    private Long videoId;
    @ApiModelProperty(value = "视频标题")
    private String title;
    @ApiModelProperty(value = "视频封面")
    private String coverUrl;
    @ApiModelProperty(value = "视频url")
    private String videoUrl;
    @ApiModelProperty(value = "创建时间")
    private Long createTimeStamp;
    @ApiModelProperty(value = "审核状态 0-待审核 1-审核中 2-审核通过 3-审核不通过")
    private Integer auditStatus;
    @ApiModelProperty(value = "审核不通过原因")
    private String auditReason;

    public static UploadVideoItemVO convert(ContentPlatformUploadVideo uploadVideo) {
        if (uploadVideo == null) {
            return null;
        }
        UploadVideoItemVO uploadVideoItemVO = new UploadVideoItemVO();
        uploadVideoItemVO.setId(uploadVideo.getId());
        uploadVideoItemVO.setVideoId(uploadVideo.getVideoId());
        uploadVideoItemVO.setTitle(uploadVideo.getTitle());
        uploadVideoItemVO.setCoverUrl(uploadVideo.getCover());
        uploadVideoItemVO.setVideoUrl(uploadVideo.getVideo());
        uploadVideoItemVO.setCreateTimeStamp(uploadVideo.getCreateTimestamp());
        uploadVideoItemVO.setAuditStatus(uploadVideo.getAuditStatus());
        uploadVideoItemVO.setAuditReason(uploadVideo.getAuditReason());
        if (StringUtils.isNotBlank(uploadVideoItemVO.getCoverUrl())
                && !uploadVideoItemVO.getCoverUrl().startsWith("http")) {
            uploadVideoItemVO.setCoverUrl(CdnUtil.VIDEO_CDN_URL_HOST + uploadVideoItemVO.getCoverUrl());
        }
        if (StringUtils.isNotBlank(uploadVideoItemVO.getVideoUrl())
                && !uploadVideoItemVO.getVideoUrl().startsWith("http")) {
            uploadVideoItemVO.setVideoUrl(CdnUtil.VIDEO_CDN_URL_HOST + uploadVideoItemVO.getVideoUrl());
        }
        return uploadVideoItemVO;
    }
}
