提交修改反射部分

This commit is contained in:
1
2025-08-28 14:38:13 +00:00
parent 7481182371
commit 921a121e11
9 changed files with 94 additions and 90 deletions

View File

@@ -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) //退出时保存
}