/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.etl.entity.bi;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.SqlCondition;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.TenantEntity;
import org.springblade.datasource.enums.DsTypeEnum;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 报表数据源实体类
 *
 * @author BladeX
 * @since 2021-03-22
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "ReportDatasource对象", description = "报表数据源")
public class ReportDatasource extends TenantEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键自增
     */
    @ApiModelProperty(value = "主键自增")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * ip地址
     */
    @ApiModelProperty(value = "ip地址")
    @NotNull(message = "IP地址不能为空")
    private String dsIp;
    /**
     * 端口
     */
    @ApiModelProperty(value = "端口")
    @NotNull(message = "端口不能为空")
    private Integer dsPort;
    /**
     * 数据库名/SID
     */
    @ApiModelProperty(value = "数据库名/SID")
    @NotNull(message = "数据库名不能为空")
    @TableField(condition = SqlCondition.LIKE)
    private String dsDb;
    /**
     * 连接url
     */
    @ApiModelProperty(value = "连接url")
    private String url;
    /**
     * 连接名称
     */
    @ApiModelProperty(value = "连接名称")
    private String poolName;
    /**
     * driverClassName
     */
    @ApiModelProperty(value = "driverClassName")
    private String driverClassName;
    /**
     * 用户名
     */
    @ApiModelProperty(value = "用户名")
    @NotNull(message = "用户名不能为空")
    private String dsUser;
    /**
     * 密码
     */
    @ApiModelProperty(value = "密码")
    private String dsPassword;
    /**
     * 数据源类型 {@link DsTypeEnum}
     */
    @ApiModelProperty(value = "数据源类型 0-mysql 1-oracle 2-sqlserver 3-postgresql 4-clickhouse 5-kingbase")
    @NotNull(message = "数据源类型不能为空")
    private Integer dsType;

    @ApiModelProperty("数据源模式 postgresql和kingbase需要")
    private String dbSchema;
    /**
     * 备注
     */
    @ApiModelProperty(value = "备注")
    private String remark;
    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createTime;

    @ApiModelProperty(value = "创建人ID")
    private Long createUserId;

    @ApiModelProperty(value = "负责人ID")
    private Long responsiblePersonId;

    @ApiModelProperty(value = "负责人姓名")
    private String responsiblePersonName;
    
    @ApiModelProperty(value = "是否可以被编辑，0：不可以，1：可以")
	private Integer isEdit;

    @ApiModelProperty(value = "数据源类型字符串")
    @TableField(exist = false)
    private DsTypeEnum dsTypeSyl;

    @ApiModelProperty(value = "自定义jdbc驱动连接属性[暂未使用]")
    @TableField(exist = false)
    private String customConnectProperties;

    public DsTypeEnum getDsTypeSyl() {
        return this.getDsType() != null ? DsTypeEnum.resolve(this.getDsType()) : dsTypeSyl;
    }
}
