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 org.jeecgframework.poi.excel.annotation.Excel;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 今日头条广告主预算信息
 *
 * @author jeecg-boot
 * @version V1.0
 * @date 2019-07-22
 */
@Data
@TableName("ctop_bytedance_advertiser_budget")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "ctop_bytedance_advertiser_budget对象", description = "今日头条广告主预算信息")
public class ByteDanceAdvertiserBudget {

    /**
     * 头条广告主id
     */
    @TableId
    @ApiModelProperty(value = "头条广告主id")
    private Long id;
    /**
     * 平台账号id
     */
    @Excel(name = "平台账号id", width = 15)
    @ApiModelProperty(value = "平台账号id")
    private String advertiserId;
    @Excel(name = "预算类型")
    private String budgetMode;
    @Excel(name = "预算数量", width = 15)
    @ApiModelProperty(value = "预算数量")
    private BigDecimal budget;
    /**
     * createTime
     */
    @ApiModelProperty(value = "createTime")
    private Date createTime;
    /**
     * updateTime
     */
    @ApiModelProperty(value = "updateTime")
    private Date updateTime;

    public ByteDanceAdvertiserBudget() {
    }

    public ByteDanceAdvertiserBudget(JSONObject dataObject, String accountId) {
        Long advertiserId = dataObject.getLong("advertiser_id");
        this.id = advertiserId;
        this.advertiserId = accountId;
        String budgetMode = dataObject.getString("budget_mode");
        if (null != budgetMode && !"".equals(budgetMode.trim())) {
            this.budgetMode = budgetMode;
        }
        BigDecimal budget = dataObject.getBigDecimal("budget");
        if (null != budget) {
            this.budget = budget;
        }
        Date now = new Date();
        this.createTime = now;
        this.updateTime = now;
    }
}
