package com.zehong.framework.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@ConfigurationProperties(prefix = "hikvision")
public class HikvisionProperties {

    private Map<String, PlatformConfig> platforms;

    public Map<String, PlatformConfig> getPlatforms() {
        return platforms;
    }

    public void setPlatforms(Map<String, PlatformConfig> platforms) {
        this.platforms = platforms;
    }

    /**
     * 获取平台配置
     * @param platformId 平台
     * @return
     */
    public HikvisionProperties.PlatformConfig getPlatformConfig(String platformId) {
        HikvisionProperties.PlatformConfig config = platforms.get(platformId);
        if (config == null) {
            throw new IllegalArgumentException("未找到平台: " + platformId);
        }
        return config;
    }

    public static class PlatformConfig {
        private String host;
        private String appKey;
        private String appSecret;

        public String getHost() {
            return host;
        }

        public void setHost(String host) {
            this.host = host;
        }

        public String getAppKey() {
            return appKey;
        }

        public void setAppKey(String appKey) {
            this.appKey = appKey;
        }

        public String getAppSecret() {
            return appSecret;
        }

        public void setAppSecret(String appSecret) {
            this.appSecret = appSecret;
        }
    }
}
