package com.gic.haoban.manage.web.vo.content;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.gic.content.api.dto.additional.ContentMaterialAdditionalDTO;
import com.gic.content.api.dto.ext.ContentMaterialExt;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author MUSI
 * @Date 2022/10/28 1:52 PM
 * @Description
 * @Version
 **/
public class ContentMaterialInfoVO implements Serializable {

    private static final long serialVersionUID = 3274097803200172473L;
    /**
     * 素材id
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long contentMaterialId;

    /**
     * 素材标题
     */
    private String materialTitle;

    /**
     * 素材内容
     */
    private String materialContent;

    /**
     * 素材类型1图文2纯文字3纯图片4视频5图文/视频6文件7富文本
     */
    private Integer materialType;

    /**
     * 是否置顶0不置顶1置顶
     */
    private Integer topFlag = 0;

    /**
     * 是否支持下载1是0否
     */
    private Integer downloadFlag;

    /**
     * 发布时间
     */
    private Date publishTime;

    /**
     * 素材图片
     */
    private List<String> materialImageUrls;

    /**
     * 缩略图
     */
    private List<String> materialThumbnailImageUrls;

    /**
     * 素材图片信息列表{width:px,height:px,size:Bytes}
     */
    private String materialImageInfos;
    /**
     * 素材视频url
     */
    private String materialVideoUrl;
    /**
     * 视频信息{width:px,height:px,size:Bytes}
     */
    private String materialVideoInfo;
    /**
     * 素材视频封面url
     */
    private String materialVideoImageUrl;

    /**
     * 视频封面信息{width:px,height:px,size:Bytes}
     */
    private String materialVideoImageInfo;
    /**
     * 素材视频第一帧url
     */
    private String materialVideoFirstImageUrl;

    /**
     * 视频第一帧信息{width:px,height:px,size:Bytes}
     */
    private String materialVideoFirstImageInfo;

    /**
     * 素材首图url
     */
    private String materialFirstImageUrl;
    /**
     * 素材首图信息{width:px,height:px,size:Bytes}
     */
    private String materialFirstImageInfo;
    /**
     * 素材文件url
     */
    private String materialFileUrl;
    /**
     * 素材文件信息{size:Bytes,name:String}
     */
    private String materialFileInfo;

    /**
     * 分享次数
     */
    private Long shareCount;

    /**
     * 发布人id
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long producerId;

    /**
     * 发布人头像
     */
    private String avatar;

    /**
     * 发布人昵称
     */
    private String nickName;

    /**
     * 商品列表
     */
    private List<SimpleGoodsInfoVO> contentGoodsList;

    /**
     * 视频时长
     */
    private Integer duration;


    /**
     * 商品来源
     * @see com.gic.store.goods.enums.GoodsSourceTypeEnum
     */
    private Integer sourceType;

    /**
     * 点赞数
     */
    private Long likeCount;

    /**
     * 是否已点赞 1是0否
     */
    private Integer likeFlag;

    /**
     * 素材额外信息
     */
    private ContentMaterialExt ext;

    /**
     * 素材附件列表
     */
    private List<ContentMaterialAdditionalDTO> additionalList;


    public Long getContentMaterialId() {
        return contentMaterialId;
    }

    public void setContentMaterialId(Long contentMaterialId) {
        this.contentMaterialId = contentMaterialId;
    }

    public String getMaterialTitle() {
        return materialTitle;
    }

    public void setMaterialTitle(String materialTitle) {
        this.materialTitle = materialTitle;
    }

    public String getMaterialContent() {
        return materialContent;
    }

    public void setMaterialContent(String materialContent) {
        this.materialContent = materialContent;
    }

    public Integer getMaterialType() {
        return materialType;
    }

    public void setMaterialType(Integer materialType) {
        this.materialType = materialType;
    }

    public Integer getTopFlag() {
        return topFlag;
    }

    public void setTopFlag(Integer topFlag) {
        this.topFlag = topFlag;
    }

    public Integer getDownloadFlag() {
        return downloadFlag;
    }

    public void setDownloadFlag(Integer downloadFlag) {
        this.downloadFlag = downloadFlag;
    }

    public Date getPublishTime() {
        return publishTime;
    }

    public void setPublishTime(Date publishTime) {
        this.publishTime = publishTime;
    }

    public List<String> getMaterialImageUrls() {
        return materialImageUrls;
    }

    public void setMaterialImageUrls(List<String> materialImageUrls) {
        this.materialImageUrls = materialImageUrls;
    }

    public String getMaterialVideoUrl() {
        return materialVideoUrl;
    }

    public void setMaterialVideoUrl(String materialVideoUrl) {
        this.materialVideoUrl = materialVideoUrl;
    }

    public String getMaterialVideoImageUrl() {
        return materialVideoImageUrl;
    }

