userThird.go 640 B

12345678910111213141516171819202122232425
  1. package model
  2. import (
  3. "strings"
  4. )
  5. type UserThird struct {
  6. IdModel
  7. UserId uint ` json:"user_id" gorm:"not null;index"`
  8. OauthUser
  9. // UnionId string `json:"union_id" gorm:"not null;"`
  10. // OauthType string `json:"oauth_type" gorm:"not null;"`
  11. OauthType string `json:"oauth_type"`
  12. Op string `json:"op" gorm:"not null;"`
  13. TimeModel
  14. }
  15. func (u *UserThird) FromOauthUser(userId uint, oauthUser *OauthUser, oauthType string, op string) {
  16. u.UserId = userId
  17. u.OauthUser = *oauthUser
  18. u.OauthType = oauthType
  19. u.Op = op
  20. // make sure email is lower case
  21. u.Email = strings.ToLower(u.Email)
  22. }