package cn.com.ctop.toutiao.entity;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import cn.com.ctop.common.module.entity.CtopOauthToken;
import org.jeecgframework.poi.excel.annotation.Excel;

import java.util.Date;

/**
 * @Description: 今日头条视频素材信息
 * @Author: jeecg-boot
 * @Date: 2019-07-29
 * @Version: V1.0
 */
@Data
@TableName("ctop_bytedance_video_info")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "ctop_bytedance_video_info对象", description = "今日头条视频素材信息")
public class ByteDanceVideoInfo {

    /**
     * id
     */
    @TableId()
    @ApiModelProperty(value = "id")
    private String id;
    /**
     * 对应本文件id
     */
    @Excel(name = "对应本文件id", width = 15)
    @ApiModelProperty(value = "对应本文件id")
    private String fileId;
    /**
     * 平台账号id
     */
    @Excel(name = "平台账号id", width = 15)
    @ApiModelProperty(value = "平台账号id")
    private String advertiserId;
    /**
     * 对应本文件id
     */
    @Excel(name = "头条账号id", width = 15)
    @ApiModelProperty(value = "头条账号id")
    private Long accountId;
    /**
     * 视频宽度
     */
    @Excel(name = "视频宽度", width = 15)
    @ApiModelProperty(value = "视频宽度")
    private Integer width;
    /**
     * 视频高度
     */
    @Excel(name = "视频高度", width = 15)
    @ApiModelProperty(value = "视频高度")
    private Integer height;
    /**
     * 视频时长
     */
    @Excel(name = "视频时长", width = 15)
    @ApiModelProperty(value = "视频时长")
    private Double duration;
    /**
     * 视频大小
     */
    @Excel(name = "视频大小", width = 15)
    @ApiModelProperty(value = "视频大小")
    private Long size;
    /**
     * 视频地址
     */
    @Excel(name = "视频地址", width = 15)
    @ApiModelProperty(value = "视频地址")
    private String videoUrl;
    /**
     * status
     */
    @Excel(name = "status", width = 15)
    @ApiModelProperty(value = "status")
    private Integer status;
    /**
     * createTime
     */
    @ApiModelProperty(value = "createTime")
    private Date createTime;
    /**
     * updateTime
     */
    @ApiModelProperty(value = "updateTime")
    private Date updateTime;

    public ByteDanceVideoInfo(JSONObject data, CtopOauthToken token) {
        this.id = data.getString("video_id");
        this.fileId = id;
        this.accountId = token.getAccountId();
        this.advertiserId = token.getAdvertiserId();
        this.width = data.getInteger("width");
        this.height = data.getInteger("width");
        this.size = data.getLong("size");
        this.duration = data.getDouble("duration");
        this.videoUrl = data.getString("video_url");
        this.status = 1;
        Date now = new Date();
        this.createTime = now;
        this.updateTime = now;
    }

    public ByteDanceVideoInfo() {
    }
}
