diff --git a/backend/README.md b/backend/README.md index 79c4055..4fa14ef 100644 --- a/backend/README.md +++ b/backend/README.md @@ -118,7 +118,7 @@ wallet_mnemonic (string, optional. *if not provided, creators mnemonic will me u ### Example Request: ``` bash -curl --location 'http://localhost:8081/organization' \ +curl --location 'http://localhost:8081/organizations' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTU0NTY4Mzg4NTAsInVpZCI6ImI2NmU1Mjk4LTU1ZTctNGIxNy1hYzliLTA0MzU3YjBlN2Q0ZSJ9.K1I0QoZEdDYK_HEsJ0PdWOfZ8ugTcPfLqy7fHhvK9nk' \ --data '{ @@ -132,4 +132,68 @@ Response: { "id": "dfac7846-0f0a-11ef-9262-0242ac120002" } +``` + +## GET **/organizations** +### Request body: +cursor (string, optional) +limit (uint8, optional. Max:50, Default:50) +offset_date (uint63, optional. *time as unix milli*) + +### Example +Request: +``` bash +curl --location --request GET 'http://localhost:8081/organizations' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTU2MDIyNDMwOTEsInVpZCI6IjUyNTNkMzdjLTMxZDQtNDgxMi1iZTcxLWE5ODQwMTVlNGVlMyJ9.IKd-sM9cy5ehj0Scvbi3HPvhjnWD1MDl-POUlvVo9sA' \ +--data '{ + "limit":10 +}' +``` + +Response: +``` json +{ + "items": [ + { + "id": "758787be-7c09-4bc5-950b-e41adaf9cc0d", + "name": "ertyertyrtye", + "address": "rtyrtyetyetry", + "created_at": 0, + "updated_at": 0 + }, + { + "id": "eb691423-cd34-43b4-bb92-3bb3cd646e63", + "name": "ertyertyrtye", + "address": "rtyrtyetyetry", + "created_at": 0, + "updated_at": 0 + }, + { + "id": "7840246b-a67b-4e7b-a26c-43a11c2baec9", + "name": "ertyertyrtye", + "address": "rtyrtyetyetry", + "created_at": 0, + "updated_at": 0 + }, + { + "id": "79a649aa-dfc9-4009-9e04-1a3bdbf49959", + "name": "ertyertyrtye", + "address": "rtyrtyetyetry", + "created_at": 0, + "updated_at": 0 + }, + { + "id": "d13ff660-9927-4d08-b679-146818c00d0c", + "name": "ertyertyrtye", + "address": "rtyrtyetyetry", + "created_at": 0, + "updated_at": 0 + } + ], + "pagination": { + "next_cursor": "eyJpZCI6ImQxM2ZmNjYwLTk5MjctNGQwOC1iNjc5LTE0NjgxOGMwMGQwYyJ9", + "total_items": 5 + } +} ``` \ No newline at end of file diff --git a/backend/internal/interface/rest/controllers/organization.go b/backend/internal/interface/rest/controllers/organization.go index 44c0a51..287807e 100644 --- a/backend/internal/interface/rest/controllers/organization.go +++ b/backend/internal/interface/rest/controllers/organization.go @@ -71,6 +71,7 @@ func (c *organizationsController) ListOrganizations(w http.ResponseWriter, r *ht return nil, fmt.Errorf("error fetch user from context. %w", err) } + // BUG: empty created_at and updfated_at resp, err := c.orgInteractor.List(ctx, organizations.ListParams{ UserId: user.Id(), Cursor: req.Cursor, diff --git a/backend/internal/usecase/repository/organizations/repository.go b/backend/internal/usecase/repository/organizations/repository.go index 62e5b21..aeaa720 100644 --- a/backend/internal/usecase/repository/organizations/repository.go +++ b/backend/internal/usecase/repository/organizations/repository.go @@ -126,8 +126,6 @@ func (r *repositorySQL) Get(ctx context.Context, params GetParams) ([]*models.Or }) } - fmt.Println(query.ToSql()) - rows, err := query.RunWith(r.Conn(ctx)).QueryContext(ctx) if err != nil { return fmt.Errorf("error fetch organizations from database. %w", err)