2025-08-27 20:52:15 +00:00
|
|
|
|
package service
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"blazing/cool"
|
|
|
|
|
|
"blazing/modules/blazing/model"
|
2025-09-22 17:30:03 +00:00
|
|
|
|
|
|
|
|
|
|
"github.com/gogf/gf/v2/database/gdb"
|
2025-08-27 20:52:15 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type UserService struct {
|
|
|
|
|
|
userid uint32
|
2025-10-07 08:14:11 +00:00
|
|
|
|
//感觉可以给每个server重新继承?
|
2025-10-17 19:40:27 +00:00
|
|
|
|
talk *cool.Service //挖矿
|
|
|
|
|
|
task *cool.Service //任务
|
|
|
|
|
|
info *cool.Service //信息
|
|
|
|
|
|
pet *PetService //精灵
|
|
|
|
|
|
item *cool.Service //物品
|
2025-08-27 20:52:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-28 14:38:13 +00:00
|
|
|
|
func NewUserService(id uint32) *UserService {
|
|
|
|
|
|
return &UserService{
|
|
|
|
|
|
userid: id,
|
|
|
|
|
|
task: &cool.Service{
|
|
|
|
|
|
Model: model.NewTask(),
|
|
|
|
|
|
},
|
2025-09-22 17:22:08 +00:00
|
|
|
|
info: &cool.Service{
|
2025-08-28 14:38:13 +00:00
|
|
|
|
Model: model.NewPlayer(),
|
2025-10-07 08:04:57 +00:00
|
|
|
|
UniqueKey: map[string]string{
|
|
|
|
|
|
"player_id": "角色名称不能重复",
|
|
|
|
|
|
},
|
2025-08-28 14:38:13 +00:00
|
|
|
|
},
|
2025-10-17 19:40:27 +00:00
|
|
|
|
pet: NewPetService(),
|
2025-10-07 08:04:57 +00:00
|
|
|
|
item: &cool.Service{Model: model.NewPlayerBag(),
|
|
|
|
|
|
UniqueKey: map[string]string{
|
|
|
|
|
|
"player_id": "角色名称不能重复",
|
|
|
|
|
|
}},
|
|
|
|
|
|
talk: &cool.Service{Model: model.NewTalk(), UniqueKey: map[string]string{
|
|
|
|
|
|
"player_id": "角色名称不能重复",
|
|
|
|
|
|
}},
|
2025-08-28 14:38:13 +00:00
|
|
|
|
}
|
2025-08-27 20:52:15 +00:00
|
|
|
|
|
|
|
|
|
|
}
|
2025-09-22 17:30:03 +00:00
|
|
|
|
func (s *UserService) Model(m cool.IModel) *gdb.Model {
|
|
|
|
|
|
|
|
|
|
|
|
return cool.DBM(m).Where("player_id", s.userid)
|
|
|
|
|
|
}
|