MSP-5186 Implement application next id endpoint
This commit is contained in:
1 parent
141650417a
commit
89f4eea280
4 files changed
+46
No files matched your search
@@ -17,6 +17,7 @@ type ApplicationService interface {
|
||||
SystemTree(ctx context.Context, systemId int) ([]*domain.DomainWithService, error)
|
||||
CreateUpdate(ctx context.Context, req domain.ApplicationCreateUpdateRequest) (*domain.ApplicationWithTokens, error)
|
||||
Delete(ctx context.Context, idList []int) (int, error)
|
||||
NextId(ctx context.Context) (int, error)
|
||||
}
|
||||
|
||||
type Application struct {
|
||||
@@ -148,3 +149,16 @@ func (c Application) Delete(ctx context.Context, req []int) (*domain.DeleteRespo
|
||||
Deleted: result,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// NextId godoc
|
||||
// @Tags application
|
||||
// @Summary Получить следующий идентификатор приложения
|
||||
// @Description Возвращает следующий идентификатор приложения
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} integer
|
||||
// @Failure 500 {object} domain.GrpcError
|
||||
// @Router /application/next_id [POST]
|
||||
func (c Application) NextId(ctx context.Context) (int, error) {
|
||||
return c.service.NextId(ctx)
|
||||
}
|
||||
@@ -571,6 +571,25 @@ paths:
|
||||
summary: Метод получения системного дерева
|
||||
tags:
|
||||
- application
|
||||
/application/next_id:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Возвращает следующий идентификатор приложения
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
type: integer
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/domain.GrpcError'
|
||||
summary: Получить следующий идентификатор приложения
|
||||
tags:
|
||||
- application
|
||||
/domain/create_update_domain:
|
||||
post:
|
||||
consumes:
|
||||
|
||||
@@ -161,6 +161,11 @@ func applicationCluster(c Controllers) []cluster.EndpointDescriptor {
|
||||
Inner: true,
|
||||
Handler: c.Application.GetSystemTree,
|
||||
},
|
||||
{
|
||||
Path: "system/application/next_id",
|
||||
Inner: true,
|
||||
Handler: c.Application.NextId,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -256,6 +256,14 @@ func (s Application) EnrichWithTokens(ctx context.Context, apps []entity.Applica
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s Application) NextId(ctx context.Context) (int, error) {
|
||||
nextId, err := s.appRepo.NextApplicationId(ctx)
|
||||
if err != nil {
|
||||
return 0, errors.WithMessage(err, "get next application id")
|
||||
}
|
||||
return nextId, nil
|
||||
}
|
||||
|
||||
func (s Application) convertApplication(req entity.Application) domain.Application {
|
||||
desc := ""
|
||||
if req.Description != nil {
|
||||
|
||||
Reference in new issue
Block a user