feat(ECR-038): GrowthInsights ReportTemplate 只读并 Closed
ReportTemplate catalog (000039) · Loop continuous.
This commit is contained in:
@@ -32,6 +32,7 @@ const (
|
||||
PermCMSRead = "admin.cms.read"
|
||||
PermPrivacyRead = "admin.privacy.read"
|
||||
PermExploreRead = "admin.explore.read"
|
||||
PermGrowthRead = "admin.growth.read"
|
||||
)
|
||||
|
||||
var knownPermissions = map[string]struct{}{
|
||||
@@ -41,7 +42,7 @@ var knownPermissions = map[string]struct{}{
|
||||
PermUsersStatusWrite: {}, PermMembershipPlansRead: {}, PermMembershipPlansWrite: {},
|
||||
PermMembershipCodesRead: {}, PermMembershipCodesWrite: {},
|
||||
PermAskRead: {}, PermAskFeedbackWrite: {}, PermContentSafetyRead: {},
|
||||
PermAIConfigRead: {}, PermCrisisRead: {}, PermCMSRead: {}, PermExploreRead: {}, PermPrivacyRead: {},
|
||||
PermAIConfigRead: {}, PermCrisisRead: {}, PermCMSRead: {}, PermGrowthRead: {}, PermExploreRead: {}, PermPrivacyRead: {},
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -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