feat(ECR-035): ExploreConfig StarConfig 只读并 Closed
StarConfig catalog (000036) · Loop continuous.
This commit is contained in:
@@ -31,6 +31,7 @@ const (
|
||||
PermCrisisRead = "admin.crisis.read"
|
||||
PermCMSRead = "admin.cms.read"
|
||||
PermPrivacyRead = "admin.privacy.read"
|
||||
PermExploreRead = "admin.explore.read"
|
||||
)
|
||||
|
||||
var knownPermissions = map[string]struct{}{
|
||||
@@ -40,7 +41,7 @@ var knownPermissions = map[string]struct{}{
|
||||
PermUsersStatusWrite: {}, PermMembershipPlansRead: {}, PermMembershipPlansWrite: {},
|
||||
PermMembershipCodesRead: {}, PermMembershipCodesWrite: {},
|
||||
PermAskRead: {}, PermAskFeedbackWrite: {}, PermContentSafetyRead: {},
|
||||
PermAIConfigRead: {}, PermCrisisRead: {}, PermCMSRead: {}, PermPrivacyRead: {},
|
||||
PermAIConfigRead: {}, PermCrisisRead: {}, PermCMSRead: {}, 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 ErrStarConfigNotFound = errString("star config not found")
|
||||
|
||||
// ListStarConfigs returns catalog.
|
||||
func (s *Service) ListStarConfigs(ctx context.Context) ([]repository.StarConfigRow, error) {
|
||||
items, err := s.Repo.ListStarConfigs(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if items == nil {
|
||||
items = []repository.StarConfigRow{}
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
// GetStarConfig loads one.
|
||||
func (s *Service) GetStarConfig(ctx context.Context, id uuid.UUID) (*repository.StarConfigRow, error) {
|
||||
row, err := s.Repo.GetStarConfig(ctx, id)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return nil, ErrStarConfigNotFound
|
||||
}
|
||||
return row, err
|
||||
}
|
||||
Reference in New Issue
Block a user