package usecase

import (
	"backend/pkg/permission/domain/permission"
	"context"
)

// RolePermissionUseCase 角色權限業務邏輯介面
type RolePermissionUseCase interface {
	// GetByRoleUID 取得角色的所有權限
	GetByRoleUID(ctx context.Context, roleUID string) (permission.Permissions, error)
	// GetByUserUID 取得使用者的所有權限
	GetByUserUID(ctx context.Context, userUID string) (*UserPermissionResponse, error)
	// UpdateRolePermissions 更新角色權限
	UpdateRolePermissions(ctx context.Context, roleUID string, permissions permission.Permissions) error
	// CheckPermission 檢查角色是否有權限
	CheckPermission(ctx context.Context, roleUID, path, method string) (*PermissionCheckResponse, error)
}

// UserPermissionResponse 使用者權限回應
type UserPermissionResponse struct {
	UserUID     string                 `json:"user_uid"`
	RoleUID     string                 `json:"role_uid"`
	RoleName    string                 `json:"role_name"`
	Permissions permission.Permissions `json:"permissions"`
}

// PermissionCheckResponse 權限檢查回應
type PermissionCheckResponse struct {
	Allowed        bool   `json:"allowed"`
	PermissionName string `json:"permission_name,omitempty"`
	PlainCode      bool   `json:"plain_code"`
}
