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 {