package com.cf.imes.module.report.controller.admin.datasource.vo;

import com.cf.imes.module.report.validation.datasource.ReportDatasourceTypeInEnum;
import com.cf.imes.module.report.validation.template.ReportTemplateTypeInEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * @author Gqr
 * @since 2024/7/8 11:01
 */
@Schema(description = "管理后台 - 报表数据源新增/修改 Request VO")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ReportDatasourceSaveReqVO implements Serializable {
    @Serial
    private static final long serialVersionUID = -1738392826420649562L;

    @Schema(description = "数据源id", example = "1")
    private Long id;

    @Schema(description = "数据源名称", example = "测试库")
    @NotBlank
    @Length(min = 1, max = 64, message = "数据源名称长度不能超过64个字符")
    private String name;

    @Schema(description = "数据源类型，jdbc、spring、api", example = "1")
    @ReportDatasourceTypeInEnum
    private String type;

    @Schema(description = "内置数据源类型，0是、1否", example = "1")
    @ReportTemplateTypeInEnum
    private Integer buildinType;

    @Schema(description = "spring型数据源id")
    @Length(max = 64, message = "spring型数据源id长度不能超过64个字符")
    private String beanId;

    @Schema(description = "数据源驱动类",example = "com.mysql.cj.jdbc.Driver")
    @Length(max = 64, message = "数据源驱动类长度不能超过64个字符")
    private String driver;

    @Schema(description = "数据源地址", example = "https://www.cf.com")
    @Length(max = 255, message = "数据源地址长度不能超过255个字符")
    private String url;

    @Schema(description = "数据源用户名", example = "晨丰")
    @Length(max = 64, message = "数据源用户名长度不能超过64个字符")
    private String username;

    @Schema(description = "数据源密码", example = "晨丰")
    @Length(max = 64, message = "数据源密码长度不能超过64个字符")
    private String password;

    @Schema(description = "备注", example = "该模板仅供生产使用")
    @Length(max = 64, message = "备注长度不能超过64个字符")
    private String remark;

    @Schema(description = "请求头参数")
    @Size(max = 30, message = "请求头参数数量不能超过30个")
    private List<Map<String, String>> headers;
}
