package com.ylcm.sys.vo;

import com.ylcm.sys.common.DateUtil;
import com.ylcm.sys.domain.AdTheatre;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;

import java.time.LocalTime;

/**
 * 剧场数据管理-页面需要的数据
 * @author liuyu
 */
@Data
public class AdTheatreVO {

    @ApiModelProperty(value = "id")
    private Integer id;
    @ApiModelProperty(value = "剧名")
    private String name;
    @ApiModelProperty(value = "媒体")
    private String mediaName;
    @ApiModelProperty(value = "集数")
    private Integer mediaNum;
    @ApiModelProperty(value = "体裁")
    private String firstTheme;
    @ApiModelProperty(value = "细分体裁")
    private String secondTheme;
    @ApiModelProperty(value = "播出日期")
    private String showDate;
    @ApiModelProperty(value = "播出时间")
    private String showTime;
    @ApiModelProperty(value = "类型0产品 1栏目")
    private Integer type;
    @ApiModelProperty(value = "产品或栏目名称")
    private String typeName;
    @ApiModelProperty(value = "进线预估（元）")
    private Integer jinxian;
    @ApiModelProperty(value = "时长（分）")
    private Float duration;

    public AdTheatre toAdTheatre(){
        AdTheatre adTheatre = new AdTheatre();
        BeanUtils.copyProperties(this, adTheatre);
        if (StringUtils.isNotBlank(this.showDate)){
            adTheatre.setShowDate(DateUtil.str2Date(this.showDate));
        }
        if (StringUtils.isNotBlank(this.showTime)){
            adTheatre.setShowTime(LocalTime.parse(this.showTime));
        }
        return adTheatre;
    }
}
