From 696e6225e523d649ab77324de6992ca06f6d8c21 Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Fri, 17 Oct 2025 19:40:27 +0000 Subject: [PATCH] =?UTF-8?q?```refactor(pet):=20=E9=87=8D=E6=9E=84=E5=AE=A0?= =?UTF-8?q?=E7=89=A9=E6=9C=8D=E5=8A=A1=E7=BB=93=E6=9E=84=EF=BC=8C=E5=B0=86?= =?UTF-8?q?PetService=E7=8B=AC=E7=AB=8B=E5=B0=81=E8=A3=85=E5=B9=B6?= =?UTF-8?q?=E7=BB=A7=E6=89=BFcool.Service```?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/cool/service.go | 3 ++- modules/blazing/service/pet.go | 8 ++++++-- modules/blazing/service/user.go | 12 ++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/common/cool/service.go b/common/cool/service.go index ef998c45..4a2a9f40 100644 --- a/common/cool/service.go +++ b/common/cool/service.go @@ -22,6 +22,7 @@ type IService interface { GetModel() IModel // 获取model } type Service struct { + Models *gdb.Model Model IModel ListQueryOp *QueryOp PageQueryOp *QueryOp @@ -420,8 +421,8 @@ func (s *Service) ModifyAfter(ctx context.Context, method string, param g.MapStr func (s *Service) GetModel() IModel { return s.Model } -// GetModel 获取model +// GetModel 获取model // NewService 新建一个service func NewService(model IModel) *Service { diff --git a/modules/blazing/service/pet.go b/modules/blazing/service/pet.go index b3086454..e66a9b5f 100644 --- a/modules/blazing/service/pet.go +++ b/modules/blazing/service/pet.go @@ -52,8 +52,12 @@ func (s *UserService) PetAdd(y model.PetInfo) { } -func NewPetService() *MonsterService { - return &MonsterService{ +type PetService struct { + *cool.Service +} + +func NewPetService() *PetService { + return &PetService{ &cool.Service{ Model: model.NewPet(), PageQueryOp: &cool.QueryOp{ diff --git a/modules/blazing/service/user.go b/modules/blazing/service/user.go index de9c7297..5ba44711 100644 --- a/modules/blazing/service/user.go +++ b/modules/blazing/service/user.go @@ -10,11 +10,11 @@ import ( type UserService struct { userid uint32 //感觉可以给每个server重新继承? - talk *cool.Service //挖矿 - task *cool.Service //任务 - info *cool.Service //信息 - pet *cool.Service //精灵 - item *cool.Service //物品 + talk *cool.Service //挖矿 + task *cool.Service //任务 + info *cool.Service //信息 + pet *PetService //精灵 + item *cool.Service //物品 } func NewUserService(id uint32) *UserService { @@ -29,7 +29,7 @@ func NewUserService(id uint32) *UserService { "player_id": "角色名称不能重复", }, }, - pet: &cool.Service{Model: model.NewPet()}, + pet: NewPetService(), item: &cool.Service{Model: model.NewPlayerBag(), UniqueKey: map[string]string{ "player_id": "角色名称不能重复",