MSP-5186 Add /application/create_application endpoint
This commit is contained in:
1 parent
fa2f88c869
commit
e2ed71196b
7 files changed
+281
-12
No files matched your search
@@ -277,6 +277,26 @@ func (s Application) GetAll(ctx context.Context) ([]domain.Application, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s Application) Create(ctx context.Context, req domain.CreateApplicationRequest) (*domain.ApplicationWithTokens, error) {
|
||||
appId := req.Id
|
||||
var err error
|
||||
if appId == 0 {
|
||||
appId, err = s.appRepo.NextApplicationId(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "next application id")
|
||||
}
|
||||
}
|
||||
app, err := s.appRepo.CreateApplication(ctx, appId, req.Name, req.Description, req.ApplicationGroupId, req.Type)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "create application")
|
||||
}
|
||||
|
||||
return &domain.ApplicationWithTokens{
|
||||
App: s.convertApplication(*app),
|
||||
Tokens: make([]domain.Token, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s Application) convertApplication(req entity.Application) domain.Application {
|
||||
desc := ""
|
||||
if req.Description != nil {
|
||||
|
||||
Reference in new issue
Block a user