package user_record

import "hongze/hongze_yb/global"

// GetByUserId 根据用户id和平台id获取用户关系
func GetByUserId(userId, platform int) (item *UserRecord, err error) {
	err = global.DEFAULT_MYSQL.Where("user_id = ? and create_platform = ?", userId, platform).First(&item).Error
	return
}

// GetByUnionID 根据用户UnionID和平台id获取用户关系
func GetByUnionID(unionID string, platform int) (item *UserRecord, err error) {
	err = global.DEFAULT_MYSQL.Where("union_id = ? and create_platform = ?", unionID, platform).First(&item).Error
	return
}

// GetByOpenID 根据用户OpenID获取用户关系
func GetByOpenID(openID string) (item *UserRecord, err error) {
	err = global.DEFAULT_MYSQL.Where("open_id = ? ", openID).First(&item).Error
	return
}

// GetUserThirdRecordByUserId 获取该用户第一个的 三方信息（微信头像信息）
func GetUserThirdRecordByUserId(userId int) (item *UserRecord, err error) {
	err = global.DEFAULT_MYSQL.Where("user_id = ? ", userId).Order("user_record_id asc").First(&item).Error
	return
}
