feat(ECR-036): ExploreConfig RhythmConfig 只读并 Closed
RhythmConfig catalog (000037) · 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 ErrRhythmConfigNotFound = errString("rhythm config not found")
|
||||
|
||||
// ListRhythmConfigs returns catalog.
|
||||
func (s *Service) ListRhythmConfigs(ctx context.Context) ([]repository.RhythmConfigRow, error) {
|
||||
items, err := s.Repo.ListRhythmConfigs(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if items == nil {
|
||||
items = []repository.RhythmConfigRow{}
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
// GetRhythmConfig loads one.
|
||||
func (s *Service) GetRhythmConfig(ctx context.Context, id uuid.UUID) (*repository.RhythmConfigRow, error) {
|
||||
row, err := s.Repo.GetRhythmConfig(ctx, id)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return nil, ErrRhythmConfigNotFound
|
||||
}
|
||||
return row, err
|
||||
}
|
||||
Reference in New Issue
Block a user