package com.njcn.gather.source.pojo.param;

import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.pojo.constant.DetectionValidMessage;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.math.BigDecimal;

/**
 * @author caozehui
 * @data 2024-11-28
 */
@Data
public class PqSourceParam {

    /**
     * 检测源名称（检测源类型 + 设备类型 + 数字自动生成）
     */
//    @ApiModelProperty(value = "检测源名称", required = true)
//    @NotBlank(message = DeviceValidMessage.NAME_NOT_BLANK)
//    @Pattern(regexp = PatternRegex.PQ_SOURCE_NAME, message = DeviceValidMessage.PQ_SOURCE_NAME_FORMAT_ERROR)
//    private String name;

    /**
     * 检测模式，字典表
     */
    @NotBlank(message = DetectionValidMessage.PATTERN_NOT_BLANK)
    @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PATTERN_FORMAT_ERROR)
    private String pattern;

    /**
     * 检测源类型，字典表
     */
    @ApiModelProperty(value = "检测源类型", required = true)
    @NotBlank(message = DetectionValidMessage.PQ_SOURCE_TYPE_NOT_BLANK)
    @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PQ_SOURCE_TYPE_FORMAT_ERROR)
    private String type;

    /**
     * 设备类型，字典表
     */
    @ApiModelProperty(value = "设备类型", required = true)
    @NotBlank(message = DetectionValidMessage.DEV_TYPE_NOT_BLANK)
    @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.DEV_TYPE_FORMAT_ERROR)
    private String devType;

    @ApiModelProperty("源参数")
    private String parameter;

    @ApiModelProperty("最大电压")
    @DecimalMin("0")
    private BigDecimal maxVoltage;

    @ApiModelProperty("最大电流")
    @DecimalMin("0")
    private BigDecimal maxCurrent;


    @Data
    public static class QueryParam extends BaseParam {
        @ApiModelProperty(value = "检测源名称")
        private String name;

        @ApiModelProperty("模式")
        @NotBlank(message = DetectionValidMessage.PATTERN_NOT_BLANK)
        @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PATTERN_FORMAT_ERROR)
        private String pattern;

        @ApiModelProperty(value = "检测源类型")
        @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PQ_SOURCE_TYPE_FORMAT_ERROR)
        private String type;

        @ApiModelProperty(value = "设备类型")
        @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.DEV_TYPE_FORMAT_ERROR)
        private String devType;
    }

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class UpdateParam extends PqSourceParam {
        @ApiModelProperty(value = "检测源ID", required = true)
        @NotBlank(message = DetectionValidMessage.ID_NOT_BLANK)
        @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR)
        private String id;
    }
}
