feat(ECR-033): AskOperations HandoffCase 只读并 Closed
HandoffCase catalog (000034) · 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 ErrHandoffCaseNotFound = errString("handoff case not found")
|
||||
|
||||
// ListHandoffCases returns catalog.
|
||||
func (s *Service) ListHandoffCases(ctx context.Context) ([]repository.HandoffCaseRow, error) {
|
||||
items, err := s.Repo.ListHandoffCases(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if items == nil {
|
||||
items = []repository.HandoffCaseRow{}
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
// GetHandoffCase loads one.
|
||||
func (s *Service) GetHandoffCase(ctx context.Context, id uuid.UUID) (*repository.HandoffCaseRow, error) {
|
||||
row, err := s.Repo.GetHandoffCase(ctx, id)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return nil, ErrHandoffCaseNotFound
|
||||
}
|
||||
return row, err
|
||||
}
|
||||
Reference in New Issue
Block a user