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

- 添加个人客户微信登录和手机验证码登录接口
- 实现个人客户设备、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,70 @@
package main
import (
"fmt"
"log"
"gorm.io/driver/postgres"
"gorm.io/gorm"
)
func main() {
// 数据库连接字符串
dsn := "host=cxd.whcxd.cn port=16159 user=erp_pgsql password=erp_2025 dbname=junhong_cmp_test sslmode=disable"
// 连接数据库
db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
if err != nil {
log.Fatalf("连接数据库失败: %v", err)
}
// 查询所有以 personal_customer 开头的表
var tables []string
result := db.Raw(`
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public'
AND table_name LIKE 'personal_customer%'
ORDER BY table_name
`).Scan(&tables)
if result.Error != nil {
log.Fatalf("查询表失败: %v", result.Error)
}
fmt.Println("✅ 个人客户相关表列表:")
for _, table := range tables {
fmt.Printf(" - %s\n", table)
}
// 验证每个表的字段
checkTableColumns(db, "personal_customer_phone")
checkTableColumns(db, "personal_customer_iccid")
checkTableColumns(db, "personal_customer_device")
fmt.Println("\n✅ 数据库迁移验证成功!")
}
func checkTableColumns(db *gorm.DB, tableName string) {
var columns []struct {
ColumnName string
DataType string
}
result := db.Raw(`
SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = ?
ORDER BY ordinal_position
`, tableName).Scan(&columns)
if result.Error != nil {
log.Printf("⚠️ 查询表 %s 的字段失败: %v", tableName, result.Error)
return
}
fmt.Printf("\n表 %s 的字段:\n", tableName)
for _, col := range columns {
fmt.Printf(" - %-20s %s\n", col.ColumnName, col.DataType)
}
}