package com.njcn.gather.device.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 org.hibernate.validator.constraints.Range;

import javax.validation.constraints.*;
import java.util.List;

/**
 * @author caozehui
 * @data 2025-05-09
 */
@Data
public class PqStandardDevParam {
    @ApiModelProperty(value = "名称", required = true)
    @NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
    @Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DetectionValidMessage.NAME_FORMAT_ERROR)
    private String name;

    @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(value = "设备厂家", required = true)
    @NotBlank(message = DetectionValidMessage.MANUFACTURER_NOT_BLANK)
    @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.MANUFACTURER_FORMAT_ERROR)
    private String manufacturer;

    @ApiModelProperty(value = "通信协议", required = true)
    @NotBlank(message = DetectionValidMessage.PROTOCOL_NOT_BLANK)
    @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PROTOCOL_FORMAT_ERROR)
    private String protocol;

    @ApiModelProperty(value = "ip地址", required = true)
    @NotBlank(message = DetectionValidMessage.IP_NOT_BLANK)
    @Pattern(regexp = PatternRegex.IP_REGEX, message = DetectionValidMessage.IP_FORMAT_ERROR)
    private String ip;

    @ApiModelProperty(value = "端口", required = true)
    @NotNull(message = DetectionValidMessage.PORT_NOT_NULL)
    @Range(min = 1, max = 65535, message = DetectionValidMessage.PORT_RANGE_ERROR)
    private Integer port;

    @ApiModelProperty(value = "装置是否为加密版本", required = true)
    @NotNull(message = DetectionValidMessage.ENCRYPTION_NOT_NULL)
    @Min(value = 0, message = DetectionValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR)
    @Max(value = 1, message = DetectionValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR)
    private Integer encryptionFlag;

    @ApiModelProperty("识别码（3ds加密）")
    private String series;

    @ApiModelProperty("秘钥（3ds加密）")
    private String devKey;

    @ApiModelProperty(value = "可检通道", required = true)
    private String inspectChannel;

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

        @ApiModelProperty(value = "设备厂家", required = true)
        private String manufacturer;

        @ApiModelProperty(value = "设备类型", required = true)
        private String devType;
    }

    /**
     * 更新操作实体
     */
    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class UpdateParam extends PqStandardDevParam {
        @ApiModelProperty(value = "标准设备id", required = true)
        @NotBlank(message = DetectionValidMessage.ID_NOT_BLANK)
        @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR)
        private String id;
    }
}
