package cn.com.ctop.crawler.modules.oceanengine.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.Base64;
import java.util.Date;

/**
 * 效果案例
 */
@Data
@TableName("ctop_oceanengine_effect_case")
public class EffectCase {
    @TableId(value = "id", type = IdType.INPUT)
    private String id;
    private String coverUrl;
    private String vid;
    @JsonProperty("creative_label_1")
    @TableField(value = "creative_label_1")
    private String creativeLabel1;
    @JsonProperty("creative_label_2")
    @TableField(value = "creative_label_2")
    private Integer creativeLabel2;
    @JsonProperty("create_date")
    private String createDate;
    @JsonProperty("creative_id")
    private Long creativeId;
    private String methods;
    @JsonProperty("video_url")
    private String videoUrl;
    private String author;
    private String effect;
    @JsonProperty("conversion_type")
    private String conversionType;
//    private String coverImage;
    private String creativeLabel;
    private String tag;
    @JsonProperty("creative_title")
    private String creativeTitle;
    @JsonProperty("creative_info")
    private String creativeInfo;
    @JsonProperty("creative_score")
    private String creativeScore;
    @JsonProperty("industry_tag")
    private String industryTag;
    private Date createTime;
    private Date updateTime;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getVid() {
        return vid;
    }

    public void setVid(String vid) {
        this.vid = vid;
    }

    public String getCreativeLabel1() {
        return creativeLabel1;
    }

    public void setCreativeLabel1(String creativeLabel1) {
        this.creativeLabel1 = creativeLabel1;
    }

    public Integer getCreativeLabel2() {
        return creativeLabel2;
    }

    public void setCreativeLabel2(Integer creativeLabel2) {
        this.creativeLabel2 = creativeLabel2;
    }

    public String getCreateDate() {
        return createDate;
    }

    public void setCreateDate(String createDate) {
        this.createDate = createDate;
    }

    public Long getCreativeId() {
        return creativeId;
    }

    public void setCreativeId(Long creativeId) {
        this.creativeId = creativeId;
    }

    public String getMethods() {
        return methods;
    }

    public void setMethods(String methods) {
        this.methods = methods;
    }

    public String getVideoUrl() {
        return videoUrl;
    }

    public void setVideoUrl(String videoUrl) {
        this.videoUrl = videoUrl;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getEffect() {
        return effect;
    }

    public void setEffect(String effect) {
        this.effect = effect;
    }

    public String getConversionType() {
        return conversionType;
    }

    public void setConversionType(String conversionType) {
        this.conversionType = conversionType;
    }
    public String getCreativeLabel() {
        return creativeLabel;
    }

    public void setCreativeLabel(String creativeLabel) {
        this.creativeLabel = creativeLabel;
    }

    public String getTag() {
        return tag;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

    public String getCreativeTitle() {
        return creativeTitle;
    }

    public void setCreativeTitle(String creativeTitle) {
        this.creativeTitle = creativeTitle;
    }

    public String getCreativeInfo() {
        return creativeInfo;
    }

    public void setCreativeInfo(String creativeInfo) {
        this.creativeInfo = creativeInfo;
    }

    public String getCreativeScore() {
        return creativeScore;
    }

    public void setCreativeScore(String creativeScore) {
        this.creativeScore = creativeScore;
    }

    public String getIndustryTag() {
        return industryTag;
    }

    public void setIndustryTag(String industryTag) {
        this.industryTag = industryTag;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public static void base64ToFile(String destPath,String base64, String fileName) {
        File file = null;
        //创建文件目录
        String filePath=destPath;
        File  dir=new File(filePath);
        if (!dir.exists() && !dir.isDirectory()) {
            dir.mkdirs();
        }
        BufferedOutputStream bos = null;
        java.io.FileOutputStream fos = null;
        try {
            byte[] bytes = Base64.getMimeDecoder().decode(base64);
            file=new File(filePath+"/"+fileName);
            fos = new java.io.FileOutputStream(file);
            bos = new BufferedOutputStream(fos);
            bos.write(bytes);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (bos != null) {
                try {
                    bos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (fos != null) {
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
