MSP-5186 Add /application/get_all endpoint
This commit is contained in:
1 parent
f8fa58a09c
commit
fa2f88c869
7 files changed
+182
No files matched your search
@@ -172,3 +172,22 @@ func (r Application) NextApplicationId(ctx context.Context) (int, error) {
|
||||
}
|
||||
return nextAppId, nil
|
||||
}
|
||||
|
||||
func (r Application) GetAllApplications(ctx context.Context) ([]entity.Application, error) {
|
||||
q, args, err := query.New().
|
||||
Select("id", "name", "description", "application_group_id", "type", "created_at", "updated_at").
|
||||
From("application").
|
||||
OrderBy("created_at DESC").
|
||||
ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.WithMessagef(err, "exec query %s", q)
|
||||
}
|
||||
|
||||
result := make([]entity.Application, 0)
|
||||
err = r.db.Select(ctx, &result, q, args...)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessagef(err, "exec query %s", q)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
Reference in new issue
Block a user