feat(ECR-038): GrowthInsights ReportTemplate 只读并 Closed
ReportTemplate catalog (000039) · 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 ErrReportTemplateNotFound = errString("report template not found")
|
||||
|
||||
// ListReportTemplates returns catalog.
|
||||
func (s *Service) ListReportTemplates(ctx context.Context) ([]repository.ReportTemplateRow, error) {
|
||||
items, err := s.Repo.ListReportTemplates(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if items == nil {
|
||||
items = []repository.ReportTemplateRow{}
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
// GetReportTemplate loads one.
|
||||
func (s *Service) GetReportTemplate(ctx context.Context, id uuid.UUID) (*repository.ReportTemplateRow, error) {
|
||||
row, err := s.Repo.GetReportTemplate(ctx, id)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return nil, ErrReportTemplateNotFound
|
||||
}
|
||||
return row, err
|
||||
}
|
||||
Reference in New Issue
Block a user