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

import com.cf.imes.module.report.validation.datasource.SqlIllegalValid;
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.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

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

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

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

    @Schema(description = "数据源id", example = "1")
    @NotNull(message = "数据源id不能为空")
    private Long datasourceId;

    @Schema(description = "动态查询SQL")
    @SqlIllegalValid
    private String sql;

    @Schema(description = "bean数据源方法名")
    @Length(min = 1, max = 64, message = "bean数据源方法名长度不能超过64个字符")
    private String method;

    @Schema(description = "参数列表")
    @Size(max = 30, message = "参数列表数量不能超过30个")
    @Valid
    private List<ReportDatasetParameterVO> parameters = new ArrayList<>();

    @Schema(description = "字段列表")
    @Size(max = 100, message = "字段列表数量不能超过100个")
    @Valid
    private List<ReportDatasetFieldVO> fields = new ArrayList<>();
}
