From 6d9d4ff91ba2f30075bb6fc339ba226f05a442aa Mon Sep 17 00:00:00 2001 From: huang <1724659546@qq.com> Date: Sat, 27 Sep 2025 23:22:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=A4=BE=E4=BA=A4=E4=BF=A1?= =?UTF-8?q?=E6=81=AFmodel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/infra/models/user.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/infra/models/user.go b/internal/infra/models/user.go index 6b42d65..9d94286 100644 --- a/internal/infra/models/user.go +++ b/internal/infra/models/user.go @@ -6,6 +6,15 @@ import ( "gorm.io/gorm" ) +// ContactInfo 存储用户的多种联系方式 +// 使用 jsonb 类型存入数据库 +type ContactInfo struct { + Email string `json:"email,omitempty"` + Phone string `json:"phone,omitempty"` + WeChat string `json:"wechat,omitempty"` + Feishu string `json:"feishu,omitempty"` +} + // User 代表系统中的用户模型 type User struct { // gorm.Model 内嵌了 ID, CreatedAt, UpdatedAt, 和 DeletedAt @@ -19,6 +28,9 @@ type User struct { // Password 存储的是加密后的密码哈希,而不是明文 // json:"-" 标签确保此字段在序列化为 JSON 时被忽略,防止密码泄露 Password string `gorm:"not null" json:"-"` + + // Contact 存储用户的联系方式,以 JSONB 格式存入数据库 + Contact ContactInfo `gorm:"type:jsonb" json:"contact"` } // TableName 自定义 User 模型对应的数据库表名