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

This commit is contained in:
昔念
2026-04-18 16:34:03 +08:00
parent 823eef00ac
commit da118dc826
9 changed files with 165 additions and 126 deletions

View File

@@ -2,41 +2,60 @@ package blazing
import (
_ "blazing/modules/config/controller"
_ "blazing/modules/config/packed"
_ "blazing/modules/config/model"
_ "blazing/modules/config/service"
"blazing/cool"
"blazing/modules/config/model"
configModel "blazing/modules/config/model"
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/os/gctx"
)
func init() {
var (
ctx = gctx.GetInitCtx()
mod bool
)
cool.Logger.Debug(ctx, "module config init start ...")
cool.FillInitData(ctx, "config", model.NewSptConfig(), &mod)
if mod {
if err := g.DB("default").Model("base_sys_menu").Where("name", "SPT配置").Delete(); err != nil {
cool.Logger.Warning(ctx, "cleanup duplicated SPT menu failed:", err)
// 首次初始化 SPT 默认数据(不依赖 XML
sptModel := configModel.NewSptConfig()
count, err := g.DB("default").Model(sptModel.TableName()).Count()
if err != nil {
cool.Logger.Warning(ctx, "count config_spt failed:", err)
} else if count == 0 {
initPath := "modules/config/resource/initjson/config_spt.json"
content := gfile.GetBytes(initPath)
if len(content) == 0 {
cool.Logger.Warning(ctx, "config_spt init file is empty:", initPath)
} else {
jsonData, jErr := gjson.LoadContent(content)
if jErr != nil {
cool.Logger.Warning(ctx, "load config_spt init json failed:", jErr)
} else {
_, err = g.DB("default").Model(sptModel.TableName()).Data(jsonData.Var()).Insert()
}
}
_, err := g.DB("default").Model("base_sys_menu").Data(g.Map{
"parentId": 2,
"name": "SPT配置",
"router": "/config/spt",
"viewPath": "config/views/spt.vue",
"module": "config-spt",
"icon": "list",
"orderNum": 70,
"keepAlive": true,
"isShow": 1,
"type": 1,
"isEnable": 1,
"permission": "",
if err != nil {
cool.Logger.Warning(ctx, "insert default config_spt failed:", err)
}
}
menuCount, err := g.DB("default").Model("base_sys_menu").Where("router", "/config/spt").Count()
if err != nil {
cool.Logger.Warning(ctx, "count SPT menu failed:", err)
} else if menuCount == 0 {
_, err = g.DB("default").Model("base_sys_menu").Data(g.Map{
"parentId": 2,
"name": "SPT配置",
"router": "/config/spt",
"viewPath": "config/views/spt.vue",
"icon": "icon-menu",
"ordernum": 70,
"keepAlive": true,
"isShow": true,
"type": 1,
}).Insert()
if err != nil {
cool.Logger.Warning(ctx, "insert SPT menu failed:", err)

View File

@@ -2,6 +2,7 @@ package admin
import (
"blazing/cool"
"blazing/modules/config/model"
"blazing/modules/config/service"
)
@@ -10,6 +11,15 @@ type SptController struct {
}
func init() {
// 仅为新加的 SPT 表做定点迁移,避免首次启用 EPS 时读取表结构报错。
db, err := cool.InitDB("default")
if err != nil {
panic(err)
}
if err = db.AutoMigrate(model.NewSptConfig()); err != nil {
panic(err)
}
cool.RegisterController(&SptController{
&cool.Controller{
Prefix: "/admin/config/spt",

View File

@@ -12,6 +12,11 @@ type SptConfig struct {
TaskID uint32 `gorm:"not null;uniqueIndex;comment:'SPT任务ID'" json:"task_id" description:"SPT任务ID"`
Title string `gorm:"type:varchar(64);not null;default:'';comment:'SPT名字'" json:"title" description:"SPT名字"`
PetID uint32 `gorm:"not null;default:0;comment:'SPT精灵ID'" json:"pet_id" description:"SPT精灵ID"`
Online int32 `gorm:"not null;default:1;comment:'是否开放(1开放/0未开放)'" json:"online" description:"是否开放"`
Level uint32 `gorm:"not null;default:1;comment:'SPT星级'" json:"level" description:"SPT星级"`
SeatID uint32 `gorm:"not null;default:0;comment:'所在地图点位ID'" json:"seat_id" description:"所在地图点位ID"`
EnterID uint32 `gorm:"not null;default:0;comment:'进入地图ID'" json:"enter_id" description:"进入地图ID"`
Description string `gorm:"type:text;not null;default:'';comment:'SPT描述'" json:"description" description:"SPT描述"`
}

View File

@@ -1,100 +0,0 @@
[
{
"task_id": 301,
"title": "蘑菇怪",
"description": "生活在克洛斯星,被艾里逊的液氮冻伤而发狂,使用火焰喷射器可以使它安静下来。制服它可以获得草系精灵小蘑菇。",
"is_enable": 1,
"remark": "SPT默认数据"
},
{
"task_id": 302,
"title": "钢牙鲨",
"description": "海洋星海底的危险怪兽,据说它躲藏的洞穴中有制作黑武士装的黑晶矿石。记住,到海底一定要穿上耐压的潜水套装。",
"is_enable": 1,
"remark": "SPT默认数据"
},
{
"task_id": 303,
"title": "里奥斯",
"description": "海盗艾里逊在火山被它困住,战胜它有机会获得火系精灵“胡里亚”。在火山,你会用到喷水装的。",
"is_enable": 1,
"remark": "SPT默认数据"
},
{
"task_id": 304,
"title": "阿克希亚",
"description": "塞西利亚星的守护者,正义的精灵圣兽,它是不可战胜的,千年来一直等待着宿命的对手。",
"is_enable": 1,
"remark": "SPT默认数据"
},
{
"task_id": 305,
"title": "提亚斯",
"description": "云霄星出现了一只极具攻击性的变异精灵,拥有很多蛋的它虽然想要努力呵护自己的孩子却力不从心,看来需要大家帮帮忙啊。",
"is_enable": 1,
"remark": "SPT默认数据"
},
{
"task_id": 306,
"title": "雷伊",
"description": "赫尔卡星天空中划过一道闪电,映出了一个酷似精灵的黑影,它全身被电流包围,从它的神态中可以看出它正等待来自各方的挑战。",
"is_enable": 1,
"remark": "SPT默认数据"
},
{
"task_id": 307,
"title": "纳多雷",
"description": "在双子阿尔法星上,特派队遇见了一只巨大的精灵,经过多次挑战后,它仍然丝毫无损,赛尔们是否有办法战胜这只精灵呢?",
"is_enable": 1,
"remark": "SPT默认数据"
},
{
"task_id": 308,
"title": "雷纳多",
"description": "彪悍的雷纳多盘踞在双子贝塔星上,和双子阿尔法星的纳多雷遥相对应,守护着星球上所有精灵的。",
"is_enable": 1,
"remark": "SPT默认数据"
},
{
"task_id": 309,
"title": "尤纳斯",
"description": "黑暗之门的制造者,拥有能够抵御一切的暗影屏障和所有能量来源的黑暗之核。",
"is_enable": 1,
"remark": "SPT默认数据"
},
{
"task_id": 310,
"title": "魔狮迪露",
"description": "魔狮迪露具有神秘的力量,能使自己的体力突破界限,但同时也会受到未知的惩罚。",
"is_enable": 1,
"remark": "SPT默认数据"
},
{
"task_id": 311,
"title": "哈莫雷特",
"description": "拥有无比巨大的身躯,集水火草三种原能为一身,龙系的神秘力量使它所向无敌。失忆的它,似乎还有很多谜团……",
"is_enable": 1,
"remark": "SPT默认数据"
},
{
"task_id": 312,
"title": "奈尼芬多",
"description": "奈尼芬多是爱迪星的守护者,凄美的歌声连月亮都为之倾倒,据说只有音乐的力量才能够唤醒它。",
"is_enable": 1,
"remark": "SPT默认数据"
},
{
"task_id": 316,
"title": "厄尔塞拉",
"description": "浑身散发着各色光芒,任何邪恶在她的光芒下消散无形",
"is_enable": 1,
"remark": "SPT默认数据"
},
{
"task_id": 50,
"title": "卡特斯",
"description": "作为暗黑武斗场的试炼精灵,守护着试炼之门,它的气度和风度非同一般,杀气重重很难对付!",
"is_enable": 1,
"remark": "SPT默认数据"
}
]