Files
digital-psychology/apps/api/internal/service/admin/intervention_outcome.go
T
jackyu66git 447fb6da16 feat(ECR-032): CrisisCare InterventionOutcome 只读并 Closed
InterventionOutcome catalog (000033) · Loop continuous.
2026-08-08 03:15:30 +08:00

35 lines
907 B
Go

package admin
import (
"context"
"errors"
"github.com/google/uuid"
"github.com/jackc/pgx/v5"
"github.com/yuxingu/digital-psychology/apps/api/internal/repository"
)
var ErrInterventionOutcomeNotFound = errString("intervention outcome not found")
// ListInterventionOutcomes returns catalog.
func (s *Service) ListInterventionOutcomes(ctx context.Context) ([]repository.InterventionOutcomeRow, error) {
items, err := s.Repo.ListInterventionOutcomes(ctx)
if err != nil {
return nil, err
}
if items == nil {
items = []repository.InterventionOutcomeRow{}
}
return items, nil
}
// GetInterventionOutcome loads one.
func (s *Service) GetInterventionOutcome(ctx context.Context, id uuid.UUID) (*repository.InterventionOutcomeRow, error) {
row, err := s.Repo.GetInterventionOutcome(ctx, id)
if errors.Is(err, pgx.ErrNoRows) {
return nil, ErrInterventionOutcomeNotFound
}
return row, err
}