refactor: 重构项目结构,分离路由注册与主函数入口
- 将路由注册逻辑从主函数移至独立的 router 包 - 更新 main.go 以调用新的路由注册函数 - 删除旧的 digitalhuman/main.go 文件 - 简化常量文件中的注释
This commit is contained in:
@@ -3,7 +3,7 @@ package public
|
|||||||
const (
|
const (
|
||||||
TableNameAudio = "digital_human_audio"
|
TableNameAudio = "digital_human_audio"
|
||||||
TableNameCustomVoice = "digital_human_custom_voice"
|
TableNameCustomVoice = "digital_human_custom_voice"
|
||||||
TableNameAsyncTaskRef = "digital_human_async_task_ref" // 异步任务绑定表(task_id -> 业务表+业务ID)
|
TableNameAsyncTaskRef = "digital_human_async_task_ref"
|
||||||
TableNameVideo = "digital_human_video"
|
TableNameVideo = "digital_human_video"
|
||||||
TableNameDigitalHuman = "digital_human"
|
TableNameDigitalHuman = "digital_human"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,20 +1,12 @@
|
|||||||
package main
|
package router
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"digital-human/digitalhuman/controller"
|
"digital-human/digitalhuman/controller"
|
||||||
|
|
||||||
_ "gitea.com/red-future/common/config"
|
|
||||||
"gitea.com/red-future/common/http"
|
"gitea.com/red-future/common/http"
|
||||||
"gitea.com/red-future/common/jaeger"
|
|
||||||
_ "gitea.com/red-future/common/ragflow"
|
|
||||||
_ "github.com/gogf/gf/contrib/drivers/pgsql/v2"
|
|
||||||
_ "github.com/gogf/gf/contrib/nosql/redis/v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func Router() {
|
||||||
ctx := context.Background()
|
|
||||||
defer jaeger.ShutDown(ctx)
|
|
||||||
// 注册路由
|
// 注册路由
|
||||||
http.RouteRegister([]interface{}{
|
http.RouteRegister([]interface{}{
|
||||||
controller.Audio, // 语音相关接口
|
controller.Audio, // 语音相关接口
|
||||||
@@ -23,6 +15,4 @@ func main() {
|
|||||||
controller.Video, // 视频相关接口
|
controller.Video, // 视频相关接口
|
||||||
controller.AsyncTask, // 异步任务相关接口
|
controller.AsyncTask, // 异步任务相关接口
|
||||||
})
|
})
|
||||||
// 保持应用运行
|
|
||||||
select {}
|
|
||||||
}
|
}
|
||||||
23
main.go
Normal file
23
main.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
digitalhuman "digital-human/digitalhuman/router"
|
||||||
|
|
||||||
|
_ "gitea.com/red-future/common/config"
|
||||||
|
"gitea.com/red-future/common/jaeger"
|
||||||
|
_ "gitea.com/red-future/common/ragflow"
|
||||||
|
_ "github.com/gogf/gf/contrib/drivers/pgsql/v2"
|
||||||
|
_ "github.com/gogf/gf/contrib/nosql/redis/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
ctx := context.Background()
|
||||||
|
defer jaeger.ShutDown(ctx)
|
||||||
|
// 注册路由
|
||||||
|
digitalhuman.Router()
|
||||||
|
|
||||||
|
// 保持应用运行
|
||||||
|
select {}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user