From 6c26e448fd40632348b0caf87b63ee6e7739167c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <12574910+72wo@users.noreply.github.com> Date: Tue, 24 Feb 2026 12:53:07 +0800 Subject: [PATCH] =?UTF-8?q?```=20refactor(common):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E6=9C=AA=E4=BD=BF=E7=94=A8=E7=9A=84XML=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除test_test.go中未完成的Mapxml函数和login/main.go中的 XML解析注释代码,清理无用的导入包,优化代码结构 BREAKING CHANGE: 删除了modules/config/model/map_moster_node.go 文件中的MapPit相关模型定义 ``` --- common/utils/test_test.go | 7 + help/查询超规精灵.sql | 8 + login/main.go | 13 + modules/config/controller/admin/mappit.go | 22 + .../config/model/{mapnode.go => map_node.go} | 0 .../model/{map_moster_node.go => map_pit.go} | 16 +- modules/config/service/map_pit.go | 21 + public/config/地图配置野怪.xml | 2125 ++++++----------- 8 files changed, 772 insertions(+), 1440 deletions(-) create mode 100644 help/查询超规精灵.sql create mode 100644 modules/config/controller/admin/mappit.go rename modules/config/model/{mapnode.go => map_node.go} (100%) rename modules/config/model/{map_moster_node.go => map_pit.go} (68%) create mode 100644 modules/config/service/map_pit.go diff --git a/common/utils/test_test.go b/common/utils/test_test.go index 4d4b23e13..902cd230a 100644 --- a/common/utils/test_test.go +++ b/common/utils/test_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/apcera/termtables" + "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/glog" ) @@ -37,6 +38,12 @@ type Map struct { Galaxy string `xml:"galaxy,attr" json:"galaxy,omitempty"` } +func Mapxml() { + + superMaps := &SuperMaps{} + err := xml.Unmarshal([]byte(gfile.GetBytes("public/config/地图配置野怪.xml")), superMaps) + fmt.Println(err) +} func TestXml(t *testing.T) { // 示例XML数据 xmlData := ` diff --git a/help/查询超规精灵.sql b/help/查询超规精灵.sql new file mode 100644 index 000000000..22db5b4a9 --- /dev/null +++ b/help/查询超规精灵.sql @@ -0,0 +1,8 @@ +-- 所有宠物ID + 对应记录总数(去重前) +SELECT + (data->>'ID')::INT AS pet_id, -- 宠物ID + COUNT(*) AS total_records -- 该宠物的总持有记录数 +FROM "player_pet" +WHERE data->>'ID' IS NOT NULL -- 过滤无宠物ID的无效记录 +GROUP BY (data->>'ID')::INT +ORDER BY total_records DESC, pet_id ASC; -- 按数量降序、ID升序排列 \ No newline at end of file diff --git a/login/main.go b/login/main.go index 8d32f4f92..5f2ea7df3 100644 --- a/login/main.go +++ b/login/main.go @@ -28,7 +28,20 @@ func init() { } func main() { + // superMaps := &xmlres.MonsterRoot{} + // err := xml.Unmarshal([]byte(gfile.GetBytes("public/config/地图配置野怪.xml")), superMaps) + // for _, v := range superMaps.Maps { + // if v.Monsters != nil { + // for _, v1 := range v.Monsters.Monsters { + // fmt.Println(v.Name, v1.ID, "|", v1.Lv) + + // } + + // } + + // } + // fmt.Println(err) // err := service.RemoteExecuteScript(ip, sshPort, user, password, scriptPort) // if err != nil { // log.Fatal(err) diff --git a/modules/config/controller/admin/mappit.go b/modules/config/controller/admin/mappit.go new file mode 100644 index 000000000..62db64900 --- /dev/null +++ b/modules/config/controller/admin/mappit.go @@ -0,0 +1,22 @@ +package admin + +import ( + "blazing/cool" + "blazing/modules/config/service" +) + +type MapPitController struct { + *cool.Controller +} + +func init() { + + // 注册路由 + cool.RegisterController(&MapPitController{ + &cool.Controller{ + Prefix: "/admin/config/mappit", + Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"}, + Service: service.NewMapPitService(), + }, + }) +} diff --git a/modules/config/model/mapnode.go b/modules/config/model/map_node.go similarity index 100% rename from modules/config/model/mapnode.go rename to modules/config/model/map_node.go diff --git a/modules/config/model/map_moster_node.go b/modules/config/model/map_pit.go similarity index 68% rename from modules/config/model/map_moster_node.go rename to modules/config/model/map_pit.go index 666cfcb32..1f5cbe350 100644 --- a/modules/config/model/map_moster_node.go +++ b/modules/config/model/map_pit.go @@ -12,21 +12,23 @@ type Event struct { //携带精灵数组Event Sprites []int32 `gorm:"type:int[];comment:'携带精灵数组'" json:"sprites"` //触发开始时间Event - StartTime int32 `gorm:"type:int;default:0;comment:'触发开始时间'" json:"start_time"` + StartTime string `gorm:"type:varchar(100);default:'';comment:'触发开始时间'" json:"start_time"` //触发结束时间Event - EndTime int32 `gorm:"type:int;default:0;comment:'触发结束时间'" json:"end_time"` + EndTime string `gorm:"type:varchar(100);default:'';comment:'触发结束时间'" json:"end_time"` //触发天气Event Weather []int32 `gorm:"type:int[];comment:'触发天气'" json:"weather"` } // MapPit 地图坑位核心配置模型(参照MonsterRefresh实现风格) type MapPit struct { - *BaseConfig // 复用通用基础配置(ID/创建时间/更新时间等) - MapID []int32 `gorm:"type:int[];comment:'绑定地图地图ID'" json:"map_id"` + *cool.Model // 保留通用Model(ID/创建时间/更新时间等) + + Remark string `gorm:"type:varchar(255);default:'';comment:'性别配置备注(如:默认性别规则)'" json:"remark"` // 调整注释 // 复用通用基础配置(ID/创建时间/更新时间等) + MapID []int32 `gorm:"type:int[];comment:'绑定地图地图ID'" json:"map_id"` *Event PitName string `gorm:"type:varchar(100);default:'';comment:'坑位名称'" json:"pit_name"` - RefreshID []int `gorm:"type:int[];comment:'关联刷新规则ID列表'" json:"refresh_id"` + RefreshID []int `gorm:"type:int[];comment:'精灵ID列表'" json:"refresh_id"` //最小等级 MinLevel int `gorm:"type:int;default:0;comment:'最小等级'" json:"min_level"` //最大等级 @@ -48,8 +50,8 @@ func (*MapPit) GroupName() string { // NewMapPit 创建一个新的MapPit实例(初始化通用BaseConfig) func NewMapPit() *MapPit { return &MapPit{ - BaseConfig: NewBaseConfig(), - Event: &Event{}, + Model: cool.NewModel(), + Event: &Event{}, } } diff --git a/modules/config/service/map_pit.go b/modules/config/service/map_pit.go new file mode 100644 index 000000000..2cb320f9f --- /dev/null +++ b/modules/config/service/map_pit.go @@ -0,0 +1,21 @@ +package service + +import ( + "blazing/cool" + "blazing/modules/config/model" +) + +type MapPitService struct { + *cool.Service +} + +func NewMapPitService() *MapPitService { + return &MapPitService{ + &cool.Service{ + Model: model.NewMapPit(), + PageQueryOp: &cool.QueryOp{ + KeyWordField: []string{"remake"}, + }, + }, + } +} diff --git a/public/config/地图配置野怪.xml b/public/config/地图配置野怪.xml index 5940bf0bc..ea571cf7d 100644 --- a/public/config/地图配置野怪.xml +++ b/public/config/地图配置野怪.xml @@ -69,8 +69,7 @@ GBTL: NonVipCost:非vip用户进地图所要支付的赛尔豆,vip用户免费 --> - - - - + + + - @@ -186,16 +179,13 @@ eg: - + - + - + @@ -350,24 +340,19 @@ eg: - + - + - + - + - + @@ -391,8 +376,7 @@ eg: - + @@ -405,8 +389,7 @@ eg: - + @@ -440,14 +423,12 @@ eg: - + - + @@ -488,11 +469,8 @@ eg: - - + + - + @@ -646,13 +616,11 @@ eg: - + - + @@ -671,13 +639,11 @@ eg: - - + @@ -699,30 +665,22 @@ eg: - + - + - + - - + + - @@ -730,11 +688,8 @@ eg: - - + + @@ -746,14 +701,11 @@ eg: - + - + @@ -923,16 +875,14 @@ eg: - + - + @@ -993,8 +943,7 @@ eg: - + @@ -1014,24 +963,18 @@ eg: - - + + - + - + @@ -1060,20 +1003,15 @@ eg: - + - - + + @@ -1081,8 +1019,7 @@ eg: - + @@ -1102,28 +1039,21 @@ eg: - + - + - - + + - + @@ -1171,40 +1101,32 @@ eg: - + - + - + - + - + - + - + - + @@ -1223,10 +1145,8 @@ eg: - - + + @@ -1235,24 +1155,18 @@ eg: - + - + - - + + @@ -1276,12 +1190,10 @@ eg: - - + + - + @@ -1303,9 +1215,7 @@ eg: - + @@ -1315,11 +1225,9 @@ eg: - + - + @@ -1329,67 +1237,39 @@ eg: - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + @@ -1446,9 +1326,7 @@ eg: - + @@ -1458,23 +1336,17 @@ eg: - + - - + + - - + + @@ -1511,8 +1383,7 @@ eg: - + @@ -1636,14 +1507,16 @@ eg: - - - + + + + + + - + @@ -1663,8 +1536,7 @@ eg: - + @@ -1677,10 +1549,8 @@ eg: - - + + @@ -1713,33 +1583,24 @@ eg: - - - + + + - + - - + + - + @@ -1774,10 +1635,8 @@ eg: - - + + @@ -1834,16 +1693,11 @@ eg: - + - + - + @@ -1851,13 +1705,10 @@ eg: - - + + - - + @@ -1917,21 +1767,16 @@ eg: - + - + - + @@ -1940,8 +1785,7 @@ eg: - + @@ -1956,18 +1800,15 @@ eg: - + - - @@ -1983,11 +1824,8 @@ eg: - - + + @@ -2038,11 +1876,8 @@ eg: - - + + @@ -2065,90 +1900,52 @@ eg: - + - + - + - + - + - + - + - - + @@ -2355,8 +2152,7 @@ eg: - + @@ -2544,53 +2340,41 @@ eg: - + - + - + - + - + - - - - + + + + - + - - + + @@ -2679,24 +2463,19 @@ eg: - + - + - + - + - + @@ -2705,8 +2484,7 @@ eg: - - @@ -2801,8 +2578,7 @@ eg: - + @@ -2819,8 +2595,7 @@ eg: - + @@ -2892,36 +2667,28 @@ eg: - + - + - + - + - + - + - + - + @@ -2953,12 +2720,10 @@ eg: - + - + @@ -2966,23 +2731,19 @@ eg: - + - + - + - + @@ -3017,8 +2778,7 @@ eg: - + @@ -3027,8 +2787,7 @@ eg: - + @@ -3038,89 +2797,84 @@ eg: - - - @@ -3156,8 +2910,7 @@ eg: - + @@ -3167,40 +2920,32 @@ eg: - + - + - + - + - + - + - + - + @@ -3238,18 +2983,15 @@ eg: - + - + - + @@ -3266,9 +3008,7 @@ eg: - + @@ -3310,35 +3050,28 @@ eg: - - @@ -3406,8 +3138,7 @@ eg: - + @@ -3417,8 +3148,7 @@ eg: - + @@ -3427,23 +3157,16 @@ eg: - - + + - - + + - - + + @@ -3458,25 +3181,17 @@ eg: - - - + + + - + - - + + @@ -3543,9 +3258,9 @@ eg: - - - + + + @@ -3553,8 +3268,7 @@ eg: - + @@ -3570,61 +3284,48 @@ eg: - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3632,11 +3333,9 @@ eg: - + @@ -3686,25 +3382,19 @@ eg: - + - - + + - + @@ -3715,24 +3405,15 @@ eg: - - - - - - - - - + + + + + + + + + @@ -3782,8 +3463,8 @@ eg: - - + + @@ -3794,12 +3475,8 @@ eg: - - + + @@ -3810,8 +3487,7 @@ eg: - + @@ -3835,44 +3511,33 @@ eg: - + - + - + - + - + - + - - - + + + - + @@ -3881,20 +3546,14 @@ eg: - + - - + + - + @@ -3989,12 +3648,8 @@ eg: - - + + @@ -4008,8 +3663,7 @@ eg: - + @@ -4037,8 +3691,7 @@ eg: - + @@ -4060,12 +3713,10 @@ eg: - + - + @@ -4194,45 +3845,29 @@ eg: - + - + - + - + - + - + - + - + - + - + @@ -4240,8 +3875,7 @@ eg: - + @@ -4256,8 +3890,7 @@ eg: - + @@ -4338,8 +3971,7 @@ eg: - + @@ -4356,8 +3988,7 @@ eg: - + @@ -4387,8 +4018,7 @@ eg: - + @@ -4413,15 +4043,11 @@ eg: - + - + @@ -4462,7 +4088,7 @@ eg: - + @@ -4470,8 +4096,7 @@ eg: - + @@ -4488,7 +4113,7 @@ eg: - + @@ -4522,10 +4147,9 @@ eg: - - - - - + - + - + @@ -4792,9 +4401,7 @@ eg: - + @@ -4819,8 +4426,7 @@ eg: - + @@ -4869,8 +4475,7 @@ eg: - + @@ -4984,8 +4589,7 @@ eg: - - + + - - + + - - + + - + @@ -5067,8 +4664,7 @@ eg: - + @@ -5138,14 +4734,12 @@ eg: - - + @@ -5155,8 +4749,7 @@ eg: - + - + - - + @@ -5598,8 +5176,7 @@ eg: - @@ -5815,15 +5392,12 @@ eg: - + - - + + @@ -5856,13 +5430,11 @@ eg: - + - + @@ -5919,8 +5491,7 @@ eg: - + @@ -5934,8 +5505,7 @@ eg: - + @@ -6129,8 +5699,7 @@ eg: - + @@ -6143,8 +5712,7 @@ eg: - + @@ -6197,15 +5765,13 @@ eg: - + - + @@ -6258,12 +5824,10 @@ eg: - - - + - - + - + @@ -6312,14 +5868,11 @@ eg: - + - + @@ -6375,8 +5928,7 @@ eg: - + @@ -6391,14 +5943,11 @@ eg: - + - + - + @@ -6422,35 +5971,27 @@ eg: - - + + - - + + - - + + - + - - - + @@ -6501,8 +6039,7 @@ eg: - + @@ -6510,8 +6047,7 @@ eg: - + @@ -6519,8 +6055,7 @@ eg: - + @@ -6528,8 +6063,7 @@ eg: - + @@ -6537,8 +6071,7 @@ eg: - + @@ -6546,8 +6079,7 @@ eg: - + @@ -6555,8 +6087,7 @@ eg: - + @@ -6564,8 +6095,7 @@ eg: - + @@ -6573,8 +6103,7 @@ eg: - + @@ -6593,8 +6122,7 @@ eg: - + @@ -6617,15 +6145,11 @@ eg: - - + + - - + + @@ -6708,12 +6232,10 @@ eg: - + - + @@ -6805,8 +6327,7 @@ eg: - + @@ -6830,17 +6351,14 @@ eg: - + - + - + @@ -6898,8 +6416,7 @@ eg: - + @@ -7029,9 +6546,7 @@ eg: - + @@ -7055,17 +6570,14 @@ eg: - + - - + + @@ -7107,23 +6619,18 @@ eg: - + - + - + - + @@ -7777,8 +7263,7 @@ eg: - + @@ -7839,8 +7324,7 @@ eg: - + @@ -7851,94 +7335,68 @@ eg: - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + - + - + - + - + - + - + - + - + - + - + - + @@ -7947,8 +7405,7 @@ eg: - + @@ -7973,24 +7430,19 @@ eg: - + - + - + - + - + @@ -8019,8 +7471,7 @@ eg: - + @@ -8074,8 +7525,7 @@ eg: - + @@ -8124,12 +7574,10 @@ eg: - + - + @@ -8219,8 +7667,7 @@ eg: - + @@ -8261,20 +7708,16 @@ eg: - + - + - + - + @@ -8291,12 +7734,10 @@ eg: - + - + @@ -8323,19 +7764,13 @@ eg: - - + + - - + + - + @@ -8357,48 +7792,37 @@ eg: - + - + - + - + - + - + - + - + - + - + - + @@ -8492,20 +7916,16 @@ eg: - + - + - + - + @@ -8580,18 +8000,14 @@ eg: - + - - + + - + @@ -8599,24 +8015,16 @@ eg: - + - + - + - + @@ -8692,8 +8100,7 @@ eg: - + @@ -8752,48 +8159,37 @@ eg: - + - + - + - + - + - + - + - + - + - + - + @@ -8807,40 +8203,31 @@ eg: - + - + - + - + - + - + - + - + - + @@ -8942,36 +8329,28 @@ eg: - + - + - + - + - + - + - + - + @@ -8986,8 +8365,7 @@ eg: - + @@ -9000,24 +8378,16 @@ eg: - + - + - + - + @@ -9025,24 +8395,16 @@ eg: - + - + - + - + @@ -9050,24 +8412,16 @@ eg: - + - + - + - + @@ -9151,8 +8505,7 @@ eg: - + @@ -9211,8 +8564,7 @@ eg: - + @@ -9245,17 +8597,14 @@ eg: - + - + - + @@ -9317,52 +8666,40 @@ eg: - + - + - + - + - + - + - + - + - + - + - + - + @@ -9489,17 +8826,14 @@ eg: - + - + - + @@ -9588,24 +8922,19 @@ eg: - + - + - + - + - + @@ -9625,10 +8954,8 @@ eg: - - + + @@ -9662,8 +8989,7 @@ eg: - + @@ -9695,8 +9021,7 @@ eg: - + @@ -9712,48 +9037,37 @@ eg: - + - + - + - + - + - + - + - + - + - + - + - - + + - - + + @@ -9871,28 +9181,22 @@ eg: - + - + - + - + - + - + @@ -9914,8 +9218,7 @@ eg: - + @@ -9965,8 +9268,7 @@ eg: - + @@ -10273,24 +9575,19 @@ eg: - + - + - + - + - + @@ -10885,8 +10182,7 @@ eg: - + @@ -11057,12 +10353,10 @@ eg: - + - + @@ -11078,8 +10372,7 @@ eg: - + @@ -11094,8 +10387,7 @@ eg: - + @@ -11113,8 +10405,7 @@ eg: - + @@ -11134,8 +10425,7 @@ eg: - + - + @@ -11205,8 +10494,7 @@ eg: - + @@ -11435,8 +10723,7 @@ eg: - + @@ -11472,12 +10759,10 @@ eg: - + - + @@ -11505,10 +10790,10 @@ eg: - + - + @@ -11531,7 +10816,8 @@ eg: - G + +G @@ -11639,8 +10925,7 @@ eg: - + @@ -11675,8 +10960,7 @@ eg: - + @@ -11686,10 +10970,11 @@ eg: - - - - - + +- + + +- @@ -11697,85 +10982,65 @@ eg: - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -11975,11 +11240,13 @@ eg: - - @@ -12051,10 +11318,8 @@ eg: - - + + @@ -12077,13 +11342,11 @@ eg: - + - @@ -12189,8 +11452,7 @@ eg: - + @@ -12226,8 +11488,7 @@ eg: - @@ -12514,8 +11775,7 @@ eg: - @@ -13823,8 +13083,7 @@ eg: - +