实现个人客户微信认证和短信验证功能
- 添加个人客户微信登录和手机验证码登录接口 - 实现个人客户设备、ICCID、手机号关联管理 - 添加短信发送服务(HTTP 客户端) - 添加微信认证服务(含 mock 实现) - 添加 JWT Token 生成和验证工具 - 创建数据库迁移脚本(personal_customer 关联表) - 修复测试文件中的路由注册参数错误 - 重构 scripts 目录结构(分离独立脚本到子目录) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,14 +4,15 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// PersonalCustomer 个人客户模型
|
||||
// PersonalCustomer 个人客户模型(微信用户)
|
||||
// 说明:个人客户由微信 OpenID/UnionID 唯一标识
|
||||
// 手机号、ICCID、设备号通过关联表存储
|
||||
type PersonalCustomer struct {
|
||||
gorm.Model
|
||||
Phone string `gorm:"column:phone;type:varchar(20);uniqueIndex:idx_personal_customer_phone,where:deleted_at IS NULL;comment:手机号(唯一标识)" json:"phone"`
|
||||
Nickname string `gorm:"column:nickname;type:varchar(50);comment:昵称" json:"nickname"`
|
||||
AvatarURL string `gorm:"column:avatar_url;type:varchar(255);comment:头像URL" json:"avatar_url"`
|
||||
WxOpenID string `gorm:"column:wx_open_id;type:varchar(100);index;comment:微信OpenID" json:"wx_open_id"`
|
||||
WxUnionID string `gorm:"column:wx_union_id;type:varchar(100);index;comment:微信UnionID" json:"wx_union_id"`
|
||||
WxOpenID string `gorm:"column:wx_open_id;type:varchar(100);uniqueIndex:idx_personal_customer_wx_open_id,where:deleted_at IS NULL;not null;comment:微信OpenID(唯一标识)" json:"wx_open_id"`
|
||||
WxUnionID string `gorm:"column:wx_union_id;type:varchar(100);index;not null;comment:微信UnionID" json:"wx_union_id"`
|
||||
Nickname string `gorm:"column:nickname;type:varchar(100);comment:微信昵称" json:"nickname"`
|
||||
AvatarURL string `gorm:"column:avatar_url;type:varchar(500);comment:微信头像URL" json:"avatar_url"`
|
||||
Status int `gorm:"column:status;type:int;not null;default:1;comment:状态 0=禁用 1=启用" json:"status"`
|
||||
}
|
||||
|
||||
|
||||
23
internal/model/personal_customer_device.go
Normal file
23
internal/model/personal_customer_device.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// PersonalCustomerDevice 个人客户设备号绑定表
|
||||
// 说明:记录微信用户使用过哪些设备号/IMEI,一个设备号可以被多个微信用户使用过
|
||||
type PersonalCustomerDevice struct {
|
||||
gorm.Model
|
||||
CustomerID uint `gorm:"column:customer_id;type:bigint;not null;comment:关联个人客户ID" json:"customer_id"`
|
||||
DeviceNo string `gorm:"column:device_no;type:varchar(50);not null;comment:设备号/IMEI" json:"device_no"`
|
||||
BindAt time.Time `gorm:"column:bind_at;type:timestamp;not null;comment:绑定时间" json:"bind_at"`
|
||||
LastUsedAt time.Time `gorm:"column:last_used_at;type:timestamp;comment:最后使用时间" json:"last_used_at"`
|
||||
Status int `gorm:"column:status;type:int;not null;default:1;comment:状态 0=禁用 1=启用" json:"status"`
|
||||
}
|
||||
|
||||
// TableName 指定表名
|
||||
func (PersonalCustomerDevice) TableName() string {
|
||||
return "tb_personal_customer_device"
|
||||
}
|
||||
23
internal/model/personal_customer_iccid.go
Normal file
23
internal/model/personal_customer_iccid.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// PersonalCustomerICCID 个人客户ICCID绑定表
|
||||
// 说明:记录微信用户使用过哪些ICCID,一个ICCID可以被多个微信用户使用过
|
||||
type PersonalCustomerICCID struct {
|
||||
gorm.Model
|
||||
CustomerID uint `gorm:"column:customer_id;type:bigint;not null;comment:关联个人客户ID" json:"customer_id"`
|
||||
ICCID string `gorm:"column:iccid;type:varchar(20);not null;comment:ICCID(20位数字)" json:"iccid"`
|
||||
BindAt time.Time `gorm:"column:bind_at;type:timestamp;not null;comment:绑定时间" json:"bind_at"`
|
||||
LastUsedAt time.Time `gorm:"column:last_used_at;type:timestamp;comment:最后使用时间" json:"last_used_at"`
|
||||
Status int `gorm:"column:status;type:int;not null;default:1;comment:状态 0=禁用 1=启用" json:"status"`
|
||||
}
|
||||
|
||||
// TableName 指定表名
|
||||
func (PersonalCustomerICCID) TableName() string {
|
||||
return "tb_personal_customer_iccid"
|
||||
}
|
||||
23
internal/model/personal_customer_phone.go
Normal file
23
internal/model/personal_customer_phone.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// PersonalCustomerPhone 个人客户手机号绑定表
|
||||
// 说明:一个微信用户可以绑定多个手机号
|
||||
type PersonalCustomerPhone struct {
|
||||
gorm.Model
|
||||
CustomerID uint `gorm:"column:customer_id;type:bigint;not null;comment:关联个人客户ID" json:"customer_id"`
|
||||
Phone string `gorm:"column:phone;type:varchar(20);not null;comment:手机号" json:"phone"`
|
||||
IsPrimary bool `gorm:"column:is_primary;type:boolean;not null;default:false;comment:是否主手机号" json:"is_primary"`
|
||||
VerifiedAt time.Time `gorm:"column:verified_at;type:timestamp;comment:验证通过时间" json:"verified_at"`
|
||||
Status int `gorm:"column:status;type:int;not null;default:1;comment:状态 0=禁用 1=启用" json:"status"`
|
||||
}
|
||||
|
||||
// TableName 指定表名
|
||||
func (PersonalCustomerPhone) TableName() string {
|
||||
return "tb_personal_customer_phone"
|
||||
}
|
||||
Reference in New Issue
Block a user