提交信息
This commit is contained in:
31
modules/blazing/service/user.go
Normal file
31
modules/blazing/service/user.go
Normal file
@@ -0,0 +1,31 @@
|
||||
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
|
||||
}
|
||||
|
||||
func (s *UserService) GetModel() *gdb.Model {
|
||||
|
||||
return cool.DBM(s.Model).Where("player_id", s.userid)
|
||||
|
||||
}
|
||||
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