Files
junhong_cmp_fiber/internal/model/phone_asset_association.go
break 70e680eb0a
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m2s
feat(手机号资产关联): AUG26-009 手机号—资产关联、十项上限与后台解绑
- 新增成对迁移 000223(tb_phone_asset_association,含有效关系部分唯一索引与 down 守卫)与 000224(解绑导入任务表),不回填历史
- H5:need_bind_phone 三支判定(开关关闭完全短路);已有主号幂等建联;十项上限按手机号 advisory 串行化(含换绑到全新号的并发场景);换绑原子迁移与冲突整单回滚;不写遗留列
- 后台:关联列表、单项/批量解绑、CSV 导入解绑(B1–B16),超管/平台 gate + 资产数据范围复核,三态统一文案
- 读侧:卡/设备列表与详情按页一次 IN 聚合;两类导出补「关联手机号」列并保留历史表头反解兼容
- 脱敏:关联审计走独立动作/资源只写脱敏手机号;访问日志手机号类字段脱敏
- 同步主 Spec openspec/specs/phone-asset-association 并归档 AUG26-009,补齐 requirement-evidence 与入口矩阵,context-health 通过
2026-09-15 11:54:56 +08:00

31 lines
2.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
import (
"time"
"gorm.io/gorm"
)
// PhoneAssetAssociation 手机号—资产当前有效关联。
// 关联只能由 H5 短信验证建立Source 固定为 constants.PhoneAssetAssociationSourceH5SMSVerification
// 后台不提供创建或补录入口。资产身份一律取 (AssetType, AssetID)iot_card 与 device 的 ID 空间独立,
// 同号计为两项资产。失效走 Status 置 0 并同时写失效时间、方式与操作人,关系行保留为业务事实。
type PhoneAssetAssociation struct {
gorm.Model
Phone string `gorm:"column:phone;type:varchar(20);not null;comment:已验证手机号" json:"phone"`
AssetType string `gorm:"column:asset_type;type:varchar(20);not null;comment:资产类型 iot_card/device" json:"asset_type"`
AssetID uint `gorm:"column:asset_id;type:bigint;not null;comment:资产ID" json:"asset_id"`
Status int `gorm:"column:status;type:smallint;not null;default:1;comment:状态 0-已失效 1-有效" json:"status"`
Source string `gorm:"column:source;type:varchar(30);not null;default:'h5_sms_verification';comment:建立来源" json:"source"`
EstablishedAt time.Time `gorm:"column:established_at;type:timestamptz;not null;default:now();comment:关联建立时间" json:"established_at"`
InvalidatedAt *time.Time `gorm:"column:invalidated_at;type:timestamptz;comment:失效时间" json:"invalidated_at"`
InvalidationMethod string `gorm:"column:invalidation_method;type:varchar(30);not null;default:'';comment:失效方式" json:"invalidation_method"`
InvalidationReason string `gorm:"column:invalidation_reason;type:varchar(500);not null;default:'';comment:失效原因" json:"invalidation_reason"`
Invalidator uint `gorm:"column:invalidator;type:bigint;not null;default:0;comment:失效操作人账号ID" json:"invalidator"`
}
// TableName 指定手机号—资产关联表名。
func (PhoneAssetAssociation) TableName() string {
return "tb_phone_asset_association"
}