mirror of
https://github.com/FJurmanovic/wallet-go-api.git
synced 2026-02-06 06:08:16 +00:00
small pattern fixes
This commit is contained in:
@@ -23,13 +23,12 @@ func NewWalletsHeaderController(as *services.WalletService, s *gin.RouterGroup)
|
|||||||
func (wc *WalletsHeaderController) Get(c *gin.Context) {
|
func (wc *WalletsHeaderController) Get(c *gin.Context) {
|
||||||
body := new(models.Auth)
|
body := new(models.Auth)
|
||||||
|
|
||||||
embed, _ := c.GetQuery("embed")
|
|
||||||
walletId, _ := c.GetQuery("walletId")
|
walletId, _ := c.GetQuery("walletId")
|
||||||
|
|
||||||
auth := c.MustGet("auth")
|
auth := c.MustGet("auth")
|
||||||
body.Id = auth.(*models.Auth).Id
|
body.Id = auth.(*models.Auth).Id
|
||||||
|
|
||||||
wm := wc.WalletService.GetHeader(body, embed, walletId)
|
wm := wc.WalletService.GetHeader(body, walletId)
|
||||||
|
|
||||||
c.JSON(200, wm)
|
c.JSON(200, wm)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ func CheckToken(tokenString string) (*jwt.Token, error) {
|
|||||||
_, ok := token.Method.(*jwt.SigningMethodHMAC)
|
_, ok := token.Method.(*jwt.SigningMethodHMAC)
|
||||||
var err error
|
var err error
|
||||||
if !ok {
|
if !ok {
|
||||||
err = errors.New("Invalid token")
|
err = errors.New("invalid token")
|
||||||
}
|
}
|
||||||
return []byte(secret), err
|
return []byte(secret), err
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ func (as *TransactionService) GetAll(am *models.Auth, walletId string, filtered
|
|||||||
if walletId != "" {
|
if walletId != "" {
|
||||||
query2 = query2.Where("? = ?", pg.Ident("wallet_id"), walletId)
|
query2 = query2.Where("? = ?", pg.Ident("wallet_id"), walletId)
|
||||||
}
|
}
|
||||||
|
query2.Select()
|
||||||
|
|
||||||
for _, sub := range *sm {
|
for _, sub := range *sm {
|
||||||
as.Ss.SubToTrans(&sub)
|
as.Ss.SubToTrans(&sub)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ func (as *WalletService) GetAll(am *models.Auth, filtered *models.FilteredRespon
|
|||||||
FilteredResponse(query, wm, filtered)
|
FilteredResponse(query, wm, filtered)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as *WalletService) GetHeader(am *models.Auth, embed string, walletId string) *models.WalletHeader {
|
func (as *WalletService) GetHeader(am *models.Auth, walletId string) *models.WalletHeader {
|
||||||
wm := new(models.WalletHeader)
|
wm := new(models.WalletHeader)
|
||||||
wallets := new([]models.WalletTransactions)
|
wallets := new([]models.WalletTransactions)
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
@@ -117,7 +117,7 @@ func (as *WalletService) GetHeader(am *models.Auth, embed string, walletId strin
|
|||||||
|
|
||||||
func addWhere(s *[]models.WalletTransactions, walletId string, e models.Transaction) {
|
func addWhere(s *[]models.WalletTransactions, walletId string, e models.Transaction) {
|
||||||
var exists bool
|
var exists bool
|
||||||
for a, _ := range *s {
|
for a := range *s {
|
||||||
if (*s)[a].WalletId == walletId {
|
if (*s)[a].WalletId == walletId {
|
||||||
(*s)[a].Transactions = append((*s)[a].Transactions, e)
|
(*s)[a].Transactions = append((*s)[a].Transactions, e)
|
||||||
exists = true
|
exists = true
|
||||||
|
|||||||
Reference in New Issue
Block a user