Skip to content

Commit

Permalink
Merge pull request #298 from LerianStudio/feature/MIDAZ-295
Browse files Browse the repository at this point in the history
Feature/MIDAZ-295
  • Loading branch information
qnen authored Nov 25, 2024
2 parents 9613b37 + b763374 commit 80e9a93
Show file tree
Hide file tree
Showing 37 changed files with 4,668 additions and 622 deletions.
92 changes: 64 additions & 28 deletions common/gold/transaction/model/transaction.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package model

// Balance structure for marshaling/unmarshalling JSON.
//
// swagger:model Balance
// @Description Balance is the struct designed to represent the account balance.
type Balance struct {
Available int `json:"available"`
OnHold int `json:"onHold"`
Scale int `json:"scale"`
}
Available int `json:"available" example:"1500"`
OnHold int `json:"onHold" example:"500"`
Scale int `json:"scale" example:"2"`
} // @name Balance

type Responses struct {
Total int
Expand All @@ -15,57 +19,89 @@ type Responses struct {
Aliases []string
}

// Metadata structure for marshaling/unmarshalling JSON.
//
// swagger:model Metadata
// @Description Metadata is the struct designed to store metadata.
type Metadata struct {
Key string `json:"key,omitempty"`
Value any `json:"value,omitempty"`
}
} // @name Metadata

// Amount structure for marshaling/unmarshalling JSON.
//
// swagger:model Amount
// @Description Amount is the struct designed to represent the amount of an operation.
type Amount struct {
Asset string `json:"asset,omitempty" validate:"required,eq=BRL"`
Value int `json:"value,omitempty" validate:"required"`
Scale int `json:"scale,omitempty" validate:"gte=0"`
}
Asset string `json:"asset,omitempty" validate:"required,eq=BRL" example:"BRL"`
Value int `json:"value,omitempty" validate:"required" example:"1000"`
Scale int `json:"scale,omitempty" validate:"gte=0" example:"2"`
} // @name Amount

// Share structure for marshaling/unmarshalling JSON.
//
// swagger:model Share
// @Description Share is the struct designed to represent the sharing fields of an operation.
type Share struct {
Percentage int `json:"percentage,omitempty" validate:"required"`
PercentageOfPercentage int `json:"percentageOfPercentage,omitempty"`
DescWhatever bool `json:"descWhatever,omitempty"`
}
} // @name Share

// Send structure for marshaling/unmarshalling JSON.
//
// swagger:model Send
// @Description Send is the struct designed to represent the sending fields of an operation.
type Send struct {
Asset string `json:"asset,omitempty" validate:"required,eq=BRL"`
Value int `json:"value,omitempty" validate:"required"`
Scale int `json:"scale,omitempty" validate:"gte=0"`
Asset string `json:"asset,omitempty" validate:"required,eq=BRL" example:"BRL"`
Value int `json:"value,omitempty" validate:"required" example:"1000"`
Scale int `json:"scale,omitempty" validate:"gte=0" example:"2"`
Source Source `json:"source,omitempty" validate:"required"`
}
} // @name Send

// Source structure for marshaling/unmarshalling JSON.
//
// swagger:model Source
// @Description Source is the struct designed to represent the source fields of an operation.
type Source struct {
Remaining string `json:"remaining,omitempty"`
Remaining string `json:"remaining,omitempty" example:"remaining"`
From []FromTo `json:"from,omitempty" validate:"singletransactiontype,required,dive"`
}
} // @name Source

// FromTo structure for marshaling/unmarshalling JSON.
//
// swagger:model FromTo
// @Description FromTo is the struct designed to represent the from/to fields of an operation.
type FromTo struct {
Account string `json:"account,omitempty"`
Account string `json:"account,omitempty" example:"@person1"`
Amount *Amount `json:"amount,omitempty"`
Share *Share `json:"share,omitempty"`
Remaining string `json:"remaining,omitempty"`
Description string `json:"description,omitempty"`
ChartOfAccounts string `json:"chartOfAccountsG"`
Remaining string `json:"remaining,omitempty" example:"remaining"`
Description string `json:"description,omitempty" example:"description"`
ChartOfAccounts string `json:"chartOfAccountsG" example:"1000"`
Metadata map[string]any `json:"metadata,omitempty" validate:"dive,keys,keymax=100,endkeys,nonested,valuemax=2000"`
IsFrom bool `json:"isFrom,omitempty"`
}
IsFrom bool `json:"isFrom,omitempty" example:"true"`
} // @name FromTo

// Distribute structure for marshaling/unmarshalling JSON.
//
// swagger:model Distribute
// @Description Distribute is the struct designed to represent the distribution fields of an operation.
type Distribute struct {
Remaining string `json:"remaining,omitempty"`
To []FromTo `json:"to,omitempty" validate:"singletransactiontype,required,dive"`
}
} // @name Distribute

