添加文件: xy_sh/cmd/server/main.go
This commit is contained in:
parent
a527a0c7d4
commit
91d52b392f
|
|
@ -0,0 +1,41 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
|
||||
"xy_sh/internal/biz"
|
||||
"xy_sh/internal/config"
|
||||
"xy_sh/internal/middleware"
|
||||
"xy_sh/internal/router"
|
||||
"xy_sh/internal/service"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 加载配置
|
||||
cfg := config.LoadConfig()
|
||||
|
||||
// 初始化全局加密密钥(注入中间件)
|
||||
middleware.SM4Key = cfg.SM4Key
|
||||
middleware.SM3Salt = cfg.SM3Salt
|
||||
|
||||
// 初始化业务层
|
||||
bizLayer := biz.NewBiz(cfg.SM4Key)
|
||||
|
||||
// 初始化服务层
|
||||
svc := service.NewService(bizLayer)
|
||||
|
||||
// 创建 Fiber 应用
|
||||
app := fiber.New(fiber.Config{
|
||||
AppName: "xy_sh - 卡券/直充权益服务",
|
||||
})
|
||||
|
||||
// 注册路由
|
||||
router.SetupRoutes(app, svc)
|
||||
|
||||
// 启动服务
|
||||
addr := ":" + cfg.ServerPort
|
||||
log.Printf("[启动] 服务监听地址: %s", addr)
|
||||
log.Fatal(app.Listen(addr))
|
||||
}
|
||||
Loading…
Reference in New Issue