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) +}