func GetUser(userId string) (apiUser *duoerlapi.User, err error) { user, err := users.FetchByIdHex(userId) if err != nil { utils.PrintStackAndError(err) return } apiUser = toApiUser(user) return }
func UpdateProfile(userInput *duoerlapi.UserInput) (err error) { user, err := users.FetchByIdHex(userInput.Id) if err != nil { utils.PrintStackAndError(err) return } user.AvatarUrl = userInput.Avatar user.Profile.Gender = userInput.Profile.Gender user.Profile.Location = userInput.Profile.Location user.Profile.Description = userInput.Profile.Description user.Profile.HairTexture = userInput.Profile.HairTexture user.Profile.SkinTexture = userInput.Profile.SkinTexture user.Profile.Birthday, _ = time.Parse(global.DATE_BIRTHDAY, userInput.Profile.Birthday) if err = user.Save(); err != nil { utils.PrintStackAndError(err) return } return }