``refactor(pet): 重构宠物服务结构,将PetService独立封装并继承cool.Service``
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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": "角色名称不能重复",
|
||||
|
||||
Reference in New Issue
Block a user