package module

import (
	"fmt"
	"strings"

	"gorm.io/gorm"

	"ops-assistant/internal/core/policy"
)

func switchFlag(module string) string {
	module = strings.TrimSpace(strings.ToLower(module))
	if module == "" {
		return ""
	}
	return fmt.Sprintf("enable_module_%s", module)
}

func IsEnabled(db *gorm.DB, module string) bool {
	k := switchFlag(module)
	if k == "" {
		return false
	}
	return policy.FlagEnabled(db, k)
}
