package usecase

import (
	"context"

	"haixun-backend/internal/model/member/domain/entity"
	permissionentity "haixun-backend/internal/model/permission/domain/entity"
)

type PermissionNode struct {
	ID          string
	Parent      string
	Name        string
	HTTPMethods string
	HTTPPath    string
	Status      string
	Type        string
	Children    []PermissionNode
}

type CatalogRequest struct {
	Status string
	Type   string
	Tree   bool
}

type MePermissions struct {
	TenantID    string
	UID         string
	Roles       []string
	Permissions map[string]string
	Tree        []PermissionNode
}

type UseCase interface {
	EnsureDefaultPermissions(ctx context.Context) error
	EnsureDefaultRolePermissions(ctx context.Context, tenantID string) error
	Catalog(ctx context.Context, req CatalogRequest) ([]PermissionNode, []PermissionNode, error)
	Me(ctx context.Context, member *entity.Member, includeTree bool) (*MePermissions, error)
	ReplaceRolePermissions(ctx context.Context, tenantID, roleKey string, permissionIDs []string) error
}

type RawPermission = permissionentity.Permission
