From a51aae9b69d318bbac96814364e78044e4a22f42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D1=83=D0=B7=D0=BD=D0=B5=D1=86=D0=BE=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=20=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD?= =?UTF-8?q?=D0=B4=D1=80=D0=BE=D0=B2=D0=B8=D1=87?= Date: Mon, 14 Apr 2025 18:57:38 +0300 Subject: [PATCH] MSP-5223 UpdateConfigNameRequest change field OldConfigName -> ConfidId + change ConfigVersion.CreatedAt actualCfg.CreatedAt -> actual.UpdatedAt --- controller/api/config.go | 2 +- docs/swagger.yaml | 8 ++++---- domain/request.go | 2 +- repository/config.go | 2 +- service/api/config_history.go | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/controller/api/config.go b/controller/api/config.go index 6fb9e1d..e2a75bd 100644 --- a/controller/api/config.go +++ b/controller/api/config.go @@ -242,7 +242,7 @@ func (c Config) DeleteConfigs(ctx context.Context, identities []string) (*domain // @Tags Конфигурация // @Accept json // @Produce json -// @Param body body domain.UpdateConfigNameRequest true "старое и новое название конфигурации" +// @Param body body domain.UpdateConfigNameRequest true "id конфигурации и новое название" // @Success 200 // @Failure 400 {object} apierrors.Error "`errorCode: 2002` - конфиг не найден
" // @Failure 500 {object} apierrors.Error diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 940c2ff..99686d0 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -176,13 +176,13 @@ definitions: type: object domain.UpdateConfigNameRequest: properties: + configId: + type: string newConfigName: type: string - oldConfigName: - type: string required: + - configId - newConfigName - - oldConfigName type: object domain.UpdateVariableRequest: properties: @@ -515,7 +515,7 @@ paths: description: Изменеяет название конфигурации без повышения версии и без рассылки события parameters: - - description: старое и новое название конфигурации + - description: id конфигурации и новое название in: body name: body required: true diff --git a/domain/request.go b/domain/request.go index 5943ad3..60d4988 100644 --- a/domain/request.go +++ b/domain/request.go @@ -26,6 +26,6 @@ type CreateUpdateConfigRequest struct { } type UpdateConfigNameRequest struct { - OldConfigName string `validate:"required"` + ConfigId string `validate:"required"` NewConfigName string `validate:"required"` } diff --git a/repository/config.go b/repository/config.go index 3856bee..20db2d6 100644 --- a/repository/config.go +++ b/repository/config.go @@ -207,7 +207,7 @@ func (r Config) UpdateConfigName(ctx context.Context, req domain.UpdateConfigNam Set("name", req.NewConfigName). Set("updated_at", squirrel.Expr("unixepoch()")). Where(squirrel.Eq{ - "name": req.OldConfigName, + "id": req.ConfigId, }). ToSql() if err != nil { diff --git a/service/api/config_history.go b/service/api/config_history.go index 4ebe83e..7945444 100644 --- a/service/api/config_history.go +++ b/service/api/config_history.go @@ -60,7 +60,7 @@ func (s ConfigHistory) GetAllVersions(ctx context.Context, configId string) ([]d ConfigId: actualCfg.Id, ConfigVersion: actualCfg.Version, Data: actualCfg.Data, - CreatedAt: time.Time(actualCfg.CreatedAt), + CreatedAt: time.Time(actualCfg.UpdatedAt), }) for _, version := range versions {