pull/131/head
wenxu12345 3 years ago
parent e26c3d9462
commit da73347231

@ -22,6 +22,9 @@ func (rpc *rpcAuth) UserRegister(_ context.Context, req *pbAuth.UserRegisterReq)
log.NewInfo(req.OperationID, "UserRegister args ", req.String())
var user imdb.User
utils.CopyStructFields(&user, req.UserInfo)
if req.UserInfo.Birth != 0 {
user.Birth = utils.UnixSecondToTime(req.UserInfo.Birth)
}
err := imdb.UserRegister(user)
if err != nil {
log.NewError(req.OperationID, "UserRegister failed ", err.Error(), user)

@ -214,6 +214,9 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserI
var user imdb.User
utils.CopyStructFields(&user, req.UserInfo)
if req.UserInfo.Birth != 0 {
user.Birth = utils.UnixSecondToTime(req.UserInfo.Birth)
}
err := imdb.UpdateUserInfo(user)
if err != nil {
log.NewError(req.OperationID, "UpdateUserInfo failed ", err.Error(), user)

@ -33,9 +33,6 @@ func UserRegister(user User) error {
return err
}
user.CreateTime = time.Now()
if user.Birth != 0 {
user.Birth = utils.UnixSecondToTime(user.Birth)
}
err = dbConn.Table("user").Create(&user).Error
if err != nil {
@ -83,9 +80,7 @@ func UpdateUserInfo(user User) error {
if err != nil {
return err
}
if user.Birth != 0 {
user.Birth = utils.UnixSecondToTime(user.Birth)
}
err = dbConn.Table("user").Where("user_id=?", user.UserID).Update(&user).Error
return err
}

Loading…
Cancel
Save