package com.smyhub.infogenie.infogeniebackendjava.dto.response;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

/**
 * Matches Go {@code GET /api/admin/site/diagnostics} JSON for the admin monitoring page.
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DiagnosticsResponse {

    private AppInfo app;
    private MysqlInfo mysql;
    private RedisInfo redis;

    @JsonProperty("sixty_upstream")
    private SixtyUpstreamInfo sixtyUpstream;

    @JsonProperty("auth_center")
    private AuthCenterInfo authCenter;

    private MailInfo mail;

    @Data
    public static class AppInfo {
        private String env;

        @JsonProperty("listen_addr")
        private String listenAddr;

        @JsonProperty("listen_port")
        private String listenPort;
    }

    @Data
    public static class MysqlInfo {
        private String host;
        private String port;
        private String database;
        private String user;

        @JsonProperty("password_configured")
        private Boolean passwordConfigured;
    }

    @Data
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public static class RedisInfo {
        private boolean enabled;
        private String addr;

        @JsonProperty("logical_db")
        private Integer logicalDb;

        @JsonProperty("key_prefix")
        private String keyPrefix;

        @JsonProperty("site_cache_ttl_sec")
        private Integer siteCacheTtlSec;

        @JsonProperty("password_configured")
        private Boolean passwordConfigured;
    }

    @Data
    public static class SixtyUpstreamInfo {
        @JsonProperty("source_id")
        private String sourceId;

        @JsonProperty("base_url")
        private String baseUrl;

        private String label;
    }

    @Data
    public static class AuthCenterInfo {
        @JsonProperty("api_url")
        private String apiUrl;
    }

    @Data
    public static class MailInfo {
        private String host;
        private Integer port;
        private String username;

        @JsonProperty("password_configured")
        private Boolean passwordConfigured;
    }
}
