mirror of
https://github.com/FJurmanovic/wallet-go-api.git
synced 2026-02-06 06:08:16 +00:00
grouped transactions
This commit is contained in:
@@ -38,7 +38,10 @@ func (as *TransactionService) GetAll(am *models.Auth, walletId string, filtered
|
||||
wm := new([]models.Transaction)
|
||||
sm := new([]models.Subscription)
|
||||
|
||||
query2 := as.Db.Model(sm).Relation("Wallet").Where("wallet.? = ?", pg.Ident("user_id"), am.Id)
|
||||
tx, _ := as.Db.Begin()
|
||||
defer tx.Rollback()
|
||||
|
||||
query2 := tx.Model(sm).Relation("Wallet").Where("wallet.? = ?", pg.Ident("user_id"), am.Id)
|
||||
if walletId != "" {
|
||||
query2 = query2.Where("? = ?", pg.Ident("wallet_id"), walletId)
|
||||
}
|
||||
@@ -48,9 +51,11 @@ func (as *TransactionService) GetAll(am *models.Auth, walletId string, filtered
|
||||
as.Ss.SubToTrans(&sub)
|
||||
}
|
||||
|
||||
query := as.Db.Model(wm).Relation("Wallet").Where("wallet.? = ?", pg.Ident("user_id"), am.Id)
|
||||
query := tx.Model(wm).Relation("Wallet").Where("wallet.? = ?", pg.Ident("user_id"), am.Id)
|
||||
if walletId != "" {
|
||||
query = query.Where("? = ?", pg.Ident("wallet_id"), walletId)
|
||||
}
|
||||
FilteredResponse(query, wm, filtered)
|
||||
|
||||
tx.Commit()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user