实现面向个人客户的 7 个认证接口(A1-A7),覆盖资产验证、 微信公众号/小程序登录、手机号绑定/换绑、退出登录完整流程。 主要变更: - 新增 PersonalCustomerOpenID 模型,支持多 AppID 多 OpenID 管理 - 实现有状态 JWT(JWT + Redis 双重校验),支持服务端主动失效 - 扩展微信 SDK:小程序 Code2Session + 3 个 DB 动态工厂函数 - 实现 A1 资产验证 IP 限流(30/min)和 A4 三层验证码限流 - 新增 7 个错误码(1180-1186)和 6 个 Redis Key 函数 - 注册 /api/c/v1/auth/* 下 7 个端点并更新 OpenAPI 文档 - 数据库迁移 000083:新建 tb_personal_customer_openid 表
24 lines
1.2 KiB
Go
24 lines
1.2 KiB
Go
package model
|
||
|
||
import (
|
||
"gorm.io/gorm"
|
||
)
|
||
|
||
// PersonalCustomerOpenID 个人客户 OpenID 关联模型
|
||
// 保存客户在不同微信应用(公众号/小程序)下的 OpenID 记录
|
||
// 同一客户可在多个 AppID 下拥有不同的 OpenID
|
||
// 唯一约束:UNIQUE(app_id, open_id) WHERE deleted_at IS NULL
|
||
type PersonalCustomerOpenID struct {
|
||
gorm.Model
|
||
CustomerID uint `gorm:"column:customer_id;type:bigint;not null;index:idx_pco_customer_id;comment:关联个人客户ID" json:"customer_id"`
|
||
AppID string `gorm:"column:app_id;type:varchar(100);not null;comment:微信应用标识(公众号或小程序AppID)" json:"app_id"`
|
||
OpenID string `gorm:"column:open_id;type:varchar(100);not null;comment:当前应用下的OpenID" json:"open_id"`
|
||
UnionID string `gorm:"column:union_id;type:varchar(100);not null;default:'';comment:微信开放平台统一标识(可选)" json:"union_id"`
|
||
AppType string `gorm:"column:app_type;type:varchar(20);not null;default:'';comment:应用类型(official_account/miniapp)" json:"app_type"`
|
||
}
|
||
|
||
// TableName 指定表名
|
||
func (PersonalCustomerOpenID) TableName() string {
|
||
return "tb_personal_customer_openid"
|
||
}
|