feat: live module and jenkins pipeline to harbor deploy
This commit is contained in:
@@ -5,6 +5,7 @@ package modules
|
||||
|
||||
import (
|
||||
integrationmodule "kra/internal/modules/integration"
|
||||
livemodule "kra/internal/modules/live"
|
||||
paymentmodule "kra/internal/modules/payment"
|
||||
systemmodule "kra/internal/modules/system"
|
||||
taskmodule "kra/internal/modules/task"
|
||||
@@ -20,5 +21,6 @@ func Catalog() module.Catalog {
|
||||
integrationmodule.Definition(),
|
||||
taskmodule.Definition(),
|
||||
paymentmodule.Definition(),
|
||||
livemodule.Definition(),
|
||||
}}
|
||||
}
|
||||
|
||||
@@ -16,25 +16,25 @@ func TestCatalogMigrationIDsAreUnique(t *testing.T) {
|
||||
|
||||
func TestCatalogContainsBuiltInModulesInDependencyOrder(t *testing.T) {
|
||||
catalog := Catalog()
|
||||
if len(catalog.Definitions) != 4 {
|
||||
t.Fatalf("definitions = %d, want 4", len(catalog.Definitions))
|
||||
if len(catalog.Definitions) != 5 {
|
||||
t.Fatalf("definitions = %d, want 5", len(catalog.Definitions))
|
||||
}
|
||||
want := []string{"system", "integration", "task", "payment"}
|
||||
want := []string{"system", "integration", "task", "payment", "live"}
|
||||
for index, name := range want {
|
||||
if got := catalog.Definitions[index].Name; got != name {
|
||||
t.Fatalf("definition[%d] = %q, want %q", index, got, name)
|
||||
}
|
||||
}
|
||||
if got := catalog.MigrationSteps(); len(got) != 13 {
|
||||
t.Fatalf("module migrations = %d, want 13", len(got))
|
||||
if got := catalog.MigrationSteps(); len(got) != 22 {
|
||||
t.Fatalf("module migrations = %d, want 22", len(got))
|
||||
}
|
||||
var menus, apis int
|
||||
for _, definition := range catalog.Definitions {
|
||||
menus += len(definition.Surface.Menus)
|
||||
apis += len(definition.Surface.APIs)
|
||||
}
|
||||
if menus != 3 || apis != 17 {
|
||||
t.Fatalf("admin surface = %d menus/%d APIs, want 3/17", menus, apis)
|
||||
if menus != 11 || apis != 50 {
|
||||
t.Fatalf("admin surface = %d menus/%d APIs, want 11/50", menus, apis)
|
||||
}
|
||||
if got := catalog.DefaultTimedTasks(); len(got) != 2 {
|
||||
t.Fatalf("default timed tasks = %d, want 2", len(got))
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package live
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
dataasset "kra/internal/data/asset"
|
||||
datagift "kra/internal/data/gift"
|
||||
datalive "kra/internal/data/live"
|
||||
datalivechat "kra/internal/data/livechat"
|
||||
datasetting "kra/internal/data/platformsetting"
|
||||
datarecharge "kra/internal/data/recharge"
|
||||
datasystem "kra/internal/data/system"
|
||||
"kra/pkg/database/migration"
|
||||
"kra/pkg/module"
|
||||
)
|
||||
|
||||
func Definition() module.Definition {
|
||||
root := module.Menu{Name: "liveOperations", Path: "liveOperations", Component: "view/routerHolder.vue", Title: "宇宙直播", Icon: "video-camera", Sort: 2}
|
||||
menus := []module.Menu{root, {Name: "liveRooms", Path: "liveRooms", ParentName: root.Name, Component: "modules/live/view/rooms.vue", Title: "直播间", Icon: "video-camera", Sort: 1}, {Name: "liveGifts", Path: "liveGifts", ParentName: root.Name, Component: "modules/live/view/gifts.vue", Title: "礼物管理", Icon: "present", Sort: 2}, {Name: "liveCategories", Path: "liveCategories", ParentName: root.Name, Component: "modules/live/view/categories.vue", Title: "分类管理", Icon: "price-tag", Sort: 3}, {Name: "liveOrders", Path: "liveOrders", ParentName: root.Name, Component: "modules/live/view/orders.vue", Title: "订单明细", Icon: "document", Sort: 4}, {Name: "liveSends", Path: "liveSends", ParentName: root.Name, Component: "modules/live/view/sends.vue", Title: "刷礼物明细", Icon: "promotion", Sort: 5}, {Name: "liveUsers", Path: "liveUsers", ParentName: root.Name, Component: "modules/live/view/users.vue", Title: "用户资产", Icon: "user", Sort: 6}, {Name: "liveSettings", Path: "liveSettings", ParentName: root.Name, Component: "modules/live/view/settings.vue", Title: "全站设置", Icon: "setting", Sort: 7}}
|
||||
apis := APIs()
|
||||
steps := append([]migration.Step{}, datalive.Migrations()...)
|
||||
steps = append(steps, datalivechat.Migrations()...)
|
||||
steps = append(steps, datagift.Migrations()...)
|
||||
steps = append(steps, datarecharge.Migrations()...)
|
||||
steps = append(steps, dataasset.Migrations()...)
|
||||
steps = append(steps, datasetting.Migrations()...)
|
||||
steps = append(steps, migration.Step{ID: "202609190006_live_admin_surface", Migrate: func(db *gorm.DB) error {
|
||||
var menuCount int64
|
||||
if err := db.Table("sys_base_menus").Count(&menuCount).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if menuCount == 0 {
|
||||
return nil
|
||||
}
|
||||
if err := datasystem.EnsureAdminSurface(db, module.Surface{Menus: []module.Menu{root}}, 888); err != nil {
|
||||
return err
|
||||
}
|
||||
return datasystem.EnsureAdminSurface(db, module.Surface{Menus: menus[1:], APIs: apis}, 888)
|
||||
}})
|
||||
steps = append(steps, migration.Step{ID: "202609210001_remove_live_dashboard_menu", Migrate: func(db *gorm.DB) error {
|
||||
return datasystem.RemoveAdminMenus(db, "liveDashboard")
|
||||
}})
|
||||
return module.Definition{Name: "live", Migrations: steps, Surface: module.Surface{Menus: menus, APIs: apis}}
|
||||
}
|
||||
func APIs() []module.API {
|
||||
defs := []struct{ m, p, d string }{{"GET", "/live/admin/dashboard", "直播数据概览"}, {"GET", "/live/admin/categories", "查询直播分类"}, {"POST", "/live/admin/categories", "新建直播分类"}, {"PUT", "/live/admin/categories/:id", "更新直播分类"}, {"DELETE", "/live/admin/categories/:id", "删除直播分类"}, {"GET", "/live/admin/rooms", "查询直播间"}, {"GET", "/live/admin/rooms/:id", "查询直播间详情"}, {"POST", "/live/admin/rooms", "新建直播间"}, {"PUT", "/live/admin/rooms/:id", "更新直播间"}, {"DELETE", "/live/admin/rooms/:id", "删除直播间"}, {"PATCH", "/live/admin/rooms/:id/status", "启停直播间"}, {"PUT", "/live/admin/rooms/sort", "保存直播间排序"}, {"GET", "/live/admin/gifts", "查询礼物"}, {"GET", "/live/admin/gifts/:id", "查询礼物详情"}, {"POST", "/live/admin/gifts", "新建礼物"}, {"PUT", "/live/admin/gifts/:id", "更新礼物"}, {"DELETE", "/live/admin/gifts/:id", "删除礼物"}, {"PATCH", "/live/admin/gifts/:id/status", "上下架礼物"}, {"PUT", "/live/admin/gifts/sort", "保存礼物排序"}, {"GET", "/live/admin/sends", "查询打赏流水"}, {"GET", "/live/admin/orders", "查询充值订单"}, {"GET", "/live/admin/orders/:orderNo", "查询充值订单详情"}, {"PUT", "/live/admin/recharge/plans", "保存充值档位"}, {"GET", "/live/admin/users", "查询用户资产"}, {"GET", "/live/admin/users/:id", "查询用户详情"}, {"PATCH", "/live/admin/users/:id/status", "启停用户"}, {"POST", "/live/admin/users/:id/balance", "调整钻石余额"}, {"PUT", "/live/admin/settings", "保存全站设置"}, {"GET", "/live/client/me", "获取直播用户资料"}, {"PUT", "/live/client/me", "更新直播用户资料"}, {"PUT", "/live/client/me/password", "修改直播用户密码"}, {"POST", "/live/rooms/:id/gifts", "直播间送礼"}, {"POST", "/live/recharge/orders", "创建充值订单"}}
|
||||
out := make([]module.API, 0, len(defs))
|
||||
for _, v := range defs {
|
||||
out = append(out, module.API{Path: v.p, Method: v.m, Group: "宇宙直播", Description: v.d})
|
||||
}
|
||||
return out
|
||||
}
|
||||
Reference in New Issue
Block a user