diff --git a/server/wheelserver/model/bag.go b/server/wheelserver/model/bag.go index 78f18943..3410773d 100644 --- a/server/wheelserver/model/bag.go +++ b/server/wheelserver/model/bag.go @@ -2,7 +2,9 @@ package model import ( "f5" + "errors" "main/constant" + "gorm.io/gorm" ) type Bag struct { @@ -24,3 +26,13 @@ func (this *Bag) Create() error { } return nil } + +func (this *Bag) Find(accountId string, nowTime int64, 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) { + return result.Error, false + } else { + return nil, result.RowsAffected > 0 + } +}