package com.qiaoba.api.tenant.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.qiaoba.common.base.entity.BaseEntity;
import com.qiaoba.common.base.validate.AddGroup;
import com.qiaoba.common.base.validate.EditGroup;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 租户数据源
 *
 * @author ailanyin
 * @version 1.0
 * @since 2023/6/7 14:38
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("sys_tenant_datasource")
public class SysTenantDatasource extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @TableId
    @NotNull(message = "id不能为空", groups = {EditGroup.class})
    private String datasourceId;

    @NotBlank(message = "数据源类型不能为空", groups = {AddGroup.class, EditGroup.class})
    @Schema(description = "数据源类型")
    private String type;

    @NotBlank(message = "数据库IP不能为空", groups = {AddGroup.class, EditGroup.class})
    @Schema(description = "数据库IP")
    private String ip;

    @NotBlank(message = "数据库端口不能为空", groups = {AddGroup.class, EditGroup.class})
    @Schema(description = "数据库端口")
    private String port;

    @NotBlank(message = "数据库名称不能为空", groups = {AddGroup.class, EditGroup.class})
    @Schema(description = "数据库名称")
    private String dbName;

    @Schema(description = "模式名称")
    private String schemaName;

    @NotBlank(message = "数据库账号不能为空", groups = {AddGroup.class, EditGroup.class})
    @Schema(description = "数据库账号")
    private String username;

    @NotBlank(message = "数据库密码不能为空", groups = {AddGroup.class, EditGroup.class})
    @Schema(description = "数据库密码")
    private String password;

    @Schema(description = "连接池-初始化大小-默认: 5")
    private Integer initCount;

    @Schema(description = "连接池-最小空闲线程数-默认: 10")
    private Integer minCount;

    @Schema(description = "连接池-最大连接池数量-默认: 20")
    private Integer maxCount;

    private String isPrimary;

    @NotBlank(message = "租户ID", groups = {AddGroup.class, EditGroup.class})
    @Schema(description = "租户ID")
    private String tenantId;
}
