实现个人客户微信认证和短信验证功能

- 添加个人客户微信登录和手机验证码登录接口
- 实现个人客户设备、ICCID、手机号关联管理
- 添加短信发送服务(HTTP 客户端)
- 添加微信认证服务(含 mock 实现)
- 添加 JWT Token 生成和验证工具
- 创建数据库迁移脚本(personal_customer 关联表)
- 修复测试文件中的路由注册参数错误
- 重构 scripts 目录结构(分离独立脚本到子目录)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-10 11:42:38 +08:00
parent 1b9080e3ab
commit 9c6d4a3bd4
53 changed files with 4258 additions and 97 deletions

View File

@@ -0,0 +1,38 @@
package routes
import (
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
"github.com/break/junhong_cmp_fiber/internal/middleware"
"github.com/gofiber/fiber/v2"
)
// RegisterPersonalCustomerRoutes 注册个人客户路由
// 路由挂载在 /api/c/v1 下
func RegisterPersonalCustomerRoutes(app *fiber.App, handlers *bootstrap.Handlers, personalAuthMiddleware *middleware.PersonalAuthMiddleware) {
// C端路由组 (Customer)
customerGroup := app.Group("/api/c/v1")
// 公开路由(不需要认证)
publicGroup := customerGroup.Group("")
{
// 发送验证码
publicGroup.Post("/login/send-code", handlers.PersonalCustomer.SendCode)
// 登录
publicGroup.Post("/login", handlers.PersonalCustomer.Login)
}
// 需要认证的路由
authGroup := customerGroup.Group("")
authGroup.Use(personalAuthMiddleware.Authenticate())
{
// 绑定微信
authGroup.Post("/bind-wechat", handlers.PersonalCustomer.BindWechat)
// 获取个人资料
authGroup.Get("/profile", handlers.PersonalCustomer.GetProfile)
// 更新个人资料
authGroup.Put("/profile", handlers.PersonalCustomer.UpdateProfile)
}
}

View File

@@ -8,14 +8,17 @@ import (
// RegisterRoutes 路由注册总入口
// 按业务模块调用各自的路由注册函数
func RegisterRoutes(app *fiber.App, handlers *bootstrap.Handlers) {
func RegisterRoutes(app *fiber.App, handlers *bootstrap.Handlers, middlewares *bootstrap.Middlewares) {
// 1. 全局路由
registerHealthRoutes(app)
// 2. Admin 域 (挂载在 /api/admin)
adminGroup := app.Group("/api/admin")
RegisterAdminRoutes(adminGroup, handlers, nil, "/api/admin")
// 任务相关路由 (归属于 Admin 域)
registerTaskRoutes(adminGroup)
// 3. 个人客户路由 (挂载在 /api/c/v1)
RegisterPersonalCustomerRoutes(app, handlers, middlewares.PersonalAuth)
}