From d7885c442fb37b953f5cbabf5199c7e9a63ff7da Mon Sep 17 00:00:00 2001 From: laoboli <1293528695@qq.com> Date: Tue, 3 Feb 2026 15:52:26 +0800 Subject: [PATCH] fix: phone and email nullable. --- models/user.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/models/user.go b/models/user.go index d9c2c94..cfbab23 100644 --- a/models/user.go +++ b/models/user.go @@ -6,13 +6,13 @@ import ( ) type User struct { - ID uint `gorm:"primaryKey" json:"id"` - Username string `gorm:"uniqueIndex;not null" json:"username"` - Email string `gorm:"uniqueIndex;" json:"email"` - Phone string `gorm:"uniqueIndex;" json:"phone"` - Password string `gorm:"not null" json:"-"` - CreatedAt int64 `json:"created_at"` - UpdatedAt int64 `json:"updated_at"` + ID uint `gorm:"primaryKey" json:"id"` + Username string `gorm:"uniqueIndex;not null" json:"username"` + Email *string `gorm:"uniqueIndex;" json:"email"` + Phone *string `gorm:"uniqueIndex;" json:"phone"` + Password string `gorm:"not null" json:"-"` + CreatedAt int64 `json:"created_at"` + UpdatedAt int64 `json:"updated_at"` } // HashPassword 密码加密