group_power.go 758 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 group_power_cv

import (
	"git.hilo.cn/hilo-common/resource/mysql"
	"gorm.io/gorm"
	"hilo-group/domain/model/groupPower_m"
)

func BatchGetGroupPower(db *gorm.DB, userIds []uint64) (map[uint64]uint64, map[uint64]string, error) {
	if len(userIds) <= 0 {
		return nil, nil, nil
	}
	groupPowers, err := groupPower_m.GetGroupPowerMap(db, userIds)
	if err != nil {
		return nil, nil, err
	}

	gpIds := make([]uint64, 0)
	for _, i := range groupPowers {
		gpIds = append(gpIds, i)
	}
	powerNames, err := groupPower_m.GetGroupPowerNames(db, gpIds)
	if err != nil {
		return nil, nil, err
	}
	groupPowerNames := make(map[mysql.ID]string, 0)
	for i, g := range groupPowers {
		groupPowerNames[i] = powerNames[g]
	}
	return groupPowers, groupPowerNames, nil
}