Files
wx_service/internal/routes/smoke_routes.go
T
nepiedg f1f77a4d3d Add dashboard and latest logs endpoints for smoke tracking
- Introduced a new API endpoint `GET /api/v1/smoke/dashboard` to retrieve a summary of smoking statistics over a specified date range, including today's count and weekly breakdown.
- Added `GET /api/v1/smoke/logs/latest` endpoint to fetch the most recent smoking logs with a configurable limit.
- Updated the smoke handler and service to support the new functionality, including error handling for date parsing and limit validation.
- Enhanced documentation to reflect the new API endpoints and their usage.
2026-01-06 00:17:51 +00:00

26 lines
839 B
Go

package routes
import (
"github.com/gin-gonic/gin"
smokehandler "wx_service/internal/smoke/handler"
)
func registerSmokeRoutes(protected *gin.RouterGroup, smokeHandler *smokehandler.SmokeHandler) {
// 戒烟/抽烟记录(与 video 去水印功能在路由前缀上区分开)
smoke := protected.Group("/smoke")
{
smoke.GET("/dashboard", smokeHandler.Dashboard)
smoke.POST("/logs", smokeHandler.Create)
smoke.GET("/logs", smokeHandler.List)
smoke.GET("/logs/latest", smokeHandler.LatestLogs)
smoke.GET("/logs/:id", smokeHandler.Get)
smoke.PUT("/logs/:id", smokeHandler.Update)
smoke.DELETE("/logs/:id", smokeHandler.Delete)
// AI 戒烟建议(会员优先;非会员需看广告解锁)
smoke.GET("/ai/advice", smokeHandler.GetAIAdvice)
smoke.POST("/ai/advice_unlocks", smokeHandler.UnlockAIAdvice)
}
}