1
This commit is contained in:
parent
998a5ed22e
commit
475eb8f07d
@ -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,
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user