package org.example.Api;

import java.util.Map;
import java.util.Set;

public final class PublicApiRegistry {
    private static final Map<String, Set<String>> PUBLIC_METHODS = Map.of(
            "org.example.Auth.controller.AuthController", Set.of(
                    "Login",
                    "ResetPwdByVerify",
                    "CheckLogin",
                    "GetUserByName",
                    "GenerateCaptcha",
                    "SendPhoneCode",
                    "verifyCode",
                    "GetPhoneNumber",
                    "ResetPwdByPhone"
            ),
            "org.example.SystemApi.controller.SystemAjaxApi", Set.of(
                    "GetSystemInfo",
                    "GetEmaUrl",
                    "GetSystemLoginInfo",
                    "GetProSysType",
                    "GetDbServer",
                    "GetWebUpdateInfo"
            )
    );

    private PublicApiRegistry() {
    }

    public static boolean isPublicEndpoint(Class<?> handlerType, String methodName) {
        if (handlerType == null || methodName == null || methodName.isBlank()) {
            return false;
        }

        Set<String> methods = PUBLIC_METHODS.get(handlerType.getName());
        return methods != null && methods.contains(methodName);
    }
}
