From 3182008eefa6fd2befd2db3be743f2d23dbee224 Mon Sep 17 00:00:00 2001 From: mayiming <1627832236@qq.com> Date: Tue, 23 Sep 2025 20:28:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=94=A8=E6=88=B7=E7=99=BB?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/user/userLogin.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/controllers/user/userLogin.go b/controllers/user/userLogin.go index 49a8030..ee7b29c 100644 --- a/controllers/user/userLogin.go +++ b/controllers/user/userLogin.go @@ -107,6 +107,7 @@ func UserLogin(c *gin.Context) { Telephone: phoneInfo.PhoneNumber, // 若还有 password、avatar_url、birthdate、bio 等字段需要赋值,可在此补充 // 比如 Password: "默认密码"(实际中密码应加密存储),AvatarUrl: "默认头像地址" 等 + Birthdate: nil, } if err := databaseInit.UserDB.Create(&newUser).Error; err != nil { @@ -180,16 +181,16 @@ func pkcs7Unpad(data []byte) []byte { // 定义与表结构对应的用户模型 type UserInfo struct { - Uid string `gorm:"column:uid;primaryKey"` - Telephone string `gorm:"column:telephone"` - Password string `gorm:"column:password"` - AvatarUrl string `gorm:"column:avatar_url"` - Gender int `gorm:"column:gender"` - Birthdate time.Time `gorm:"column:birthdate;type:datetime"` - CreatedTime time.Time `gorm:"column:createdtime;type:datetime"` - UpdatedTime time.Time `gorm:"column:updatedtime;type:datetime"` - Bio string `gorm:"column:bio"` - Username string `gorm:"column:username"` + Uid string `gorm:"column:uid;primaryKey"` + Telephone string `gorm:"column:telephone"` + Password string `gorm:"column:password"` + AvatarUrl string `gorm:"column:avatar_url"` + Gender int `gorm:"column:gender"` + Birthdate *time.Time `gorm:"column:birthdate-date;type:datetime;nullable"` + CreatedTime time.Time `gorm:"column:createdtime;type:datetime"` + UpdatedTime time.Time `gorm:"column:updatedtime;type:datetime"` + Bio string `gorm:"column:bio"` + Username string `gorm:"column:username"` } // 自定义表名