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"` } // 自定义表名