package com.njcn.gather.type.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.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * @author caozehui
 * @data 2025-02-10
 */
@Data
public class DevTypeParam {
    @ApiModelProperty(value = "名称", required = true)
    @NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
    @Pattern(regexp = PatternRegex.DEV_TYPE_NAME_REGEX, message = DetectionValidMessage.DEV_TYPE_NAME_FORMAT_ERROR)
    private String name;

    @ApiModelProperty(value = "设备关联的ICD", required = true)
    @NotBlank(message = DetectionValidMessage.ICD_NOT_BLANK)
    private String icd;

    @ApiModelProperty(value = "设备关联的PQDIF", required = true)
    @NotBlank(message = "PQDIF不能为空")
    @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR)
    private String pqdif;

    @ApiModelProperty(value = "工作电源", required = true)
    @NotBlank(message = DetectionValidMessage.POWER_NOT_BLANK)
    private String power;

    @ApiModelProperty(value = "额定电压", required = true)
    @NotNull(message = DetectionValidMessage.VOLT_NOT_BLANK)
    private Double devVolt;

    @ApiModelProperty(value = "额定电流", required = true)
    @NotNull(message = DetectionValidMessage.CURR_NOT_BLANK)
    private Double devCurr;

    @ApiModelProperty(value = "通道数", required = true)
    @NotNull(message = DetectionValidMessage.CHNS_NOT_BLANK)
    @Min(value = 1, message = DetectionValidMessage.DEV_CHNS_RANGE_ERROR)
    private Integer devChns;

    @ApiModelProperty(value = "报告模板")
    private String reportName;

    @ApiModelProperty(value = "录波指令")
    private String waveCmd;

    /**
     * 分页查询实体
     */
    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class QueryParam extends BaseParam {
        @ApiModelProperty(value = "名称", required = true)
        private String name;
    }

    /**
     * 更新参数
     */
    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class UpdateParam extends DevTypeParam {

        @ApiModelProperty(value = "id", required = true)
        @NotBlank(message = DetectionValidMessage.ID_NOT_BLANK)
        @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR)
        private String id;
    }
}
