35 lines
847 B
Go
35 lines
847 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 ErrPrivacyRequestNotFound = errString("privacy request not found")
|
|
|
|
// ListPrivacyRequests returns catalog.
|
|
func (s *Service) ListPrivacyRequests(ctx context.Context) ([]repository.PrivacyRequestRow, error) {
|
|
items, err := s.Repo.ListPrivacyRequests(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if items == nil {
|
|
items = []repository.PrivacyRequestRow{}
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
// GetPrivacyRequest loads one.
|
|
func (s *Service) GetPrivacyRequest(ctx context.Context, id uuid.UUID) (*repository.PrivacyRequestRow, error) {
|
|
row, err := s.Repo.GetPrivacyRequest(ctx, id)
|
|
if errors.Is(err, pgx.ErrNoRows) {
|
|
return nil, ErrPrivacyRequestNotFound
|
|
}
|
|
return row, err
|
|
}
|