platform_kuaishou_user_info_dao.go 992 B

1234567891011121314151617181920212223242526272829303132333435
  1. package dao
  2. import (
  3. "youngee_b_api/app/entity"
  4. )
  5. type PlatformKuaishouUserInfoDao struct{}
  6. func (d PlatformKuaishouUserInfoDao) GetUserInfo(openId string) (entity.PlatformKuaishouUserInfo, error) {
  7. var userInfo entity.PlatformKuaishouUserInfo
  8. err := Db.Model(&entity.PlatformKuaishouUserInfo{}).Select("open_id, platform_id, nick_name, head_uri, city, gender").Where("open_id = ?", openId).Find(&userInfo).Error
  9. if err != nil {
  10. userInfo.OpenID = openId
  11. userInfo.NickName = ""
  12. userInfo.HeadUri = ""
  13. userInfo.City = ""
  14. userInfo.Gender = ""
  15. }
  16. return userInfo, nil
  17. }
  18. func (d PlatformKuaishouUserInfoDao) GetUserInfoById(id string) (entity.PlatformKuaishouUserInfo, error) {
  19. var userInfo entity.PlatformKuaishouUserInfo
  20. err := Db.First(&userInfo, "id = ?", id).Error
  21. if err != nil {
  22. userInfo.OpenID = id
  23. userInfo.NickName = ""
  24. userInfo.HeadUri = ""
  25. userInfo.City = ""
  26. userInfo.Gender = ""
  27. userInfo.LikeNum = 0
  28. userInfo.VideoNum = 0
  29. }
  30. return userInfo, nil
  31. }