refactor: align framework cleanup with new bootstrap flow
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
@@ -3,21 +3,12 @@ package routes
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/handler"
|
||||
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
||||
)
|
||||
|
||||
// Services 容器,包含所有业务 Handler
|
||||
// 由 main 函数初始化并传递给路由注册函数
|
||||
type Services struct {
|
||||
// RBAC 相关 Handler
|
||||
AccountHandler *handler.AccountHandler
|
||||
RoleHandler *handler.RoleHandler
|
||||
PermissionHandler *handler.PermissionHandler
|
||||
}
|
||||
|
||||
// RegisterRoutes 路由注册总入口
|
||||
// 按业务模块调用各自的路由注册函数
|
||||
func RegisterRoutes(app *fiber.App, services *Services) {
|
||||
func RegisterRoutes(app *fiber.App, handlers *bootstrap.Handlers) {
|
||||
// API 路由组
|
||||
api := app.Group("/api/v1")
|
||||
|
||||
@@ -26,13 +17,13 @@ func RegisterRoutes(app *fiber.App, services *Services) {
|
||||
registerTaskRoutes(api)
|
||||
|
||||
// RBAC 路由
|
||||
if services.AccountHandler != nil {
|
||||
registerAccountRoutes(api, services.AccountHandler)
|
||||
if handlers.Account != nil {
|
||||
registerAccountRoutes(api, handlers.Account)
|
||||
}
|
||||
if services.RoleHandler != nil {
|
||||
registerRoleRoutes(api, services.RoleHandler)
|
||||
if handlers.Role != nil {
|
||||
registerRoleRoutes(api, handlers.Role)
|
||||
}
|
||||
if services.PermissionHandler != nil {
|
||||
registerPermissionRoutes(api, services.PermissionHandler)
|
||||
if handlers.Permission != nil {
|
||||
registerPermissionRoutes(api, handlers.Permission)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user