Files
bl/modules/blazing/service/user.go

46 lines
1015 B
Go

package service
import (
"blazing/cool"
"blazing/modules/blazing/model"
"github.com/gogf/gf/v2/database/gdb"
)
type UserService struct {
userid uint32
talk *cool.Service //挖矿
task *cool.Service //任务
info *cool.Service //信息
pet *cool.Service //精灵
item *cool.Service //物品
}
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: &cool.Service{Model: model.NewPet()},
item: &cool.Service{Model: model.NewPlayerBag(),
UniqueKey: map[string]string{
"player_id": "角色名称不能重复",
}},
talk: &cool.Service{Model: model.NewTalk(), UniqueKey: map[string]string{
"player_id": "角色名称不能重复",
}},
}
}
func (s *UserService) Model(m cool.IModel) *gdb.Model {
return cool.DBM(m).Where("player_id", s.userid)
}