更新用户登录
This commit is contained in:
@@ -107,6 +107,7 @@ func UserLogin(c *gin.Context) {
|
|||||||
Telephone: phoneInfo.PhoneNumber,
|
Telephone: phoneInfo.PhoneNumber,
|
||||||
// 若还有 password、avatar_url、birthdate、bio 等字段需要赋值,可在此补充
|
// 若还有 password、avatar_url、birthdate、bio 等字段需要赋值,可在此补充
|
||||||
// 比如 Password: "默认密码"(实际中密码应加密存储),AvatarUrl: "默认头像地址" 等
|
// 比如 Password: "默认密码"(实际中密码应加密存储),AvatarUrl: "默认头像地址" 等
|
||||||
|
Birthdate: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := databaseInit.UserDB.Create(&newUser).Error; err != nil {
|
if err := databaseInit.UserDB.Create(&newUser).Error; err != nil {
|
||||||
@@ -180,16 +181,16 @@ func pkcs7Unpad(data []byte) []byte {
|
|||||||
|
|
||||||
// 定义与表结构对应的用户模型
|
// 定义与表结构对应的用户模型
|
||||||
type UserInfo struct {
|
type UserInfo struct {
|
||||||
Uid string `gorm:"column:uid;primaryKey"`
|
Uid string `gorm:"column:uid;primaryKey"`
|
||||||
Telephone string `gorm:"column:telephone"`
|
Telephone string `gorm:"column:telephone"`
|
||||||
Password string `gorm:"column:password"`
|
Password string `gorm:"column:password"`
|
||||||
AvatarUrl string `gorm:"column:avatar_url"`
|
AvatarUrl string `gorm:"column:avatar_url"`
|
||||||
Gender int `gorm:"column:gender"`
|
Gender int `gorm:"column:gender"`
|
||||||
Birthdate time.Time `gorm:"column:birthdate;type:datetime"`
|
Birthdate *time.Time `gorm:"column:birthdate-date;type:datetime;nullable"`
|
||||||
CreatedTime time.Time `gorm:"column:createdtime;type:datetime"`
|
CreatedTime time.Time `gorm:"column:createdtime;type:datetime"`
|
||||||
UpdatedTime time.Time `gorm:"column:updatedtime;type:datetime"`
|
UpdatedTime time.Time `gorm:"column:updatedtime;type:datetime"`
|
||||||
Bio string `gorm:"column:bio"`
|
Bio string `gorm:"column:bio"`
|
||||||
Username string `gorm:"column:username"`
|
Username string `gorm:"column:username"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 自定义表名
|
// 自定义表名
|
||||||
|
|||||||
Reference in New Issue
Block a user