matchActive.go 735 Bytes
Newer Older
hujiebin's avatar
hujiebin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
package user_m

import (
	"git.hilo.cn/hilo-common/domain"
	"git.hilo.cn/hilo-common/resource/mysql"
)

/**
 * 用户活跃分数
 **/
type MatchActityUserScore struct {
	mysql.Entity
	*domain.Model `gorm:"-"`
	UserId        mysql.ID
	Score         mysql.Num
	Grade         mysql.Num
}

// 获取活跃等级
func MGetActiveGrade(model *domain.Model, userIds []mysql.ID) (map[mysql.ID]mysql.Num, error) {
	res := make(map[mysql.ID]mysql.Num)
	var rows []MatchActityUserScore
	if err := mysql.Db.Model(&MatchActityUserScore{}).Where("user_id in ?", userIds).Find(&rows).Error; err != nil {
		model.Log.Errorf("MGetActiveGrade fail:%v", err)
		return res, err
	}
	for _, r := range rows {
		res[r.UserId] = r.Grade
	}
	return res, nil
}