From 3e9916abd259d0bf5ac77163527f2ebdacbc1fac Mon Sep 17 00:00:00 2001 From: weijuesen Date: Thu, 13 Aug 2026 14:31:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(server-go):=20=E6=81=A2=E5=A4=8D=20/health?= =?UTF-8?q?=20=E8=B7=AF=E7=94=B1=EF=BC=88=E5=8E=9F=20health.go=20=E8=A2=AB?= =?UTF-8?q?=E8=A6=86=E7=9B=96=EF=BC=89=EF=BC=8C=E5=81=A5=E5=BA=B7=E7=94=BB?= =?UTF-8?q?=E5=83=8F=E7=8B=AC=E7=AB=8B=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-go/cmd/server/main.go | 3 ++- server-go/internal/handler/health.go | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/server-go/cmd/server/main.go b/server-go/cmd/server/main.go index 8f61625..8ea219c 100644 --- a/server-go/cmd/server/main.go +++ b/server-go/cmd/server/main.go @@ -118,7 +118,8 @@ func main() { handler.RegisterConsultationRoutes(api, db) handler.RegisterDetectionMethodRoutes(api, db) handler.RegisterTraceRoutes(api, db) - handler.RegisterHealthRoutes(api, db) + handler.RegisterHealthRoutes(api) + handler.RegisterHealthProfileRoutes(api, db) // 启动高发病天气预警定时任务(未配置时跳过) go startWeatherAlertLoop(db, weatherSvc, time.Duration(cfg.QWeatherIntervalMin)*time.Minute) diff --git a/server-go/internal/handler/health.go b/server-go/internal/handler/health.go index 49d8a11..2bcb4fd 100644 --- a/server-go/internal/handler/health.go +++ b/server-go/internal/handler/health.go @@ -12,8 +12,15 @@ import ( "gorm.io/gorm" ) -// RegisterHealthRoutes 注册蚕房健康画像路由 -func RegisterHealthRoutes(rg *gin.RouterGroup, db *gorm.DB) { +// RegisterHealthRoutes 注册健康检查路由 +func RegisterHealthRoutes(rg *gin.RouterGroup) { + rg.GET("/health", func(c *gin.Context) { + c.JSON(http.StatusOK, gin.H{"status": "ok"}) + }) +} + +// RegisterHealthProfileRoutes 注册蚕房健康画像路由 +func RegisterHealthProfileRoutes(rg *gin.RouterGroup, db *gorm.DB) { rg.GET("/health-profiles/:roomId", middleware.RequirePermission(db, "room:read"), roomHealthProfile(db))