From baa75334ea26416658c44295301cab8837fd9316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <12574910+72wo@users.noreply.github.com> Date: Wed, 11 Mar 2026 01:32:49 +0800 Subject: [PATCH] =?UTF-8?q?```=20feat(pet):=20=E4=BF=AE=E6=94=B9=E5=AE=A0?= =?UTF-8?q?=E7=89=A9=E4=BB=B7=E6=A0=BC=E5=AD=97=E6=AE=B5=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E4=B8=BAuint32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 统一宠物价格相关字段的数据类型,将sale_price从float32改为uint32, 以保持数据类型一致性并避免浮点数精度问题。 - 更新controller中PriseReq结构体的Price字段类型 - 修改model中Pet结构体的SalePrice字段类型 - 调整service中UPdatePrice方法的参数类型 ``` --- modules/player/controller/admin/pet.go | 6 +++--- modules/player/model/pet.go | 10 +++++----- modules/player/service/pet.go | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/player/controller/admin/pet.go b/modules/player/controller/admin/pet.go index 81daff4a2..d7b6afea4 100644 --- a/modules/player/controller/admin/pet.go +++ b/modules/player/controller/admin/pet.go @@ -86,9 +86,9 @@ type PetLevelRes struct { } type PriseReq struct { g.Meta `path:"/modpirse" method:"POST"` - Ctime uint32 `json:"catch_time"` - Price float32 `json:"sale_price"` - IsSale uint32 `json:"is_sale"` + Ctime uint32 `json:"catch_time"` + Price uint32 `json:"sale_price"` + IsSale uint32 `json:"is_sale"` } func (c *PetBagController) ModPrise(ctx context.Context, req *PriseReq) (res *cool.BaseRes, err error) { diff --git a/modules/player/model/pet.go b/modules/player/model/pet.go index cead9588b..db24fb60e 100644 --- a/modules/player/model/pet.go +++ b/modules/player/model/pet.go @@ -25,11 +25,11 @@ const TableNamePet = "player_pet" // Pet mapped from table type Pet struct { Base - PlayerID uint32 `gorm:"not null;index:idx_pet_by_player_id;comment:'所属玩家ID'" json:"player_id"` - Free int `gorm:"not null;default:0;comment:'是否放生'" json:"free"` //"0为放入仓库,1为放入背包 - CatchTime uint32 `gorm:"not null;comment:'捕捉时间'" json:"catch_time"` //唯一键 - IsSale int `gorm:"not null;default:0;comment:'是否出售'" json:"is_sale"` - SalePrice float32 `gorm:"not null;default:0;comment:'出售价格'" json:"sale_price"` + PlayerID uint32 `gorm:"not null;index:idx_pet_by_player_id;comment:'所属玩家ID'" json:"player_id"` + Free int `gorm:"not null;default:0;comment:'是否放生'" json:"free"` //"0为放入仓库,1为放入背包 + CatchTime uint32 `gorm:"not null;comment:'捕捉时间'" json:"catch_time"` //唯一键 + IsSale int `gorm:"not null;default:0;comment:'是否出售'" json:"is_sale"` + SalePrice uint32 `gorm:"not null;default:0;comment:'出售价格'" json:"sale_price"` // Owner uint32 `struc:"skip"` //仅作为存储 // FreedTime uint32 `struc:"skip"` //放生时间 //是否可交易,这里应该定义在精灵ID里 diff --git a/modules/player/service/pet.go b/modules/player/service/pet.go index 197969bf0..57b371c87 100644 --- a/modules/player/service/pet.go +++ b/modules/player/service/pet.go @@ -46,7 +46,7 @@ func (s *PetService) UPdateFree(ctime uint32, free uint32) { ).Update() } -func (s *PetService) UPdatePrice(ctime uint32, Price float32, is_sale uint32) { +func (s *PetService) UPdatePrice(ctime uint32, Price uint32, is_sale uint32) { s.dbm(s.Model).Where("catch_time", ctime).Data("sale_price", Price, "is_sale", is_sale).Update() }