package com.mosty.base.model.dto.bkzx;

/**
 *
 */

import com.mosty.base.enums.BKDbTypeEnum;
import com.mosty.common.base.exception.BusinessException;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

/**
 * @author dw
 * @since 2022-07-13
 * 布控车辆审批 dto
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "TbVBkDbInsertDto", description = "布控数据新建模型 ")
public class TbBkDbInsertDto implements Serializable {

    @NotBlank(message="创建布控数据库名无效！")
    @ApiModelProperty(value = "布控库名")
    private String  dbName;

    @ApiModelProperty(value = "库描述信息")
    private String description;

    @NotNull(message = "创建布控数据库类型信息无效！")
    @ApiModelProperty(value = "数据库类型：All所有(包含人车)，Personnel 人员，Car 车辆",hidden = true)
    private BKDbTypeEnum dbType = BKDbTypeEnum.All;

    @NotBlank(message = "所属市区域代码无效！")
    @ApiModelProperty(value = "所属市区域代码无效")
    private String  areaCode;

    @ApiModelProperty(value = "所属市/区名字")
    private String  areaName;

    @ApiModelProperty(value = "布控开始时间，格式：yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date bkKassj;

    @ApiModelProperty(value = "布控结束时间，格式：yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date   bkJssj;


    public void checkData() throws BusinessException {
        if(StringUtils.isEmpty(dbName)){
            throw  new BusinessException("创建布控数据库名无效！");
        }
        if(StringUtils.isEmpty(areaCode)){
            throw  new BusinessException("所属市公安局代码无效！");
        }
        if(null == dbType){
            throw  new BusinessException("创建布控数据库类型信息无效！");
        }
    }
}
