package com.sunyard.chsm.dto;

import com.sunyard.chsm.model.PageQuery;
import com.sunyard.chsm.model.entity.Device;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author liulu
 * @since 2024/10/21
 */
public abstract class DeviceGroupDTO {

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

    @Data
    public static class DGView {

        private Long id;
        /**
         * 设备组名称
         */
        private String name;
        /**
         * 已选设备列表
         */
        private List<Device> checkedDevices;
        /**
         * 密码设备
         */
        private String deviceNames;
        /**
         * 备注
         */
        private String remark;

        private LocalDateTime createTime;
    }


    @Data
    public static class DGSave {
        private Long id;
        /**
         * 设备组名称
         */
        @NotBlank(message = "设备组名称不能为空")
        private String name;
        /**
         * 密码设备id
         */
        private List<Long> deviceIds;
        /**
         * 备注
         */
        private String remark;
    }

    @Data
    public static class LoadWeight {
        /**
         * 设备组id
         */
        @NotNull(message = "设备组id不能为空")
        private Long id;
        @Valid
        @NotEmpty(message = "设备负载信息不能为空")
        private List<WeightDe> devices;
    }

    @Data
    public static class WeightDe {

        /**
         * 设备id
         */
        @NotNull(message = "设备id不能为空")
        private Long id;
        @Min(value = 1, message = "设备负载值最低为1")
        @NotNull(message = "设备负载值不能为空")
        private Integer weight;
    }


}
