定时发布目录(ops_scheduled_publications),并加固 catalog 生成器。 Co-authored-by: Cursor <cursoragent@cursor.com>
35 lines
919 B
Go
35 lines
919 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 ErrScheduledPublicationNotFound = errString("scheduled publication not found")
|
|
|
|
// ListScheduledPublications returns catalog.
|
|
func (s *Service) ListScheduledPublications(ctx context.Context) ([]repository.ScheduledPublicationRow, error) {
|
|
items, err := s.Repo.ListScheduledPublications(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if items == nil {
|
|
items = []repository.ScheduledPublicationRow{}
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
// GetScheduledPublication loads one.
|
|
func (s *Service) GetScheduledPublication(ctx context.Context, id uuid.UUID) (*repository.ScheduledPublicationRow, error) {
|
|
row, err := s.Repo.GetScheduledPublication(ctx, id)
|
|
if errors.Is(err, pgx.ErrNoRows) {
|
|
return nil, ErrScheduledPublicationNotFound
|
|
}
|
|
return row, err
|
|
}
|