43 lines
1.8 KiB
Go
43 lines
1.8 KiB
Go
|
|
// Package usecase contains the permission module's domain interfaces and
|
||
|
|
// DTOs. Implementations live under internal/model/permission/usecase/.
|
||
|
|
package usecase
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"gateway/internal/model/permission/domain/entity"
|
||
|
|
"gateway/internal/model/permission/domain/enum"
|
||
|
|
)
|
||
|
|
|
||
|
|
// PermissionTreeNode is a hierarchical node returned by the catalog
|
||
|
|
// endpoint. Children are nil when not requested or when the caller asked
|
||
|
|
// for a flat list.
|
||
|
|
type PermissionTreeNode struct {
|
||
|
|
ID string `json:"id"`
|
||
|
|
Parent string `json:"parent,omitempty"`
|
||
|
|
Name string `json:"name"`
|
||
|
|
HTTPMethods string `json:"http_methods,omitempty"`
|
||
|
|
HTTPPath string `json:"http_path,omitempty"`
|
||
|
|
Status enum.Status `json:"status"`
|
||
|
|
Type enum.PermissionType `json:"type"`
|
||
|
|
Children []*PermissionTreeNode `json:"children,omitempty"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// CatalogQuery filters the catalog tree.
|
||
|
|
type CatalogQuery struct {
|
||
|
|
OnlyOpen bool // exclude status=close (and their subtrees)
|
||
|
|
Type *enum.PermissionType // restrict to backend or frontend
|
||
|
|
}
|
||
|
|
|
||
|
|
// PermissionUseCase exposes the platform-wide permission catalog. Tenants
|
||
|
|
// only consume read endpoints; mutations are platform-admin only and
|
||
|
|
// usually run via cmd/permission-seed.
|
||
|
|
type PermissionUseCase interface {
|
||
|
|
GetCatalogTree(ctx context.Context, query *CatalogQuery) ([]*PermissionTreeNode, error)
|
||
|
|
List(ctx context.Context, query *CatalogQuery) ([]*entity.Permission, error)
|
||
|
|
GetByID(ctx context.Context, id string) (*entity.Permission, error)
|
||
|
|
GetByName(ctx context.Context, name string) (*entity.Permission, error)
|
||
|
|
UpsertCatalog(ctx context.Context, perms []*entity.Permission) error
|
||
|
|
UpdateStatus(ctx context.Context, id string, status enum.Status) error
|
||
|
|
}
|