feat(ECR-026): OpsCMS ScheduledPublication 只读并 Closed
定时发布目录(ops_scheduled_publications),并加固 catalog 生成器。 Co-authored-by: Cursor <cursoragent@cursor.com>
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 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
|
||||
}
|
||||
Reference in New Issue
Block a user