From 1ee43e1319e8a44f52e5fe6f846ccde7a4ec2d15 Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Mon, 22 Sep 2025 17:30:03 +0000 Subject: [PATCH] =?UTF-8?q?refactor(service):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=9C=8D=E5=8A=A1=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=80=BB=E8=BE=91=EF=BC=8C=E5=B0=86DBM?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E5=B0=81=E8=A3=85=E4=B8=BAModel=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=B9=B6=E6=B7=BB=E5=8A=A0GetModel=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/cool/service.go | 2 ++ modules/blazing/service/talk.go | 2 +- modules/blazing/service/user.go | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/common/cool/service.go b/common/cool/service.go index 00e464a08..ef998c45e 100644 --- a/common/cool/service.go +++ b/common/cool/service.go @@ -420,6 +420,8 @@ func (s *Service) ModifyAfter(ctx context.Context, method string, param g.MapStr func (s *Service) GetModel() IModel { return s.Model } +// GetModel 获取model + // NewService 新建一个service func NewService(model IModel) *Service { diff --git a/modules/blazing/service/talk.go b/modules/blazing/service/talk.go index 9333d0f48..2ca0f11ce 100644 --- a/modules/blazing/service/talk.go +++ b/modules/blazing/service/talk.go @@ -9,7 +9,7 @@ import ( // todo 待实现xml解析判断是否溢出 func (s *UserService) TalkCheck() map[uint32]uint32 { - m1 := cool.DBM(s.talk.Model).Where("player_id", s.userid) + m1 := s.Model(s.talk.Model) var talks []model.Talk m1.Scan(&talks) diff --git a/modules/blazing/service/user.go b/modules/blazing/service/user.go index bed5726e3..bbdb33c82 100644 --- a/modules/blazing/service/user.go +++ b/modules/blazing/service/user.go @@ -3,6 +3,8 @@ package service import ( "blazing/cool" "blazing/modules/blazing/model" + + "github.com/gogf/gf/v2/database/gdb" ) type UserService struct { @@ -29,3 +31,7 @@ func NewUserService(id uint32) *UserService { } } +func (s *UserService) Model(m cool.IModel) *gdb.Model { + + return cool.DBM(m).Where("player_id", s.userid) +}