You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
775 B
38 lines
775 B
package wallet
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"recook/internal/back"
|
|
"recook/internal/dbc"
|
|
"recook/internal/model/user"
|
|
"recook/tools"
|
|
)
|
|
|
|
func QueryBalanceList(c *gin.Context) {
|
|
var p queryWalletCoinParam
|
|
err := tools.ParseParams(&p, c)
|
|
if err != nil {
|
|
back.Fail(c, err.Error())
|
|
return
|
|
}
|
|
|
|
if p.UserID == 0 {
|
|
back.Suc(c, "", gin.H{
|
|
"balance": 0,
|
|
"list": []user.WalletBalanceList{},
|
|
})
|
|
return
|
|
}
|
|
|
|
var wallet user.Wallet
|
|
dbc.DB.Select("balance").First(&wallet, "user_id = ?", p.UserID)
|
|
|
|
list := make([]user.WalletBalanceList, 0)
|
|
dbc.DB.Select("amount,title,comment,created_at").Limit(20).Offset(p.Page*20).Order("id desc").Find(&list, "user_id = ?", p.UserID)
|
|
|
|
back.Suc(c, "", gin.H{
|
|
"balance": wallet.Balance,
|
|
"list": list,
|
|
})
|
|
}
|