重构
This commit is contained in:
@@ -2,45 +2,37 @@ package service
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/blazing/model"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
)
|
||||
|
||||
type UserService struct {
|
||||
type BaseService struct {
|
||||
userid uint32
|
||||
//感觉可以给每个server重新继承?
|
||||
talk *cool.Service //挖矿
|
||||
task *cool.Service //任务
|
||||
info *cool.Service //信息
|
||||
pet *PetService //精灵
|
||||
item *cool.Service //物品
|
||||
*cool.Service
|
||||
}
|
||||
type UserService struct {
|
||||
Talk *TalkService //挖矿
|
||||
Task *TaskService //任务
|
||||
Info *InfoService //信息
|
||||
Pet *PetService //精灵
|
||||
Item *ItemService //物品
|
||||
Done *DoneService //完成
|
||||
}
|
||||
|
||||
func NewUserService(id uint32) *UserService {
|
||||
return &UserService{
|
||||
userid: id,
|
||||
task: &cool.Service{
|
||||
Model: model.NewTask(),
|
||||
},
|
||||
info: &cool.Service{
|
||||
Model: model.NewPlayer(),
|
||||
UniqueKey: map[string]string{
|
||||
"player_id": "角色名称不能重复",
|
||||
},
|
||||
},
|
||||
pet: NewPetService(),
|
||||
item: &cool.Service{Model: model.NewPlayerBag(),
|
||||
UniqueKey: map[string]string{
|
||||
"player_id": "角色名称不能重复",
|
||||
}},
|
||||
talk: &cool.Service{Model: model.NewTalk(), UniqueKey: map[string]string{
|
||||
"player_id": "角色名称不能重复",
|
||||
}},
|
||||
|
||||
Task: NewTaskService(id),
|
||||
Info: NewInfoService(id),
|
||||
Pet: NewPetService(id),
|
||||
Item: NewItemService(id),
|
||||
Talk: NewTalkService(id),
|
||||
Done: NewDoneService(id),
|
||||
}
|
||||
|
||||
}
|
||||
func (s *UserService) Model(m cool.IModel) *gdb.Model {
|
||||
|
||||
func (s *BaseService) GModel(m cool.IModel) *gdb.Model {
|
||||
|
||||
return cool.DBM(m).Where("player_id", s.userid)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user