// Transaction structure for marshaling/unmarshalling JSON.
//
// swagger:model Transaction
// @Description Transaction is a struct designed to store transaction data.
type Transaction struct {
ChartOfAccountsGroupName string `json:"chartOfAccountsGroupName,omitempty"`
Description string `json:"description,omitempty"`
Code string `json:"code,omitempty"`
Pending bool `json:"pending,omitempty"`
ChartOfAccountsGroupName string `json:"chartOfAccountsGroupName,omitempty" example:"1000"`
Description string `json:"description,omitempty" example:"Description"`
Code string `json:"code,omitempty" example:"00000000-0000-0000-0000-000000000000"`
Pending bool `json:"pending,omitempty" example:"false"`
Metadata map[string]any `json:"metadata,omitempty" validate:"dive,keys,keymax=100,endkeys,nonested,valuemax=2000"`
Send Send `json:"send" validate:"required"`
Distribute Distribute `json:"distribute" validate:"required"`
}
} // @name Transaction
10 changes: 5 additions & 5 deletions common/mmodel/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// CreateAccountInput is a struct design to encapsulate request create payload data.
//
// swagger:model CreateAccountInput
// @Description CreateAccountInput is a struct design to encapsulate request create payload data.
// @Description CreateAccountInput is the input payload to create an account.
type CreateAccountInput struct {
AssetCode string `json:"assetCode" validate:"required,max=100" example:"BRL"`
Name string `json:"name" validate:"max=256" example:"My Account"`
Expand All @@ -27,7 +27,7 @@ type CreateAccountInput struct {
// UpdateAccountInput is a struct design to encapsulate request update payload data.
//
// swagger:model UpdateAccountInput
// @Description UpdateAccountInput is a struct design to encapsulate request update payload data.
// @Description UpdateAccountInput is the input payload to update an account.
type UpdateAccountInput struct {
Name string `json:"name" validate:"max=256" example:"My Account Updated"`
Status Status `json:"status"`
Expand All @@ -41,7 +41,7 @@ type UpdateAccountInput struct {
// Account is a struct designed to encapsulate response payload data.
//
// swagger:model Account
// @Description Account is a struct designed to encapsulate response payload data.
// @Description Account is a struct designed to store account data.
type Account struct {
ID string `json:"id" example:"00000000-0000-0000-0000-000000000000"`
Name string `json:"name" example:"My Account"`
Expand All @@ -67,7 +67,7 @@ type Account struct {
// Balance structure for marshaling/unmarshalling JSON.
//
// swagger:model Balance
// @Description Balance structure for marshaling/unmarshalling JSON.
// @Description Balance is the struct designed to represent the account balance.
type Balance struct {
Available *float64 `json:"available" example:"1500"`
OnHold *float64 `json:"onHold" example:"500"`
Expand All @@ -82,7 +82,7 @@ func (b Balance) IsEmpty() bool {
// Accounts struct to return get all.
//
// swagger:model Accounts
// @Description Accounts struct to return get all.
// @Description Accounts is the struct designed to return a list of accounts with pagination.
type Accounts struct {
Items []Account `json:"items"`
Page int `json:"page" example:"1"`
Expand Down
28 changes: 12 additions & 16 deletions common/mmodel/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,32 @@ import "time"
// CreateAssetInput is a struct design to encapsulate request create payload data.
//
// swagger:model CreateAssetInput
// @Description CreateAssetInput is a struct design to encapsulate request create payload data.
// @Param name query string false "Name" e
// @Param type query string false "Type"
// @Param code query string false "Code"
// @Param status query string false "Status"
// @Param metadata query string false "Metadata"
//
// @Description CreateAssetInput is the input payload to create an asset.
type CreateAssetInput struct {
Name string `json:"name" validate:"max=256" example:"Brazilian Real"`
Type string `json:"type" example:"currency"`
Code string `json:"code" validate:"required,max=100" example:"BRL"`
Status Status `json:"status"`
Metadata map[string]any `json:"metadata" validate:"dive,keys,keymax=100,endkeys,nonested,valuemax=2000"`
} // @name CreateAssetInput
} // @name CreateAssetInput

// UpdateAssetInput is a struct design to encapsulate request update payload data.
//
// swagger:model UpdateAssetInput
// @Description UpdateAssetInput is a struct design to encapsulate request update payload data.
//
// @Description UpdateAssetInput is the input payload to update an asset.
type UpdateAssetInput struct {
Name string `json:"name" validate:"max=256" example:"Bitcoin"`
Status Status `json:"status"`
Metadata map[string]any `json:"metadata" validate:"dive,keys,keymax=100,endkeys,nonested,valuemax=2000"`
} // @name UpdateAssetInput
} // @name UpdateAssetInput

// Asset is a struct designed to encapsulate payload data.
//
// swagger:model Asset
// @Description Asset is a struct designed to encapsulate payload data.
//
// @Description Asset is a struct designed to store asset data.
type Asset struct {
ID string `json:"id" example:"00000000-0000-0000-0000-000000000000"`
Name string `json:"name" example:"Brazilian Real"`
Expand All @@ -45,17 +43,15 @@ type Asset struct {
UpdatedAt time.Time `json:"updatedAt" example:"2021-01-01T00:00:00Z"`
DeletedAt *time.Time `json:"deletedAt" example:"2021-01-01T00:00:00Z"`
Metadata map[string]any `json:"metadata,omitempty"`
} // @name Asset
} // @name Asset

// Assets struct to return get all.
//
// swagger:model Assets
// @Description Assets struct to return get all.
// @Param items query string false "Items"
// @Param page query string false "Page"
// @Param limit query string false "Limit"
//
// @Description Assets is the struct designed to return a list of assets with pagination.
type Assets struct {
Items []Asset `json:"items"`
Page int `json:"page" example:"1"`
Limit int `json:"limit" example:"10"`
} // @name Assets
} // @name Assets
8 changes: 4 additions & 4 deletions common/mmodel/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "time"
// CreateLedgerInput is a struct design to encapsulate request create payload data.
//
// swagger:model CreateLedgerInput
// @Description CreateLedgerInput is a struct design to encapsulate request create payload data for ledger.
// @Description CreateLedgerInput is the input payload to create a ledger.
type CreateLedgerInput struct {
Name string `json:"name" validate:"required,max=256" example:"Lerian Studio"`
Status Status `json:"status"`
Expand All @@ -15,7 +15,7 @@ type CreateLedgerInput struct {
// UpdateLedgerInput is a struct design to encapsulate request update payload data.
//
// swagger:model UpdateLedgerInput
// @Description UpdateLedgerInput is a struct design to encapsulate request update payload data for ledger.
// @Description UpdateLedgerInput is the input payload to update a ledger.
type UpdateLedgerInput struct {
Name string `json:"name" validate:"max=256" example:"Lerian Studio Updated"`
Status Status `json:"status"`
Expand All @@ -25,7 +25,7 @@ type UpdateLedgerInput struct {
// Ledger is a struct designed to encapsulate payload data.
//
// swagger:model Ledger
// @Description Ledger is a struct designed to encapsulate payload data.
// @Description Ledger is a struct designed to store ledger data.
type Ledger struct {
ID string `json:"id" example:"00000000-0000-0000-0000-000000000000"`
Name string `json:"name" example:"Lerian Studio"`
Expand All @@ -40,7 +40,7 @@ type Ledger struct {
// Ledgers struct to return get all.
//
// swagger:model Ledgers
// @Description Ledgers struct to return get all.
// @Description Ledgers is the struct designed to return a list of ledgers with pagination.
type Ledgers struct {
Items []Ledger `json:"items"`
Page int `json:"page" example:"1"`
Expand Down
10 changes: 5 additions & 5 deletions common/mmodel/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "time"
// CreateOrganizationInput is a struct design to encapsulate request create payload data.
//
// // swagger:model CreateOrganizationInput
// @Description CreateOrganizationInput is a struct design to encapsulate request create payload data for organization.
// @Description CreateOrganizationInput is the input payload to create an organization.
type CreateOrganizationInput struct {
LegalName string `json:"legalName" validate:"required,max=256" example:"Lerian Studio"`
ParentOrganizationID *string `json:"parentOrganizationId" validate:"omitempty,uuid" example:"00000000-0000-0000-0000-000000000000"`
Expand All @@ -19,7 +19,7 @@ type CreateOrganizationInput struct {
// UpdateOrganizationInput is a struct design to encapsulate request update payload data.
//
// // swagger:model UpdateOrganizationInput
// @Description UpdateOrganizationInput is a struct design to encapsulate request update payload data for organization.
// @Description UpdateOrganizationInput is the input payload to update an organization.
type UpdateOrganizationInput struct {
LegalName string `json:"legalName" validate:"required,max=256" example:"Lerian Studio Updated"`
ParentOrganizationID *string `json:"parentOrganizationId" validate:"omitempty,uuid" example:"00000000-0000-0000-0000-000000000000"`
Expand All @@ -32,7 +32,7 @@ type UpdateOrganizationInput struct {
// Organization is a struct designed to encapsulate response payload data.
//
// swagger:model Organization
// @Description Organization is a struct designed to encapsulate response payload data.
// @Description Organization is a struct designed to store organization data.
type Organization struct {
ID string `json:"id" example:"00000000-0000-0000-0000-000000000000"`
ParentOrganizationID *string `json:"parentOrganizationId" example:"00000000-0000-0000-0000-000000000000"`
Expand All @@ -50,7 +50,7 @@ type Organization struct {
// Address structure for marshaling/unmarshalling JSON.
//
// swagger:model Address
// @Description Address structure for marshaling/unmarshalling JSON.
// @Description Address is a struct designed to store the address data of an organization.
type Address struct {
Line1 string `json:"line1" example:"Street 1"`
Line2 *string `json:"line2" example:"Street 2"`
Expand All @@ -68,7 +68,7 @@ func (a Address) IsEmpty() bool {
// Organizations struct to return get all.
//
// swagger:model Organizations
// @Description Organizations struct to return get all.
// @Description Organizations is the struct designed to return a list of organizations with pagination.
type Organizations struct {
Items []Organization `json:"items"`
Page int `json:"page" example:"1"`
Expand Down
8 changes: 4 additions & 4 deletions common/mmodel/portfolio.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "time"
// CreatePortfolioInput is a struct design to encapsulate request create payload data.
//
// swagger:model CreatePortfolioInput
// @Description CreatePortfolioInput is a struct design to encapsulate request create payload data.
// @Description CreatePortfolioInput is the input payload to create a portfolio.
type CreatePortfolioInput struct {
EntityID string `json:"entityId" validate:"required,max=256" example:"00000000-0000-0000-0000-000000000000"`
Name string `json:"name" validate:"required,max=256" example:"My Portfolio"`
Expand All @@ -16,7 +16,7 @@ type CreatePortfolioInput struct {
// UpdatePortfolioInput is a struct design to encapsulate payload data.
//
// swagger:model UpdatePortfolioInput
// @Description UpdatePortfolioInput is a struct design to encapsulate payload data.
// @Description UpdatePortfolioInput is the input payload to update a portfolio.
type UpdatePortfolioInput struct {
Name string `json:"name" validate:"max=256" example:"My Portfolio Updated"`
Status Status `json:"status"`
Expand All @@ -26,7 +26,7 @@ type UpdatePortfolioInput struct {
// Portfolio is a struct designed to encapsulate request update payload data.
//
// swagger:model Portfolio
// @Description Portfolio is a struct designed to encapsulate request update payload data.
// @Description Portfolio is a struct designed to store portfolio data.
type Portfolio struct {
ID string `json:"id" example:"00000000-0000-0000-0000-000000000000"`
Name string `json:"name" example:"My Portfolio"`
Expand All @@ -43,7 +43,7 @@ type Portfolio struct {
// Portfolios struct to return get all.
//
// swagger:model Portfolios
// @Description Portfolios struct to return get all.
// @Description Portfolios is the struct designed to return a list of portfolios with pagination.
type Portfolios struct {
Items []Portfolio `json:"items"`
Page int `json:"page" example:"1"`
Expand Down
8 changes: 4 additions & 4 deletions common/mmodel/product.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "time"
// CreateProductInput is a struct design to encapsulate request create payload data.
//
// swagger:model CreateProductInput
// @Description CreateProductInput is a struct design to encapsulate request create payload data.
// @Description CreateProductInput is the input payload to create a product.
type CreateProductInput struct {
Name string `json:"name" validate:"required,max=256" example:"My Product"`
Status Status `json:"status"`
Expand All @@ -15,7 +15,7 @@ type CreateProductInput struct {
// UpdateProductInput is a struct design to encapsulate request update payload data.
//
// swagger:model UpdateProductInput
// @Description UpdateProductInput is a struct design to encapsulate request update payload data.
// @Description UpdateProductInput is the input payload to update a product.
type UpdateProductInput struct {
Name string `json:"name" validate:"max=256" example:"My Product Updated"`
Status Status `json:"status"`
Expand All @@ -25,7 +25,7 @@ type UpdateProductInput struct {
// Product is a struct designed to encapsulate payload data.
//
// swagger:model Product
// @Description Product is a struct designed to encapsulate payload data.
// @Description Product is a struct designed to store product data.
type Product struct {
ID string `json:"id" example:"00000000-0000-0000-0000-000000000000"`
Name string `json:"name" example:"My Product"`
Expand All @@ -41,7 +41,7 @@ type Product struct {
// Products struct to return get all.
//
// swagger:model Products
// @Description Products struct to return get all.
// @Description Products is the struct designed to return a list of products with pagination.
type Products struct {
Items []Product `json:"items"`
Page int `json:"page" example:"1"`
Expand Down
Loading

0 comments on commit 80e9a93

Please sign in to comment.