1
This commit is contained in:
parent
c9cda18e3e
commit
d46f12c4aa
@ -41,6 +41,14 @@ func (this *BagApi) UseItem(c *gin.Context) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
reqJson := struct {
|
||||
ItemUniId string `json:"item_uniid"`
|
||||
ItemNum string `json:"item_num"`
|
||||
}{}
|
||||
if err := c.ShouldBindJSON(&reqJson); err != nil {
|
||||
f5.RspErr(c, 401, "params parse error")
|
||||
return
|
||||
}
|
||||
user := new(model.User)
|
||||
rspObj := struct {
|
||||
vo.BaseVo
|
||||
|
@ -27,7 +27,7 @@ func (this *Bag) Create() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *Bag) Find(accountId string, itemId int32) (error, bool) {
|
||||
func (this *Bag) FindByItemId(accountId string, itemId int32) (error, bool) {
|
||||
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Table(this.TableName()).Take(
|
||||
this, "account_id = ? and item_id = ?", accountId, itemId); result.Error != nil &&
|
||||
!errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
@ -37,6 +37,16 @@ func (this *Bag) Find(accountId string, itemId int32) (error, bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *Bag) FindByItemUniId(accountId string, itemUniId int64) (error, bool) {
|
||||
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Table(this.TableName()).Take(
|
||||
this, "account_id = ? and idx = ?", accountId, itemUniId); result.Error != nil &&
|
||||
!errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return result.Error, false
|
||||
} else {
|
||||
return nil, result.RowsAffected > 0
|
||||
}
|
||||
}
|
||||
|
||||
func (this *Bag) AddItemNum(itemNum int32, nowTime int32) error {
|
||||
this.ItemNum += itemNum
|
||||
this.ModifyTime = nowTime
|
||||
|
@ -33,7 +33,7 @@ func (this *award) AddItem(accountId string, itemId int32, itemNum int32, baseVo
|
||||
return
|
||||
}
|
||||
bagItem := new(model.Bag)
|
||||
if err, found := bagItem.Find(accountId, itemId); err == nil {
|
||||
if err, found := bagItem.FindByItemId(accountId, itemId); err == nil {
|
||||
if found {
|
||||
bagItem.AddItemNum(itemNum, int32(nowTime))
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user