From 129ce7c2c6061f602e07651c57b76fcb9c1ff644 Mon Sep 17 00:00:00 2001 From: likhachevam Date: Wed, 8 Oct 2025 11:31:11 +0300 Subject: [PATCH] MSP-6459 update /purge_versions endpoint --- controller/api/config_history.go | 16 ++++++++++++---- docs/swagger.yaml | 6 ++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/controller/api/config_history.go b/controller/api/config_history.go index e7b586f..63d2eec 100644 --- a/controller/api/config_history.go +++ b/controller/api/config_history.go @@ -81,14 +81,22 @@ func (c ConfigHistory) DeleteConfigVersion(ctx context.Context, req domain.IdReq // @Accept json // @Produce json // @Param body body domain.PurgeConfigVersionsRequest true "Название модуля, количество оставленных версий конфигурации" -// @Success 200 {object} domain.DeleteResponse -// @Failure 400 {object} apierrors.Error "не указан массив идентификаторов" +// @Success 200 {object} map[string]int +// @Failure 400 {object} apierrors.Error "`errorCode: 2001` - модуль не найден" // @Failure 500 {object} apierrors.Error // @Router /config/purge_versions [POST] func (c ConfigHistory) PurgeConfigVersions(ctx context.Context, req domain.PurgeConfigVersionsRequest) (map[string]int, error) { result, err := c.service.Purge(ctx, req.ModuleName, req.KeepVersions) - if err != nil { + switch { + case errors.Is(err, entity.ErrModuleNotFound): + return nil, apierrors.NewBusinessError( + domain.ErrorCodeModuleNotFound, + "module not found", + err, + ) + case err != nil: return nil, apierrors.NewInternalServiceError(err) + default: + return result, nil } - return result, nil } diff --git a/docs/swagger.yaml b/docs/swagger.yaml index c4981ee..82aabba 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -587,9 +587,11 @@ paths: "200": description: OK schema: - $ref: '#/definitions/domain.DeleteResponse' + additionalProperties: + type: integer + type: object "400": - description: не указан массив идентификаторов + description: '`errorCode: 2001` - модуль не найден' schema: $ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error' "500":