package com.ylcm.sys.vo;

import java.math.BigDecimal;

import org.springframework.beans.BeanUtils;

import com.ylcm.sys.common.DateUtil;
import com.ylcm.sys.common.EnumHelperUtil;
import com.ylcm.sys.domain.AdSpecial;
import com.ylcm.sys.enums.AdSpecialShowEnvEnum;

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

@Data
public class AdSpecialVO {
	
	private Integer id;

	@ApiModelProperty(value = "0广告 1栏目")
	private Integer type;
	
    @ApiModelProperty(value = "产品名称")
    private String productName;

    @ApiModelProperty(value = "品牌")
    private String brandName;

    @ApiModelProperty(value = "广告主")
    private String advMaster;

    @ApiModelProperty(value = "播出媒体")
    private String mediaName;

    @ApiModelProperty(value = "播出环境 0电视剧 1综艺 2广告")
    private String showEnv;

    @ApiModelProperty(value = "播出节目")
    private String tvName;

    @ApiModelProperty(value = "播出时间")
    private String showTime;
    
    @ApiModelProperty(value = "播出日期")
    private String showDate;
    
    @ApiModelProperty(value = "播出时长(单位分)")
    private Float showDuration;
    
    @ApiModelProperty(value = "价格")
    private BigDecimal price;
    
    @ApiModelProperty(value = "联系方式")
    private String phone;
    
    public static AdSpecialVO from(AdSpecial adSpecial) {
    	AdSpecialVO adSpecialVO = new AdSpecialVO();
    	
    	BeanUtils.copyProperties(adSpecial, adSpecialVO);
    	adSpecialVO.setShowDate(DateUtil.date2Str(adSpecial.getShowDate(), "yyyy-MM-dd"));
    	adSpecialVO.setShowTime(DateUtil.time2Str(adSpecial.getShowTime(), "HH:mm:ss"));
    	
    	AdSpecialShowEnvEnum showEnvEnum = EnumHelperUtil.getOneByCode(AdSpecialShowEnvEnum.class, adSpecial.getShowEnv() + "");
    	if (showEnvEnum != null) {
			adSpecialVO.setShowEnv(showEnvEnum.getName());
		}
    	
    	return adSpecialVO;
    }
}
