This commit is contained in:
toom1996
2026-08-30 10:45:34 +08:00
parent a6724265ad
commit 9c3403a903
23 changed files with 284 additions and 508 deletions

View File

@ -73,22 +73,25 @@ func main() {
articleRepo = repository.NewArticleRepository(db)
brandRepo = repository.NewBrandRepository(db)
userRepo = repository.NewUserRepository(db)
snapRepo = repository.NewStreetSnapRepository(db)
jwtManager = jwt.NewManager(cfg.JWT.Secret, cfg.JWT.ExpireHours)
articleSvc = service.NewArticleService(articleRepo)
brandSvc = service.NewBrandService(brandRepo)
indexSvc = service.NewIndexService(brandRepo)
snapSvc = service.NewStreetSnapService(snapRepo)
authSvc = service.NewAuthService(userRepo, jwtManager)
)
engine := router.New(router.Options{
Config: cfg,
JWT: jwtManager,
Article: handler.NewArticleHandler(articleSvc),
Brand: handler.NewBrandHandler(brandSvc),
Auth: handler.NewAuthHandler(authSvc),
Health: handler.NewHealthHandler(),
Config: cfg,
JWT: jwtManager,
Article: handler.NewArticleHandler(articleSvc),
Brand: handler.NewBrandHandler(brandSvc),
StreetSnap: handler.NewStreetSnapHandler(snapSvc),
Auth: handler.NewAuthHandler(authSvc),
Health: handler.NewHealthHandler(),
})
// 6. 启动对外公开 HTTP 服务(8090),并支持优雅关闭
@ -109,7 +112,7 @@ func main() {
// 即便部署层误绑了 0.0.0.0,SSGToken 中间件也能作为最后一道闸。
ssgEngine := router.NewSSG(router.Options{
Config: cfg,
SSG: handler.NewSSGHandler(brandSvc, indexSvc),
SSG: handler.NewSSGHandler(brandSvc, indexSvc, snapSvc),
})
srvSSG := &http.Server{
Addr: ":" + cfg.Server.SSGPort,