This commit is contained in:
aozhiwei 2024-06-20 15:54:54 +08:00
parent 998a5ed22e
commit 475eb8f07d
2 changed files with 20 additions and 0 deletions

View File

@ -121,6 +121,12 @@ func (this *ShopCartApi) Add(c *gin.Context) {
c.JSON(200, rspObj)
return
}
if len(reqJson.Tokens) > constant.SHOPCART_MAX_GOODS_NUM {
rspObj.ErrCode = 2
rspObj.ErrMsg = "token len error"
c.JSON(200, rspObj)
return
}
f5.GetGoStyleDb().OrmSelectOne(
constant.BCNFT_DB,

View File

@ -4,6 +4,7 @@ import (
"q5"
"f5"
"fmt"
"main/constant"
)
type NftHomeMeta struct {
@ -127,6 +128,19 @@ func (this* ShopCart) GetGoods(netId int32, contractAddress string, tokenId stri
}
func (this* ShopCart) DeleteExcessData() {
q5.Sort[ShopCartGoods](this.Goods,
func (a *ShopCartGoods, b *ShopCartGoods) bool{
return a.SortIdx > b.SortIdx
})
newGoods := []*ShopCartGoods{}
for _, val := range this.Goods {
if len(newGoods) < constant.SHOPCART_MAX_GOODS_NUM {
q5.AppendSlice(&newGoods, val)
} else {
break
}
}
this.Goods = newGoods
q5.Sort[ShopCartGoods](this.Goods,
func (a *ShopCartGoods, b *ShopCartGoods) bool{
return a.SortIdx < b.SortIdx