userThird.go 732 B

123456789101112131415161718192021222324252627
  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:"default:'';not null;"`
  10. // OauthType string `json:"oauth_type" gorm:"not null;"`
  11. ThirdType string `json:"third_type" gorm:"default:'';not null;"` //deprecated
  12. OauthType string `json:"oauth_type" gorm:"default:'';not null;"`
  13. Op string `json:"op" gorm:"default:'';not null;"`
  14. TimeModel
  15. }
  16. func (u *UserThird) FromOauthUser(userId uint, oauthUser *OauthUser, oauthType string, op string) {
  17. u.UserId = userId
  18. u.OauthUser = *oauthUser
  19. u.OauthType = oauthType
  20. u.Op = op
  21. // make sure email is lower case
  22. u.Email = strings.ToLower(u.Email)
  23. }