提交修改反射部分
This commit is contained in:
@@ -3,29 +3,24 @@ package service
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/blazing/model"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
)
|
||||
|
||||
type UserService struct {
|
||||
userid uint32
|
||||
|
||||
*cool.Service
|
||||
task *cool.Service
|
||||
reg *cool.Service
|
||||
}
|
||||
|
||||
func (s *UserService) GetModel() *gdb.Model {
|
||||
|
||||
return cool.DBM(s.Model).Where("player_id", s.userid)
|
||||
func NewUserService(id uint32) *UserService {
|
||||
return &UserService{
|
||||
userid: id,
|
||||
task: &cool.Service{
|
||||
Model: model.NewTask(),
|
||||
},
|
||||
reg: &cool.Service{
|
||||
Model: model.NewPlayer(),
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
func (s *UserService) Exec(t func(map[uint32]model.TaskInfo) bool) {
|
||||
var tt model.Task
|
||||
s.GetModel().Scan(&tt)
|
||||
var ttt map[uint32]model.TaskInfo
|
||||
json.Unmarshal([]byte(tt.Data), &ttt)
|
||||
t(ttt)
|
||||
t1, _ := json.Marshal(&ttt)
|
||||
tt.Data = string(t1)
|
||||
s.GetModel().Save(&tt) //退出时保存
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user