package com.ylcm.sys.excel.model;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalTime;

import javax.validation.constraints.NotNull;

import org.springframework.beans.BeanUtils;

import com.alibaba.excel.annotation.ExcelProperty;
import com.ylcm.sys.common.EnumHelperUtil;
import com.ylcm.sys.domain.AdSpecial;
import com.ylcm.sys.enums.AdSpecialShowEnvEnum;
import com.ylcm.sys.excel.converter.FloatConverter;
import com.ylcm.sys.excel.converter.LocalDateConverter;
import com.ylcm.sys.excel.converter.LocalTimeConverter;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class AdSpecialPlatformExportDTO implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 3863153959765813542L;

    @NotNull
    @ApiModelProperty(value = "栏目名称")
    @ExcelProperty(index = 0, value="栏目名称")
    private String productName;

    @ApiModelProperty(value = "内容")
    @ExcelProperty(index = 1, value="内容")
    private String brandName;

    @ApiModelProperty(value = "广告主")
    @ExcelProperty(index = 2, value="广告主")
    private String advMaster;

    @NotNull
    @ApiModelProperty(value = "播出媒体")
    @ExcelProperty(index = 3, value="播出媒体")
    private String mediaName;

    @NotNull
    @ExcelProperty(index = 4, value="播出环境 ")
    private String showEnv;

    @NotNull
    @ApiModelProperty(value = "播出节目")
    @ExcelProperty(index = 5, value="播出节目")
    private String tvName;

    @NotNull
    @ApiModelProperty(value = "播出日期")
    @ExcelProperty(index = 6, converter = LocalDateConverter.class, value="播出日期")
    private LocalDate showDate;
    
    @NotNull
    @ApiModelProperty(value = "播出时间")
    @ExcelProperty(index = 7, converter = LocalTimeConverter.class, value="播出时间")
    private LocalTime showTime;
    
    @ApiModelProperty(value = "联系方式")
    @ExcelProperty(index = 8, value="联系方式")
    private String phone = "";
    
    @ApiModelProperty(value = "播出时长(单位分)")
    @ExcelProperty(index = 9, converter = FloatConverter.class, value="播出时长(单位分)")
    private Float showDuration;
    
    @ApiModelProperty(value = "刊例(万）")
    @ExcelProperty(index = 10, value="刊例(万）")
    private BigDecimal price;
    
    public static AdSpecialPlatformExportDTO from(AdSpecial adSpecial) {
    	AdSpecialPlatformExportDTO exportDTO = new AdSpecialPlatformExportDTO();
    	BeanUtils.copyProperties(adSpecial, exportDTO);

    	AdSpecialShowEnvEnum showEnvEnum = EnumHelperUtil.getOneByCode(AdSpecialShowEnvEnum.class, adSpecial.getShowEnv() + "");
    	exportDTO.setShowEnv(showEnvEnum.getName());
    	
    	return exportDTO;
    }
}
