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

/**
 * @author caozehui
 * @data 2026-04-13
 */
@Data
public class PqFreqConverterParam {
    @ApiModelProperty(value = "名称", required = true)
    private String name;

    @ApiModelProperty(value = "电脑串口名", required = true)
    private String portName;

    @ApiModelProperty(value = "变频器设置从机地址", required = true)
    private Integer slaveAddress;

    @ApiModelProperty(value = "变频器设置波特率", required = true)
    private Integer baudRate;

    @ApiModelProperty(value = "奇偶校验类型: None, Even, Odd", required = true)
    private String parity;

    @ApiModelProperty(value = "变频器数据位", required = true)
    private Integer dataBits;

    @ApiModelProperty(value = "变频器停止位，当前只支持 1 或 2", required = true)
    private Integer stopBits;

    @ApiModelProperty(value = "串口读写超时，单位毫秒", required = true)
    private Integer timeoutMs;
    private Integer testStatus;

    /**
     * 分页查询实体
     */
    @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 PqFreqConverterParam {

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