package cn.com.ctop.toutiao.modules.material.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 org.jeecgframework.poi.excel.annotation.Excel;

import java.util.Date;

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

    /**
     * 素材id
     */
    @TableId
    @ApiModelProperty(value = "素材id")
    private Long id;
    /**
     * 平台广告主id
     */
    @Excel(name = "平台广告主id", width = 15)
    @ApiModelProperty(value = "平台广告主id")
    private String advertiserId;
    /**
     * 广告id
     */
    @Excel(name = "广告id", width = 15)
    @ApiModelProperty(value = "广告id")
    private Long adId;
    /**
     * 头天广告主id
     */
    @Excel(name = "头天广告主id", width = 15)
    @ApiModelProperty(value = "头天广告主id")
    private Long toutiaoId;
    /**
     * 创意标题
     */
    @Excel(name = "创意标题", width = 15)
    @ApiModelProperty(value = "创意标题")
    private String title;
    /**
     * 创意状态
     */
    @Excel(name = "创意状态", width = 15)
    @ApiModelProperty(value = "创意状态")
    private String status;
    /**
     * 创意状态
     */
    @Excel(name = "创意状态", width = 15)
    @ApiModelProperty(value = "创意状态")
    private String optStatus;
    /**
     * 创意类型
     */
    @Excel(name = "创意类型", width = 15)
    @ApiModelProperty(value = "创意类型")
    private String imageMode;
    /**
     * 图片素材信息
     */
    @Excel(name = "图片素材信息", width = 15)
    @ApiModelProperty(value = "图片素材信息")
    private String imageInfo;
    /**
     * createTime
     */
    @ApiModelProperty(value = "createTime")
    private Date createTime;
    /**
     * updateTime
     */
    @ApiModelProperty(value = "updateTime")
    private Date updateTime;

    public ByteDanceCreativeMaterial() {
    }

    public ByteDanceCreativeMaterial(JSONObject dataObject, String accountId) {
        this.id = dataObject.getLong("id");
        this.toutiaoId = dataObject.getLong("advertiser_id");

        String status = dataObject.getString("status");
        if (null != status && !"".equals(status.trim())) {
            this.status = status;
        }

        Long adId = dataObject.getLong("ad_id");
        if (null != adId) {
            this.adId = adId;
        }

        String title = dataObject.getString("title");
        if (null != title && !"".equals(title.trim())) {
            this.title = title;
        }

        String imageMode = dataObject.getString("image_mode");
        if (null != imageMode && !"".equals(imageMode.trim())) {
            this.imageMode = imageMode;
        }

        String imageInfo = dataObject.getString("image_info");
        if (null != imageInfo && !"".equals(imageInfo.trim())) {
            this.imageInfo = imageInfo;
        }

        String optStatus = dataObject.getString("opt_status");
        if (null != optStatus && !"".equals(optStatus.trim())) {
            this.optStatus = optStatus;
        }
    }
}
