Integrate WeChat Official Account support and update configuration

- Added WeChat Official Account configuration options to .env.example and config.go for OAuth2 integration.
- Updated main.go to initialize WeChat OAuth handler and register routes for handling OAuth requests.
- Enhanced documentation to include references for WeChat Official Account functionality.
- Updated route registration to accommodate the new OAuth handler for improved API structure.
This commit is contained in:
nepiedg
2025-12-31 03:55:30 +00:00
parent bba6dc6b4f
commit 1c48fbdeaf
10 changed files with 349 additions and 1 deletions
+5
View File
@@ -8,6 +8,7 @@ import (
authhandler "wx_service/internal/common/auth/handler"
qiniuhandler "wx_service/internal/common/qiniu/handler"
oahandler "wx_service/internal/common/wechat_official/handler"
"wx_service/internal/middleware"
rmhandler "wx_service/internal/remove_watermark/handler"
smokehandler "wx_service/internal/smoke/handler"
@@ -20,6 +21,7 @@ func Register(
videoHandler *rmhandler.VideoHandler,
smokeHandler *smokehandler.SmokeHandler,
uploadHandler *qiniuhandler.UploadHandler,
oaOAuthHandler *oahandler.OAuthHandler,
) {
// Register 用来集中注册所有 HTTP 路由,便于工程结构更清晰:
// - main 只负责初始化(配置/DB/依赖注入)
@@ -29,6 +31,9 @@ func Register(
// 登录接口:用微信 code 换取/创建用户并返回 session_key(作为后续 Bearer Token
api.POST("/auth/login", authHandler.LoginWithWeChat)
// 公众号网页授权:不需要登录(code 本身来自微信授权回调)
registerWeChatOfficialRoutes(api, oaOAuthHandler)
// 需要登录的接口组:统一挂载鉴权中间件
protected := api.Group("")
protected.Use(middleware.AuthMiddleware(db))