package cn.iocoder.yudao.module.pms.hik;

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

import java.util.List;

@Data
@Component
@ConfigurationProperties(prefix = "hikvision")
public class HikvisionProperties {
    
    private IsapiConfig isapi;
    private AlarmConfig alarm;
    
    @Data
    public static class IsapiConfig {
        private List<DeviceConfig> devices;
        private CallbackConfig callback;
        private StorageConfig storage;
        
        @Data
        public static class DeviceConfig {
            private String id;
            private String name;
            private String ip;
            private Integer port;
            private String username;
            private String password;
            private String protocol;
            private Integer timeout;
            private PathConfig paths;
            private SubscriptionConfig subscription;
            
            public String getBaseUrl() {
                return String.format("%s://%s:%d", protocol, ip, port);
            }
        }
        
        @Data
        public static class PathConfig {
            private String eventNotification;
            private String intelligenceAnalysis;
            private String systemStatus;
            private String deviceInfo;
            private String sipInfo;
        }
        
        @Data
        public static class SubscriptionConfig {
            private Integer heartbeatInterval;
            private String eventTypes;
        }
        
        @Data
        public static class CallbackConfig {
            private Boolean enabled;
            private String localUrl;
            private String imageUrl;
            private Integer retryTimes;
            private Integer retryInterval;
        }
        
        @Data
        public static class StorageConfig {
            private Boolean saveAlarm;
            private Boolean saveImage;
            private String imagePath;
        }
    }
    
    @Data
    public static class AlarmConfig {
        private List<EventType> eventTypes;
        
        @Data
        public static class EventType {
            private String name;
            private String code;
            private String level;
        }
    }
}