package com.sunyard.chsm.dto;

import com.sunyard.chsm.model.PageQuery;
import com.sunyard.ssp.common.constant.RegexConstant;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * @author liulu
 * @since 2024/10/18
 */
public abstract class DeviceDTO {


    @EqualsAndHashCode(callSuper = true)
    @Data
    public static class Query extends PageQuery {
        /**
         * 厂商
         */
        private String manufacturers;
        /**
         * 型号
         */
        private String model;
        /**
         * 名称
         */
        private String name;
    }

    @Data
    public static class DeviceSave {

        private Long id;
        /**
         * 名称
         */
        @NotBlank(message = "名称不能为空")
        private String name;
        /**
         * 厂商
         */
        @NotBlank(message = "厂商不能为空")
        private String manufacturer;
        /**
         * 型号
         */
        @NotBlank(message = "型号不能为空")
        private String manufacturerModel;
        /**
         * 服务ip
         */
        @NotBlank(message = "服务ip不能为空")
        @Pattern(regexp = RegexConstant.DEVICE_IPV4, message = "服务ip格式错误")
        private String serviceIp;
        /**
         * 服务端口
         */
        @NotNull(message = "服务端口不能为空")
        private Integer servicePort;
        /**
         * 管理ip
         */
        private String manageIp;
        /**
         * 管理端口
         */
        private Integer managePort;
        @NotNull(message = "加密密钥索引不能为空")
        private Integer encKeyIdx;
        /**
         * 访问凭证
         */
        @NotBlank(message = "访问凭证不能为空")
        private String accessCredentials;
        /**
         * 备注
         */
        @Size(max = 500, message = "备注长度在1-500之间")
        private String remark;

    }

    @Data
    public static class DeviceView {
        private Long id;
        /**
         * 名称
         */
        private String name;
        /**
         * 厂商
         */
        private String manufacturer;
        private String manufacturerText;
        /**
         * 型号
         */
        private String manufacturerModel;
        private String manufacturerModelText;
        /**
         * 服务ip
         */
        private String serviceIp;
        /**
         * 服务端口
         */
        private Integer servicePort;
        /**
         * 管理ip
         */
        private String manageIp;
        /**
         * 管理端口
         */
        private Integer managePort;
        private Integer encKeyIdx;
        /**
         * 访问凭证
         */
        private String accessCredentials;
        /**
         * 设备是否已经分组
         */
        private Boolean isGrouped;
        /**
         * 备注
         */
        private String remark;
        private LocalDateTime createTime;
    }

    @EqualsAndHashCode(callSuper = true)
    @Data
    public static class Detail extends DeviceView {

        private Double cpuRate;
        private Double memoryRate;
        private Double diskRate;

    }

}
