package dao import ( "youngee_b_api/app/entity" ) type PlatformKuaishouUserInfoDao struct{} func (d PlatformKuaishouUserInfoDao) GetUserInfo(openId string) (entity.PlatformKuaishouUserInfo, error) { var userInfo entity.PlatformKuaishouUserInfo err := Db.Model(&entity.PlatformKuaishouUserInfo{}).Select("open_id, platform_id, nick_name, head_uri, city, gender").Where("open_id = ?", openId).Find(&userInfo).Error if err != nil { userInfo.OpenID = openId userInfo.NickName = "" userInfo.HeadUri = "" userInfo.City = "" userInfo.Gender = "" } return userInfo, nil } func (d PlatformKuaishouUserInfoDao) GetUserInfoById(id string) (entity.PlatformKuaishouUserInfo, error) { var userInfo entity.PlatformKuaishouUserInfo err := Db.First(&userInfo, "id = ?", id).Error if err != nil { userInfo.OpenID = id userInfo.NickName = "" userInfo.HeadUri = "" userInfo.City = "" userInfo.Gender = "" userInfo.LikeNum = 0 userInfo.VideoNum = 0 } return userInfo, nil }