package com.ylcm.sys.excel.model;

import java.io.Serializable;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;

import com.alibaba.excel.annotation.ExcelProperty;
import com.ylcm.sys.common.Constants;
import com.ylcm.sys.domain.AdTv;
import com.ylcm.sys.enums.PicUploadEnum;

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

/**
 *     电视剧导入
 * @author admin
 *
 */
@Data
public class AdTvImportDTO implements Serializable{

	private static final long serialVersionUID = 3863153959765813542L;

    @ApiModelProperty(value = "电视剧名称")
    @ExcelProperty(index = 0)
    private String name;
    
    @ApiModelProperty(value = "电视剧海报")
    @ExcelProperty(index = 1)
    private String imgUrl;

    @ApiModelProperty(value = "体裁")
    @ExcelProperty(index = 2)
    private String firstTheme;

    @ApiModelProperty(value = "细分体裁")
    @ExcelProperty(index = 3)
    private String secondTheme;
    
    private String msg = "";

    public void check() {
        if (StringUtils.isBlank(name)) {
  			msg = "电视剧名称不能为空";
  			return;
  		}
		if (name.length() > 20) {
			msg = "电视剧名称长度不能超过20个字";
			return;
		}
		if (StringUtils.isBlank(firstTheme)) {
			msg = "体裁不能为空";
			return;
		}
		if (StringUtils.isBlank(secondTheme)) {
			msg = "细分体裁不能为空";
			return;
		}
    }
    
    public AdTv toAdTv() {
    	AdTv adTv = new AdTv();
    	if (StringUtils.isNotBlank(imgUrl)) {
			imgUrl = Constants.PIC_BASE_URL + PicUploadEnum.TV.getName() + imgUrl;
		}
    	BeanUtils.copyProperties(this, adTv);
    	return adTv;
    }
}
