package com.ycwl.basic.integration.device.dto.config;

import lombok.Data;

import java.util.Map;

@Data
public class UpdateDeviceConfigRequest {
    private String configKey;
    private String configValue;
    private String configType;
    private String description;
    private Integer isActive;
    
    // 支持灵活的字段更新
    public static UpdateDeviceConfigRequest fromMap(Map<String, Object> updates) {
        UpdateDeviceConfigRequest request = new UpdateDeviceConfigRequest();
        if (updates.containsKey("configKey")) {
            request.setConfigKey((String) updates.get("configKey"));
        }
        if (updates.containsKey("configValue")) {
            request.setConfigValue((String) updates.get("configValue"));
        }
        if (updates.containsKey("configType")) {
            request.setConfigType((String) updates.get("configType"));
        }
        if (updates.containsKey("description")) {
            request.setDescription((String) updates.get("description"));
        }
        if (updates.containsKey("isActive")) {
            request.setIsActive((Integer) updates.get("isActive"));
        }
        return request;
    }
}