From 942919e6704f62d6f9b2beb426a26df0516c37da Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 11 Nov 2024 17:58:27 +0800 Subject: [PATCH] 1 --- server/wheelserver/api/v1/shop/shop.go | 6 ++++++ server/wheelserver/model/chip.go | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/server/wheelserver/api/v1/shop/shop.go b/server/wheelserver/api/v1/shop/shop.go index 16bc3170..859d61b6 100644 --- a/server/wheelserver/api/v1/shop/shop.go +++ b/server/wheelserver/api/v1/shop/shop.go @@ -80,5 +80,11 @@ func (this *ShopApi) Buy(c *gin.Context) { f5.RspErr(c, 500, "server internal error5") return } + chip := new(model.Chip) + chip.AccountId = s.GetAccountId() + chip.ItemId = itemMeta.GetId() + chip.ItemNum = 1 + chip.CreateTime = int32(nowTime) + chip.ModifyTime = int32(nowTime) c.JSON(200, rspObj) } diff --git a/server/wheelserver/model/chip.go b/server/wheelserver/model/chip.go index 485e56d4..e1bfa0cd 100644 --- a/server/wheelserver/model/chip.go +++ b/server/wheelserver/model/chip.go @@ -1,12 +1,14 @@ package model import ( + "f5" + "main/constant" ) type Chip struct { Idx int64 `gorm:"column:idx;AUTO_INCREMENT"` AccountId string `gorm:"column:account_id;primaryKey"` - ItemId int64 `gorm:"column:item_id"` + ItemId int32 `gorm:"column:item_id"` ItemNum int32 `gorm:"column:item_num"` CreateTime int32 `gorm:"column:createtime;<-:create"` ModifyTime int32 `gorm:"column:modifytime"` @@ -15,3 +17,10 @@ type Chip struct { func (this *Chip) TableName() string { return "t_chip" } + +func (this *Chip) Create() error { + if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Create(this); result.Error != nil { + return result.Error + } + return nil +}