From e550502e36fde62019882d4f7bf6f7d819442ada Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Thu, 28 Aug 2025 15:20:05 +0000 Subject: [PATCH] =?UTF-8?q?=E5=88=B7=E6=96=B0=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- login/main.go | 2 +- modules/blazing/service/monster_refresh.go | 60 ++++++++++++++++------ modules/blazing/service/user.go | 4 +- 3 files changed, 48 insertions(+), 18 deletions(-) diff --git a/login/main.go b/login/main.go index 15299e686..080f56663 100644 --- a/login/main.go +++ b/login/main.go @@ -28,7 +28,7 @@ import ( var tt task.GetTaskBufOutboundInfo func main() { - + // Test_kick() cmd.Main.Run(gctx.New()) } diff --git a/modules/blazing/service/monster_refresh.go b/modules/blazing/service/monster_refresh.go index b885d5073..3234e99c2 100644 --- a/modules/blazing/service/monster_refresh.go +++ b/modules/blazing/service/monster_refresh.go @@ -3,9 +3,11 @@ package service import ( "blazing/cool" "blazing/modules/blazing/model" + "fmt" "strconv" "time" + "github.com/dop251/goja" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/util/gconv" @@ -19,12 +21,6 @@ func NewMonsterService() *MonsterService { return &MonsterService{ &cool.Service{ Model: model.NewMonsterRefresh(), - PageQueryOp: &cool.QueryOp{ - FieldEQ: []string{"status", "type"}, - }, - UniqueKey: map[string]string{ - "name": "任务名称不能重复", - }, }, } } @@ -37,13 +33,12 @@ func (s *MonsterService) ModifyAfter(ctx g.Ctx, method string, param g.MapStrAny Name: model.TableNameMonsterRefresh + gconv.String(param["map_id"]), Force: false, })) - //todo 待测试,缓存优化 + return nil } -func (s *MonsterService) GetId(mapid uint32) uint32 { +func (s *MonsterService) GetId(mapid uint32) []model.MonsterRefresh { - //todo 待修改更新时候删除缓存 m := cool.DBM(s.Model).Where("map_id", mapid).Cache( gdb.CacheOption{ Duration: time.Hour, @@ -54,14 +49,49 @@ func (s *MonsterService) GetId(mapid uint32) uint32 { var tt []model.MonsterRefresh m.Scan(&tt) - for _, v := range tt { + // for _, v := range tt { - if v.MapID == int32(mapid) { - return uint32(v.MonsterID) + // if v.MapID == int32(mapid) { + // return uint32(v.MonsterID) - } + // } - } - return 0 + // } + return tt } +func Test_kick() { + const SCRIPT = ` + function shouldRefresh(userId, day, dayOfWeek, hour, minute) { + return true; + + + + + } + ` + t, _ := goja.Compile("test.js", SCRIPT, false) + vm := goja.New() + _, err := vm.RunProgram(t) + if err != nil { + panic(err) + } + sum, ok := goja.AssertFunction(vm.Get("shouldRefresh")) + if !ok { + panic("Not a function") + } + + res, err := sum( + goja.Undefined(), + vm.ToValue(1), + vm.ToValue(time.Now().Day()), + vm.ToValue(time.Now().Weekday()), + vm.ToValue(time.Now().Hour()), + vm.ToValue(time.Now().Minute()), + ) + if err != nil { + panic(err) + } + fmt.Println(res) + // Output: 42 +} diff --git a/modules/blazing/service/user.go b/modules/blazing/service/user.go index d83fd35a0..3a90b0dc0 100644 --- a/modules/blazing/service/user.go +++ b/modules/blazing/service/user.go @@ -8,8 +8,8 @@ import ( type UserService struct { userid uint32 - task *cool.Service - reg *cool.Service + task *cool.Service //任务 + reg *cool.Service //注册 } func NewUserService(id uint32) *UserService {