Extend codegen for system resources

* Rename generated services
* Add definitions for reports
This commit is contained in:
Tomaž Jerman
2021-09-22 11:26:14 +02:00
parent cf35691c56
commit 8cae39f231
19 changed files with 426 additions and 79 deletions
@@ -11,14 +11,14 @@ import (
{{- end }}
"github.com/cortezaproject/corteza-server/pkg/actionlog"
"github.com/cortezaproject/corteza-server/pkg/auth"
intAuth "github.com/cortezaproject/corteza-server/pkg/auth"
"github.com/cortezaproject/corteza-server/pkg/locale"
"github.com/cortezaproject/corteza-server/store"
systemTypes "github.com/cortezaproject/corteza-server/system/types"
)
type (
resourceTranslation struct {
resourceTranslationsManager struct {
actionlog actionlog.Recorder
locale locale.Resource
store store.Storer
@@ -29,7 +29,7 @@ type (
// CanManageResourceTranslation(context.Context) bool
}
ResourceTranslationService interface {
ResourceTranslationsManagerService interface {
{{- range .Def }}
{{ .Resource }}(ctx context.Context, {{ if .Locale.Resource }}{{ range .Locale.Resource.References }}{{ .Field }} uint64, {{ end }}{{ end }}) (locale.ResourceTranslationSet, error)
{{- end }}
@@ -39,8 +39,8 @@ type (
}
)
func ResourceTranslation(ls locale.Resource) *resourceTranslation {
return &resourceTranslation{
func ResourceTranslationsManager(ls locale.Resource) *resourceTranslationsManager {
return &resourceTranslationsManager{
actionlog: DefaultActionlog,
store: DefaultStore,
ac: DefaultAccessControl,
@@ -48,7 +48,7 @@ func ResourceTranslation(ls locale.Resource) *resourceTranslation {
}
}
func (svc resourceTranslation) Upsert(ctx context.Context, rr locale.ResourceTranslationSet) (err error) {
func (svc resourceTranslationsManager) Upsert(ctx context.Context, rr locale.ResourceTranslationSet) (err error) {
// @todo AC
//if (!svc.ac.CanManageResourceTranslation(ctx)) {
// return *****ErrNotAllowedToCreate()
@@ -56,7 +56,7 @@ func (svc resourceTranslation) Upsert(ctx context.Context, rr locale.ResourceTra
// @todo validation
me := auth.GetIdentityFromContext(ctx)
me := intAuth.GetIdentityFromContext(ctx)
// - group by resource
localeByRes := make(map[string]locale.ResourceTranslationSet)
@@ -106,7 +106,7 @@ func (svc resourceTranslation) Upsert(ctx context.Context, rr locale.ResourceTra
return nil
}
func (svc resourceTranslation) Locale() locale.Resource {
func (svc resourceTranslationsManager) Locale() locale.Resource {
return svc.locale
}
@@ -114,7 +114,7 @@ func (svc resourceTranslation) Locale() locale.Resource {
{{ $Resource := .Resource }}
{{ $GoType := printf "types.%s" .Resource }}
func (svc resourceTranslation) {{ .Resource }}(ctx context.Context, {{ if .Locale.Resource }}{{ range .Locale.Resource.References }}{{ .Field }} uint64, {{ end }}{{ end }}) (locale.ResourceTranslationSet, error) {
func (svc resourceTranslationsManager) {{ .Resource }}(ctx context.Context, {{ if .Locale.Resource }}{{ range .Locale.Resource.References }}{{ .Field }} uint64, {{ end }}{{ end }}) (locale.ResourceTranslationSet, error) {
var (
err error
out locale.ResourceTranslationSet
+1 -1
View File
@@ -51,7 +51,7 @@ type (
Unique bool `json:"unique"`
System bool `json:"system"`
Caster frameCellCaster `json:"-"`
Caster frameCellCaster `json:"-" yaml:"-"`
}
FrameDefinitionSet []*FrameDefinition