fixed code documentation

This commit is contained in:
Fran Jurmanović
2021-08-29 10:51:29 +02:00
parent 0682252859
commit f441f46494
35 changed files with 674 additions and 70 deletions

View File

@@ -14,7 +14,16 @@ type WalletService struct {
Ss *SubscriptionService
}
// Inserts row to wallets table.
/*
New
Inserts row to wallets table.
Args:
context.Context: Application context
*models.NewWalletBody: Object to be inserted
Returns:
*models.Wallet: Wallet object from database.
*/
func (as *WalletService) New(ctx context.Context, am *models.NewWalletBody) *models.Wallet {
db := as.Db.WithContext(ctx)
@@ -26,7 +35,17 @@ func (as *WalletService) New(ctx context.Context, am *models.NewWalletBody) *mod
return walletModel
}
// Updates row in wallets table by id.
/*
Edit
Updates row in wallets table by id.
Args:
context.Context: Application context
*models.WalletEdit: Object to be edited
string: id to search
Returns:
*models.Wallet: Wallet object from database.
*/
func (as *WalletService) Edit(ctx context.Context, body *models.WalletEdit, id string) *models.Wallet {
db := as.Db.WithContext(ctx)
@@ -44,7 +63,17 @@ func (as *WalletService) Edit(ctx context.Context, body *models.WalletEdit, id s
return tm
}
// Gets row in wallets table by id.
/*
Get
Gets row in wallets table by id.
Args:
context.Context: Application context
string: id to search
*models.Params: url query parameters
Returns:
*models.Wallet: Wallet object from database
*/
func (as *WalletService) Get(ctx context.Context, id string, params *models.Params) *models.Wallet {
db := as.Db.WithContext(ctx)
@@ -62,7 +91,15 @@ func (as *WalletService) Get(ctx context.Context, id string, params *models.Para
return wm
}
// Gets filtered rows from wallets table.
/*
GetAll
Gets filtered rows from wallets table.
Args:
context.Context: Application context
*models.Auth: Authentication object
*models.FilteredResponse: filter options
*/
func (as *WalletService) GetAll(ctx context.Context, am *models.Auth, filtered *models.FilteredResponse) {
db := as.Db.WithContext(ctx)
wm := new([]models.Wallet)
@@ -71,9 +108,19 @@ func (as *WalletService) GetAll(ctx context.Context, am *models.Auth, filtered *
FilteredResponse(query, wm, filtered)
}
// Gets row from wallets table.
//
// Calculates previous month, current and next month totals.
/*
GetHeader
Gets row from wallets table.
Calculates previous month, current and next month totals.
Args:
context.Context: Application context
*models.Auth: Authentication object
string: wallet id to search
Returns:
*models.WalletHeader: generated wallet header object
*/
func (as *WalletService) GetHeader(ctx context.Context, am *models.Auth, walletId string) *models.WalletHeader {
db := as.Db.WithContext(ctx)
@@ -181,9 +228,17 @@ func (as *WalletService) GetHeader(ctx context.Context, am *models.Auth, walletI
return wm
}
// Appends Transaction to the belonging walletId
//
// If missing, it creates the item list.
/*
addWhere
Appends Transaction to the belonging walletId.
If missing, it creates the item list.
Args:
*[]models.WalletTransactions: list to append to
string: wallet id to check
models.Transaction: Transaction to append
*/
func addWhere(s *[]models.WalletTransactions, walletId string, e models.Transaction) {
var exists bool
for a := range *s {