```
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

refactor(config): 移除怪物刷新相关代码并优化地图坑位配置

移除 modules/config/controller/admin/monster_refresh.go 中的
TaskInfoController 及其相关路由注册逻辑

移除 modules/config/model/map_monster.go 中的 MonsterRefresh
模型定义及相关常量、方法

重构 modules/config/model/map_pit.go 中的 MapPit 结
This commit is contained in:
昔念
2026-02-24 14:11:01 +08:00
parent 41714fca0b
commit 0a2ec3af08
4 changed files with 84 additions and 165 deletions

View File

@@ -1,98 +1,95 @@
package service
import (
"blazing/cool"
"blazing/modules/config/model"
// import (
// "blazing/cool"
// "blazing/modules/config/model"
"fmt"
"strconv"
"time"
// "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"
)
// "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"
// )
type MonsterService struct {
*cool.Service
}
// type MonsterService struct {
// *cool.Service
// }
func NewMonsterService() *MonsterService {
return &MonsterService{
&cool.Service{
Model: model.NewMonsterRefresh(),
},
}
}
// func NewMonsterService() *MonsterService {
// return &MonsterService{
// &cool.Service{
// Model: model.NewMonsterRefresh(),
// },
// }
// }
func (s *MonsterService) ModifyAfter(ctx g.Ctx, method string, param g.MapStrAny) (err error) {
// func (s *MonsterService) ModifyAfter(ctx g.Ctx, method string, param g.MapStrAny) (err error) {
gconv.String(param["map_id"])
cool.DBM(s.Model).Cache((gdb.CacheOption{
Duration: -1,
Name: model.TableNameMonsterRefresh + gconv.String(param["map_id"]),
Force: false,
}))
// gconv.String(param["map_id"])
// cool.DBM(s.Model).Cache((gdb.CacheOption{
// Duration: -1,
// Name: model.TableNameMonsterRefresh + gconv.String(param["map_id"]),
// Force: false,
// }))
return nil
}
// return nil
// }
func (s *MonsterService) GetId(mapid uint32) []model.MonsterRefresh {
// func (s *MonsterService) GetId(mapid uint32) []model.MonsterRefresh {
m := cool.DBM(s.Model).Where("map_id", mapid).Cache(
gdb.CacheOption{
Duration: time.Hour,
Name: model.TableNameMonsterRefresh + strconv.Itoa(int(mapid)),
Force: false,
},
)
var tt []model.MonsterRefresh
m.Scan(&tt)
// m := cool.DBM(s.Model).Where("map_id", mapid).Cache(
// gdb.CacheOption{
// Duration: time.Hour,
// Name: model.TableNameMonsterRefresh + strconv.Itoa(int(mapid)),
// Force: false,
// },
// )
// 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 tt
// // }
// 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")
}
// }
// func Test_kick() {
// const SCRIPT = `
// function shouldRefresh(userId, day, dayOfWeek, hour, minute) {
// return true;
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
}
// }
// `
// 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
// }