package com.red.circle.other.inner.model.cmd.user.device;

import com.red.circle.framework.dto.Command;
import com.red.circle.tool.core.text.StringUtils;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.util.Objects;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * @author pengliang on 2023/5/24
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
public class AllowDeviceRegisterCmd extends Command {

  /**
   * 设备号.
   */
  @NotBlank
  private String deviceNo;

  /**
   * 设备现在数量.
   */
  @NotNull
  private Integer deviceLimit;

  /**
   * ip.
   */
  private String ip;

  /**
   * ip 限制数量.
   */
  private Integer ipLimit;

  /**
   * 系统.
   */
  private String sysOrigin;

  public boolean checkDevice() {
    return deviceLimit > 0 && StringUtils.isNotBlank(deviceNo);
  }

  public boolean checkIp() {
    return Objects.nonNull(ipLimit) && ipLimit > 0 && StringUtils.isNotBlank(getIp());
  }

}
