Enhance AI and Redis integration for smoke logging features

- Added AI configuration options to .env.example and config.go for OpenAI integration.
- Implemented Redis caching for session management in main.go and auth middleware.
- Updated smoke logging service to support real smoking time (`smoke_at`) and AI advice retrieval.
- Enhanced API routes to include endpoints for AI advice and unlock functionality for non-members.
- Improved database schema with new tables for AI advice and unlock records.
- Expanded documentation to cover new AI features and Redis caching implementation.
This commit is contained in:
nepiedg
2026-01-03 02:14:21 +00:00
parent 1c48fbdeaf
commit 16844d4a42
30 changed files with 1662 additions and 9 deletions
+6 -1
View File
@@ -8,7 +8,9 @@ import (
authhandler "wx_service/internal/common/auth/handler"
qiniuhandler "wx_service/internal/common/qiniu/handler"
rediscache "wx_service/internal/common/redis/cache"
oahandler "wx_service/internal/common/wechat_official/handler"
membershiphandler "wx_service/internal/membership/handler"
"wx_service/internal/middleware"
rmhandler "wx_service/internal/remove_watermark/handler"
smokehandler "wx_service/internal/smoke/handler"
@@ -20,8 +22,10 @@ func Register(
authHandler *authhandler.AuthHandler,
videoHandler *rmhandler.VideoHandler,
smokeHandler *smokehandler.SmokeHandler,
redeemCodeHandler *membershiphandler.RedeemCodeHandler,
uploadHandler *qiniuhandler.UploadHandler,
oaOAuthHandler *oahandler.OAuthHandler,
sessionCache *rediscache.SessionUserCache,
) {
// Register 用来集中注册所有 HTTP 路由,便于工程结构更清晰:
// - main 只负责初始化(配置/DB/依赖注入)
@@ -36,10 +40,11 @@ func Register(
// 需要登录的接口组:统一挂载鉴权中间件
protected := api.Group("")
protected.Use(middleware.AuthMiddleware(db))
protected.Use(middleware.AuthMiddleware(db, sessionCache))
{
registerCommonRoutes(protected, uploadHandler)
registerRemoveWatermarkRoutes(protected, videoHandler)
registerMembershipRoutes(protected, redeemCodeHandler)
registerSmokeRoutes(protected, smokeHandler)
}
}