feat(ECR-032): CrisisCare InterventionOutcome 只读并 Closed
InterventionOutcome catalog (000033) · 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 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
|
||||
}
|
||||
Reference in New Issue
Block a user