package usecase import ( "backend/tmp/reborn-mongo/domain/entity" "context" ) // PermissionUseCase 權限業務邏輯介面 type PermissionUseCase interface { // GetAll 取得所有權限 GetAll(ctx context.Context) ([]*PermissionResponse, error) // GetTree 取得權限樹 GetTree(ctx context.Context) (*PermissionTreeNode, error) // GetByHTTP 根據 HTTP 資訊取得權限 GetByHTTP(ctx context.Context, path, method string) (*PermissionResponse, error) // ExpandPermissions 展開權限 (包含父權限) ExpandPermissions(ctx context.Context, permissions entity.Permissions) (entity.Permissions, error) // GetUsersByPermission 取得擁有指定權限的所有使用者 GetUsersByPermission(ctx context.Context, permissionNames []string) ([]string, error) } // PermissionResponse 權限回應 type PermissionResponse struct { ID int64 `json:"id"` ParentID int64 `json:"parent_id"` Name string `json:"name"` HTTPPath string `json:"http_path,omitempty"` HTTPMethod string `json:"http_method,omitempty"` Status entity.PermissionStatus `json:"status"` Type entity.PermissionType `json:"type"` } // PermissionTreeNode 權限樹節點 type PermissionTreeNode struct { *PermissionResponse Children []*PermissionTreeNode `json:"children,omitempty"` }