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 结
96 lines
1.9 KiB
Go
96 lines
1.9 KiB
Go
package service
|
|
|
|
// import (
|
|
// "blazing/cool"
|
|
// "blazing/modules/config/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"
|
|
// )
|
|
|
|
// type MonsterService struct {
|
|
// *cool.Service
|
|
// }
|
|
|
|
// func NewMonsterService() *MonsterService {
|
|
// return &MonsterService{
|
|
// &cool.Service{
|
|
// Model: model.NewMonsterRefresh(),
|
|
// },
|
|
// }
|
|
// }
|
|
|
|
// 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,
|
|
// }))
|
|
|
|
// return nil
|
|
// }
|
|
|
|
// 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)
|
|
|
|
// // for _, v := range tt {
|
|
|
|
// // if v.MapID == int32(mapid) {
|
|
// // return uint32(v.MonsterID)
|
|
|
|
// // }
|
|
|
|
// // }
|
|
// 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
|
|
// }
|