feat(ECR-028): AICoreConfig ToolDefinition 只读并 Closed
ToolDefinition catalog (000029) · Loop continuous.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5"
|
||||
|
||||
"github.com/yuxingu/digital-psychology/apps/api/internal/repository"
|
||||
)
|
||||
|
||||
var ErrToolDefinitionNotFound = errString("tool definition not found")
|
||||
|
||||
// ListToolDefinitions returns catalog.
|
||||
func (s *Service) ListToolDefinitions(ctx context.Context) ([]repository.ToolDefinitionRow, error) {
|
||||
items, err := s.Repo.ListToolDefinitions(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if items == nil {
|
||||
items = []repository.ToolDefinitionRow{}
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
// GetToolDefinition loads one.
|
||||
func (s *Service) GetToolDefinition(ctx context.Context, id uuid.UUID) (*repository.ToolDefinitionRow, error) {
|
||||
row, err := s.Repo.GetToolDefinition(ctx, id)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return nil, ErrToolDefinitionNotFound
|
||||
}
|
||||
return row, err
|
||||
}
|
||||
Reference in New Issue
Block a user