2025-05-14 11:54:07: merge [master:138dde59487c426482ca2f7c3e9db90630787f98];

This commit is contained in:
txix committed 2025-05-14 11:54:07 +03:00
1 parent a648f4f9a7
commit c5b82152e0
13 files changed
+286 -120

No files matched your search

+32
View File
@@ -11,8 +11,10 @@ import (
"google.golang.org/grpc/codes"
)
// nolint:interfacebloat
type ApplicationService interface {
GetById(ctx context.Context, appId int) (*domain.ApplicationWithTokens, error)
GetByToken(ctx context.Context, token string) (*domain.GetApplicationByTokenResponse, error)
GetByIdList(ctx context.Context, idList []int) ([]*domain.ApplicationWithTokens, error)
GetByServiceId(ctx context.Context, id int) ([]*domain.ApplicationWithTokens, error)
SystemTree(ctx context.Context, systemId int) ([]*domain.DomainWithService, error)
@@ -64,6 +66,36 @@ func (c Application) GetById(ctx context.Context, req domain.Identity) (*domain.
}
}
// GetByToken godoc
//
// @Tags application
// @Summary Получить идентификатор приложения и группы по токену
// @Description Возвращает идентификатор приложения и группы по токену
// @Accept json
// @Produce json
// @Param body body domain.GetApplicationByTokenRequest true "Тело запроса"
// @Success 200 {object} domain.GetApplicationByTokenResponse
// @Failure 400 {object} apierrors.Error
// @Failure 404 {object} apierrors.Error
// @Failure 500 {object} apierrors.Error
// @Router /application/get_application_by_token [POST]
func (c Application) GetByToken(ctx context.Context, req domain.GetApplicationByTokenRequest) (*domain.GetApplicationByTokenResponse, error) {
result, err := c.service.GetByToken(ctx, req.Token)
switch {
case errors.Is(err, domain.ErrApplicationNotFound):
return nil, apierrors.New(
codes.NotFound,
domain.ErrCodeApplicationNotFound,
fmt.Sprintf("application with token '%s' not found", req.Token),
err,
)
case err != nil:
return nil, err
default:
return result, nil
}
}
// GetByIdList godoc
//
// @Tags application