diff --git a/modules/config/blazing.go b/modules/config/blazing.go index 4174ede8..8cb3c590 100644 --- a/modules/config/blazing.go +++ b/modules/config/blazing.go @@ -1,7 +1,46 @@ -package blazing - -import ( - _ "blazing/modules/config/controller" - _ "blazing/modules/config/model" - _ "blazing/modules/config/service" -) +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" + + "github.com/gogf/gf/v2/frame/g" + "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) + } + _, 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": "", + }).Insert() + if err != nil { + cool.Logger.Warning(ctx, "insert SPT menu failed:", err) + } + } + cool.Logger.Debug(ctx, "module config init finished ...") +} diff --git a/modules/config/controller/admin/spt.go b/modules/config/controller/admin/spt.go new file mode 100644 index 00000000..a6efb636 --- /dev/null +++ b/modules/config/controller/admin/spt.go @@ -0,0 +1,20 @@ +package admin + +import ( + "blazing/cool" + "blazing/modules/config/service" +) + +type SptController struct { + *cool.Controller +} + +func init() { + cool.RegisterController(&SptController{ + &cool.Controller{ + Prefix: "/admin/config/spt", + Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"}, + Service: service.NewSptService(), + }, + }) +} diff --git a/modules/config/model/spt.go b/modules/config/model/spt.go new file mode 100644 index 00000000..019537cb --- /dev/null +++ b/modules/config/model/spt.go @@ -0,0 +1,34 @@ +package model + +import "blazing/cool" + +const ( + TableNameSptConfig = "config_spt" +) + +// SptConfig SPT展示配置(仅保留前端展示必需字段)。 +type SptConfig struct { + *BaseConfig + + 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名字"` + Description string `gorm:"type:text;not null;default:'';comment:'SPT描述'" json:"description" description:"SPT描述"` +} + +func (*SptConfig) TableName() string { + return TableNameSptConfig +} + +func (*SptConfig) GroupName() string { + return "default" +} + +func NewSptConfig() *SptConfig { + return &SptConfig{ + BaseConfig: NewBaseConfig(), + } +} + +func init() { + cool.CreateTable(&SptConfig{}) +} diff --git a/modules/config/resource/initjson/config_spt.json b/modules/config/resource/initjson/config_spt.json new file mode 100644 index 00000000..c10c407f --- /dev/null +++ b/modules/config/resource/initjson/config_spt.json @@ -0,0 +1,100 @@ +[ + { + "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默认数据" + } +] diff --git a/modules/config/service/spt.go b/modules/config/service/spt.go new file mode 100644 index 00000000..71c43d6c --- /dev/null +++ b/modules/config/service/spt.go @@ -0,0 +1,31 @@ +package service + +import ( + "blazing/cool" + "blazing/modules/config/model" +) + +type SptService struct { + *cool.Service +} + +func NewSptService() *SptService { + return &SptService{ + &cool.Service{ + Model: model.NewSptConfig(), + ListQueryOp: &cool.QueryOp{ + FieldEQ: []string{"is_enable"}, + AddOrderby: map[string]string{ + "task_id": "asc", + }, + }, + PageQueryOp: &cool.QueryOp{ + FieldEQ: []string{"is_enable", "task_id"}, + KeyWordField: []string{"title", "description", "remark"}, + AddOrderby: map[string]string{ + "task_id": "asc", + }, + }, + }, + } +}