32 lines
588 B
Go
32 lines
588 B
Go
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) //退出时保存
|
|
}
|