package com.xxl.job.executor.material.entity;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xxl.job.executor.common.entity.CtopOauthToken;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * @Description: 今日头条创意信息
 * @Author: jeecg-boot
 * @Date: 2019-07-22
 * @Version: V1.0
 */
@Data
@TableName("ctop_bytedance_creative")
@Accessors(chain = true)
public class ByteDanceCreative {

    /**
     * 创意id
     */
    @TableId
    private Long id;
    /**
     * 广告计划id
     */
    private Long planId;
    /**
     * 本平台广告主id
     */
    private String accountId;
    /**
     * 创意素材标题
     */
    private String title;
    /**
     * 动态词包列表
     */
    private String creativeWordIds;
    /**
     * 创意素材状态
     */
    private String status;
    private String optStatus;
    /**
     * 创意素材类型
     */
    private String imageMode;
    /**
     * 图片素材id列表
     */
    private String imageIds;
    /**
     * 视频素材封面
     */
    private String imageId;
    /**
     * 视频id
     */
    private String videoId;
    /**
     * 创意审核信息
     */
    private String auditRejectReason;
    /**
     * 第三方id
     */
    private String thirdPartyId;
    /**
     * 广告创意创建时间
     */
    private String creativeCreateTime;
    /**
     * 广告创意更新时间
     */
    private String creativeModifyTime;
    /**
     * createTime
     */
    private Date createTime;
    /**
     * updateTime
     */
    private Date updateTime;
    @TableField(exist = false)
    private Boolean createStatus;

    public ByteDanceCreative(){

    }

    public ByteDanceCreative(JSONObject dataObject, CtopOauthToken token) {
        this.id = dataObject.getLong("creative_id");
        this.planId = dataObject.getLong("ad_id");
        this.accountId = token.getAccountId()+"";
        String title = dataObject.getString("title");
        if (null != title && !"".equals(title.trim())) {
            this.title = title;
        }
        String creativeWordIds = dataObject.getString("creative_word_ids");
        if (null != creativeWordIds && !"".equals(creativeWordIds.trim())) {
            this.creativeWordIds = creativeWordIds;
        }
        String status = dataObject.getString("status");
        if (null != status && !"".equals(status.trim())) {
            this.status = status;
        }
        String optStatus = dataObject.getString("opt_status");
        if(null!=optStatus&&!"".equals(optStatus.trim())){
            this.optStatus = optStatus;
        }
        String imageMode = dataObject.getString("image_mode");
        if (null != imageMode && !"".equals(imageMode.trim())) {
            this.imageMode = imageMode;
        }
        String imageIds = dataObject.getString("image_ids");
        if (null != imageIds && !"".equals(imageIds.trim())) {
            this.imageIds = imageIds;
        }
        String imageId = dataObject.getString("image_id");
        if (null != imageId && !"".equals(imageId.trim())) {
            this.imageId = imageId;
        }
        String videoId = dataObject.getString("video_id");
        if (null != videoId && !"".equals(videoId.trim())) {
            this.videoId = videoId;
        }
        String thirdPartyId = dataObject.getString("third_party_id");
        if (null != thirdPartyId && !"".equals(thirdPartyId.trim())) {
            this.thirdPartyId = thirdPartyId;
        }
        String auditRejectReason = dataObject.getString("audit_reject_reason");
        if (null != auditRejectReason && !"".equals(auditRejectReason.trim())) {
            this.auditRejectReason = auditRejectReason;
        }
        String creativeCreateTime = dataObject.getString("creative_create_time");
        if (null != creativeCreateTime && !"".equals(creativeCreateTime.trim())) {
            this.creativeCreateTime = creativeCreateTime;
        }
        String creativeModifyTime = dataObject.getString("creative_modify_time");
        if (null != creativeModifyTime && !"".equals(creativeModifyTime.trim())) {
            this.creativeModifyTime = creativeModifyTime;
        }
        Date now = new Date();
        this.createTime = now;
        this.updateTime = now;
    }

}
