From 5efa2ebb583cbfb360fb261838f8a23b16421bdc Mon Sep 17 00:00:00 2001 From: MartinezAvellan Date: Tue, 4 Jun 2024 17:18:49 +0200 Subject: [PATCH 1/4] refactor: update DDL portfolio create table entity_id uuid to text :hammer: --- .../ledger/migrations/000005_create_portfolio_table.up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/ledger/migrations/000005_create_portfolio_table.up.sql b/components/ledger/migrations/000005_create_portfolio_table.up.sql index 54a33704..266b62f1 100644 --- a/components/ledger/migrations/000005_create_portfolio_table.up.sql +++ b/components/ledger/migrations/000005_create_portfolio_table.up.sql @@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS portfolio ( id UUID PRIMARY KEY NOT NULL DEFAULT (uuid_generate_v4()), name TEXT, - entity_id UUID NOT NULL, + entity_id TEXT NOT NULL, ledger_id UUID NOT NULL, organization_id UUID NOT NULL, status TEXT NOT NULL, From d68be08765d57c7c01d4a9b1f0466070007839c2 Mon Sep 17 00:00:00 2001 From: MartinezAvellan Date: Tue, 4 Jun 2024 17:20:03 +0200 Subject: [PATCH 2/4] fix: bring back omitempty on metadata in field _id because cant generate automatic id without :bug: --- components/ledger/internal/domain/metadata/metadata.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/ledger/internal/domain/metadata/metadata.go b/components/ledger/internal/domain/metadata/metadata.go index 546af017..b92faa34 100644 --- a/components/ledger/internal/domain/metadata/metadata.go +++ b/components/ledger/internal/domain/metadata/metadata.go @@ -11,7 +11,7 @@ import ( // MetadataMongoDBModel represents the metadata into mongodb context type MetadataMongoDBModel struct { - ID primitive.ObjectID `bson:"_id"` + ID primitive.ObjectID `bson:"_id,omitempty"` EntityID string `bson:"entity_id"` EntityName string `bson:"entity_name"` Data JSON `bson:"metadata"` From 0b8118650ac85b35dd46f530140d163d1e14078c Mon Sep 17 00:00:00 2001 From: MartinezAvellan Date: Tue, 4 Jun 2024 17:20:50 +0200 Subject: [PATCH 3/4] refactor: add time.now() on created_at and updated_at field on ledger :hammer: --- components/ledger/internal/app/command/create-ledger.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/ledger/internal/app/command/create-ledger.go b/components/ledger/internal/app/command/create-ledger.go index 019c7c19..815bf097 100644 --- a/components/ledger/internal/app/command/create-ledger.go +++ b/components/ledger/internal/app/command/create-ledger.go @@ -29,6 +29,8 @@ func (uc *UseCase) CreateLedger(ctx context.Context, organizationID string, cli OrganizationID: organizationID, Name: cli.Name, Status: status, + CreatedAt: time.Now(), + UpdatedAt: time.Now(), } led, err := uc.LedgerRepo.Create(ctx, ledger) From c81e8e5744b7e90a4552f4a721a8625ab646899f Mon Sep 17 00:00:00 2001 From: MartinezAvellan Date: Tue, 4 Jun 2024 17:21:43 +0200 Subject: [PATCH 4/4] refactor: update postman change portuguese words to english words :hammer: --- postman/MIDAZ.postman_collection.json | 77 ++++++++++++++++----------- 1 file changed, 46 insertions(+), 31 deletions(-) diff --git a/postman/MIDAZ.postman_collection.json b/postman/MIDAZ.postman_collection.json index d5d72317..7823d182 100644 --- a/postman/MIDAZ.postman_collection.json +++ b/postman/MIDAZ.postman_collection.json @@ -19,9 +19,9 @@ "exec": [ "const jsonData = JSON.parse(responseBody);", "if (jsonData.hasOwnProperty('id')) {", - " console.log(\"organization_id antes: \" + postman.getEnvironmentVariable(\"organization_id\"));", + " console.log(\"organization_id before: \" + postman.getEnvironmentVariable(\"organization_id\"));", " postman.setEnvironmentVariable(\"organization_id\", jsonData.id);", - " console.log(\"organization_id depois: \" + postman.getEnvironmentVariable(\"organization_id\"));", + " console.log(\"organization_id after: \" + postman.getEnvironmentVariable(\"organization_id\"));", "}" ], "type": "text/javascript", @@ -139,17 +139,17 @@ { "key": "metadata.chave", "value": "teste", - "description": "com, pesquisa no mongodb, sem, pesquisa no postgresql." + "description": "Search on MongoDB" }, { "key": "limit", "value": "6", - "description": "default 10" + "description": "Default 10" }, { "key": "page", "value": "1", - "description": "default 1" + "description": "Default 1" } ] } @@ -244,9 +244,9 @@ "exec": [ "const jsonData = JSON.parse(responseBody);", "if (jsonData.hasOwnProperty('id')) {", - " console.log(\"ledger_id antes: \" + postman.getEnvironmentVariable(\"ledger_id\"));", + " console.log(\"ledger_id before: \" + postman.getEnvironmentVariable(\"ledger_id\"));", " postman.setEnvironmentVariable(\"ledger_id\", jsonData.id);", - " console.log(\"ledger_id depois: \" + postman.getEnvironmentVariable(\"ledger_id\"));", + " console.log(\"ledger_id after: \" + postman.getEnvironmentVariable(\"ledger_id\"));", "}" ], "type": "text/javascript", @@ -354,15 +354,18 @@ "query": [ { "key": "metadata.chave", - "value": "teste" + "value": "teste", + "description": "Search on MongoDB" }, { "key": "limit", - "value": "5" + "value": "5", + "description": "Default 10" }, { "key": "page", - "value": "1" + "value": "1", + "description": "Default 1" } ] } @@ -449,9 +452,9 @@ "exec": [ "const jsonData = JSON.parse(responseBody);", "if (jsonData.hasOwnProperty('id')) {", - " console.log(\"instrument_id antes: \" + postman.getEnvironmentVariable(\"instrument_id\"));", + " console.log(\"instrument_id before: \" + postman.getEnvironmentVariable(\"instrument_id\"));", " postman.setEnvironmentVariable(\"instrument_id\", jsonData.id);", - " console.log(\"instrument_id depois: \" + postman.getEnvironmentVariable(\"instrument_id\"));", + " console.log(\"instrument_id after: \" + postman.getEnvironmentVariable(\"instrument_id\"));", "}" ], "type": "text/javascript", @@ -553,15 +556,18 @@ "query": [ { "key": "metadata.chave", - "value": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlf" + "value": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlf", + "description": "Search on MongoDB" }, { "key": "limit", - "value": "2" + "value": "2", + "description": "Default 10" }, { "key": "page", - "value": "1" + "value": "1", + "description": "Default 1" } ] } @@ -639,9 +645,9 @@ "exec": [ "const jsonData = JSON.parse(responseBody);", "if (jsonData.hasOwnProperty('id')) {", - " console.log(\"portfolio_id antes: \" + postman.getEnvironmentVariable(\"portfolio_id\"));", + " console.log(\"portfolio_id before: \" + postman.getEnvironmentVariable(\"portfolio_id\"));", " postman.setEnvironmentVariable(\"portfolio_id\", jsonData.id);", - " console.log(\"portfolio_id depois: \" + postman.getEnvironmentVariable(\"portfolio_id\"));", + " console.log(\"portfolio_id after: \" + postman.getEnvironmentVariable(\"portfolio_id\"));", "}" ], "type": "text/javascript", @@ -743,15 +749,18 @@ "query": [ { "key": "metadata.chave", - "value": "teste" + "value": "teste", + "description": "Search on MongoDB" }, { "key": "limit", - "value": "2" + "value": "2", + "description": "Default 10" }, { "key": "page", - "value": "1" + "value": "1", + "description": "Default 1" } ] } @@ -829,9 +838,9 @@ "exec": [ "const jsonData = JSON.parse(responseBody);", "if (jsonData.hasOwnProperty('id')) {", - " console.log(\"product_id antes: \" + postman.getEnvironmentVariable(\"product_id\"));", + " console.log(\"product_id before: \" + postman.getEnvironmentVariable(\"product_id\"));", " postman.setEnvironmentVariable(\"product_id\", jsonData.id);", - " console.log(\"product_id depois: \" + postman.getEnvironmentVariable(\"product_id\"));", + " console.log(\"product_id after: \" + postman.getEnvironmentVariable(\"product_id\"));", "}" ], "type": "text/javascript", @@ -925,7 +934,7 @@ "formdata": [] }, "url": { - "raw": "{{url}}/v1/organizations/{{organization_id}}/ledgers/{{ledger_id}}/products?metadata.chave=teste&limit=5&page=1", + "raw": "{{url}}/v1/organizations/{{organization_id}}/ledgers/{{ledger_id}}/products?metadata.chave=metadata_chave&limit=5&page=1", "host": [ "{{url}}" ], @@ -940,15 +949,18 @@ "query": [ { "key": "metadata.chave", - "value": "teste" + "value": "metadata_chave", + "description": "Search on MongoDB" }, { "key": "limit", - "value": "5" + "value": "5", + "description": "Default 10" }, { "key": "page", - "value": "1" + "value": "1", + "description": "Default 1" } ] } @@ -1026,9 +1038,9 @@ "exec": [ "const jsonData = JSON.parse(responseBody);", "if (jsonData.hasOwnProperty('id')) {", - " console.log(\"account_id antes: \" + postman.getEnvironmentVariable(\"account_id\"));", + " console.log(\"account_id before: \" + postman.getEnvironmentVariable(\"account_id\"));", " postman.setEnvironmentVariable(\"account_id\", jsonData.id);", - " console.log(\"account_id depois: \" + postman.getEnvironmentVariable(\"account_id\"));", + " console.log(\"account_id after: \" + postman.getEnvironmentVariable(\"account_id\"));", "}" ], "type": "text/javascript", @@ -1136,15 +1148,18 @@ "query": [ { "key": "metadata.chave", - "value": "xuxa" + "value": "xuxa", + "description": "Search on MongoDB" }, { "key": "limit", - "value": "2" + "value": "2", + "description": "Default 10" }, { "key": "page", - "value": "1" + "value": "1", + "description": "Default 1" } ] }