    public void setMaterialVideoImageUrl(String materialVideoImageUrl) {
        this.materialVideoImageUrl = materialVideoImageUrl;
    }

    public String getMaterialVideoFirstImageUrl() {
        return materialVideoFirstImageUrl;
    }

    public void setMaterialVideoFirstImageUrl(String materialVideoFirstImageUrl) {
        this.materialVideoFirstImageUrl = materialVideoFirstImageUrl;
    }

    public String getMaterialFirstImageUrl() {
        return materialFirstImageUrl;
    }

    public void setMaterialFirstImageUrl(String materialFirstImageUrl) {
        this.materialFirstImageUrl = materialFirstImageUrl;
    }

    public String getMaterialFirstImageInfo() {
        return materialFirstImageInfo;
    }

    public void setMaterialFirstImageInfo(String materialFirstImageInfo) {
        this.materialFirstImageInfo = materialFirstImageInfo;
    }

    public String getMaterialFileUrl() {
        return materialFileUrl;
    }

    public void setMaterialFileUrl(String materialFileUrl) {
        this.materialFileUrl = materialFileUrl;
    }

    public String getMaterialFileInfo() {
        return materialFileInfo;
    }

    public void setMaterialFileInfo(String materialFileInfo) {
        this.materialFileInfo = materialFileInfo;
    }

    public Long getShareCount() {
        return shareCount;
    }

    public void setShareCount(Long shareCount) {
        this.shareCount = shareCount;
    }

    public Long getProducerId() {
        return producerId;
    }

    public void setProducerId(Long producerId) {
        this.producerId = producerId;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public List<SimpleGoodsInfoVO> getContentGoodsList() {
        return contentGoodsList;
    }

    public void setContentGoodsList(List<SimpleGoodsInfoVO> contentGoodsList) {
        this.contentGoodsList = contentGoodsList;
    }

    public List<String> getMaterialThumbnailImageUrls() {
        return materialThumbnailImageUrls;
    }

    public void setMaterialThumbnailImageUrls(List<String> materialThumbnailImageUrls) {
        this.materialThumbnailImageUrls = materialThumbnailImageUrls;
    }

    public Integer getDuration() {
        return duration;
    }

    public void setDuration(Integer duration) {
        this.duration = duration;
    }

    public Integer getSourceType() {
        return sourceType;
    }

    public void setSourceType(Integer sourceType) {
        this.sourceType = sourceType;
    }

    public String getMaterialImageInfos() {
        return materialImageInfos;
    }

    public void setMaterialImageInfos(String materialImageInfos) {
        this.materialImageInfos = materialImageInfos;
    }

    public String getMaterialVideoInfo() {
        return materialVideoInfo;
    }

    public void setMaterialVideoInfo(String materialVideoInfo) {
        this.materialVideoInfo = materialVideoInfo;
    }

    public String getMaterialVideoImageInfo() {
        return materialVideoImageInfo;
    }

    public void setMaterialVideoImageInfo(String materialVideoImageInfo) {
        this.materialVideoImageInfo = materialVideoImageInfo;
    }

    public String getMaterialVideoFirstImageInfo() {
        return materialVideoFirstImageInfo;
    }

    public void setMaterialVideoFirstImageInfo(String materialVideoFirstImageInfo) {
        this.materialVideoFirstImageInfo = materialVideoFirstImageInfo;
    }

    public Long getLikeCount() {
        return likeCount;
    }

    public void setLikeCount(Long likeCount) {
        this.likeCount = likeCount;
    }

    public Integer getLikeFlag() {
        return likeFlag;
    }

    public void setLikeFlag(Integer likeFlag) {
        this.likeFlag = likeFlag;
    }

    public ContentMaterialExt getExt() {
        return ext;
    }

    public void setExt(ContentMaterialExt ext) {
        this.ext = ext;
    }

    public List<ContentMaterialAdditionalDTO> getAdditionalList() {
        return additionalList;
    }

    public void setAdditionalList(List<ContentMaterialAdditionalDTO> additionalList) {
        this.additionalList = additionalList;
    }

    public void convertMaterialImages(String materialImageUrls, String materialThumbnailImageUrls) {
        if (StringUtils.isNotBlank(materialImageUrls)) {
            String[] split = StringUtils.split(materialImageUrls, ",");
            List<String> imageUrls = Arrays.stream(split).collect(Collectors.toList());
            this.setMaterialImageUrls(imageUrls);
        }
        if (StringUtils.isNotBlank(materialThumbnailImageUrls)) {
            String[] split = StringUtils.split(materialThumbnailImageUrls, ",");
            List<String> imageUrls = Arrays.stream(split).collect(Collectors.toList());
            this.setMaterialThumbnailImageUrls(imageUrls);
        }
    }

}
