From d1594aa852a75974c56f4f697f284ef0ca56152c Mon Sep 17 00:00:00 2001 From: Valera Shaitorov <shaitorov@perx.ru> Date: Mon, 29 May 2023 14:13:48 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BF=D1=80=D0=BE=D0=BF=D1=83=D1=89=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D1=8B=D0=B5=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8?= =?UTF-8?q?=20=D0=B2=20=D0=BF=D0=B0=D0=BA=D0=B5=D1=82=20Items?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- perxis-proto | 2 +- pkg/items/pagination.go | 4 +++- pkg/items/service.go | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/perxis-proto b/perxis-proto index 8606df02..f000812a 160000 --- a/perxis-proto +++ b/perxis-proto @@ -1 +1 @@ -Subproject commit 8606df02e0df6807e503bf22471a295020a47fba +Subproject commit f000812a1eef24093c0d0abf1318e3179b679773 diff --git a/pkg/items/pagination.go b/pkg/items/pagination.go index 6fe197d7..2e6fdd56 100644 --- a/pkg/items/pagination.go +++ b/pkg/items/pagination.go @@ -10,7 +10,9 @@ import ( ) type BatchProcessor struct { - Items Items + Items Items // fixme: после того как здесь Content поменяли на Items (из-за цикличного импорта) + // использование в perxis BatchProcessor'a необходимо менять + // стоит ли это так делать или лучше в perxis-go BatchProcessor вынести в отдельный пакет чтобы не было цикличного импорта? SpaceID, EnvID, CollectionID string FindOptions *FindOptions FindPublishedOptions *FindPublishedOptions diff --git a/pkg/items/service.go b/pkg/items/service.go index 51d65d5b..6a550dd0 100644 --- a/pkg/items/service.go +++ b/pkg/items/service.go @@ -149,3 +149,25 @@ func EncodeAggregateResult(ctx context.Context, request map[string]string, r map return result, nil } + +func CreateAndPublishItem(ctx context.Context, items Items, item *Item) error { + var err error + if item, err = items.Create(ctx, item); err != nil { + return errors.Wrap(err, "create item") + } + if err = items.Publish(ctx, item); err != nil { + return errors.Wrap(err, "publish item") + } + return nil +} + +func UpdateAndPublishItem(ctx context.Context, items Items, item *Item) error { + var err error + if err = items.Update(ctx, item); err != nil { + return errors.Wrap(err, "update item") + } + if err = items.Publish(ctx, item); err != nil { + return errors.Wrap(err, "publish item") + } + return nil +} -- GitLab