Esempio n. 1
0
func RedisQueryFriendList(uid uint64, typ int) ([]uint64, error) {
	userKey := ""
	if typ == 1 {
		userKey = fmt.Sprintf("%s%d", SET_WHITELIST, uid)
	} else {
		userKey = fmt.Sprintf("%s%d", SET_BLACKLIST, uid)
	}

	strUidList, err := redis.SMembers(userKey).Result()
	if err != nil {
		return []uint64{}, errors.As(err, uid, typ)
	}

	if strUidList == nil || len(strUidList) < 1 {
		return []uint64{}, nil
	}

	uidList := make([]uint64, len(strUidList))

	for i, val := range strUidList {
		uidList[i], _ = strconv.ParseUint(val, 10, 64)
	}

	return uidList, nil
}
Esempio n. 2
0
// 系统预设的群组
func RedisQuerySysTeamList() ([]int64, error) {
	strTeamList, err := redis.SMembers(SET_SYS_TEAM).Result()
	if err != nil {
		return nil, errors.As(err)
	}

	teamList := make([]int64, len(strTeamList))

	for i, val := range strTeamList {
		teamList[i], _ = strconv.ParseInt(val, 10, 64)
	}

	return teamList, nil
}
Esempio n. 3
0
func RedisQueryTeamMemberList(tid uint64) ([]uint64, error) {
	userKey := fmt.Sprintf("%s%d", SET_TEAM_MEMBER, tid)
	strUidList, err := redis.SMembers(userKey).Result()
	if err != nil {
		return nil, errors.As(err, tid)
	}

	uidList := make([]uint64, len(strUidList))

	for i, val := range strUidList {
		uidList[i], _ = strconv.ParseUint(val, 10, 64)
	}

	return uidList, nil
}
Esempio n. 4
0
func RedisQueryTeamList(uid uint64) ([]int64, error) {
	userKey := fmt.Sprintf("%s%d", SET_USERS_TEAM, uid)
	strTeamList, err := redis.SMembers(userKey).Result()

	if err != nil {
		return nil, errors.As(err, uid)
	}

	teamList := make([]int64, len(strTeamList))

	for i, val := range strTeamList {
		teamList[i], _ = strconv.ParseInt(val, 10, 64)
	}

	return teamList, nil
}
Esempio n. 5
0
func RedisDeleteTeam(tid uint64) error {
	userKey := fmt.Sprintf("%s%d", KEY_TEAM_INFO, tid)
	redis.RedisDel(userKey)

	userKey = fmt.Sprintf("%s%d", SET_TEAM_MEMBER, tid)

	uidList, err := redis.SMembers(userKey).Result()

	if err != nil {
		return errors.As(err, tid)
	} else {
		for _, val := range uidList {
			userKey2 := fmt.Sprintf("%s%s", SET_USERS_TEAM, val)
			val := fmt.Sprintf("%d", tid)
			redis.SRem(userKey2, val)
		}
	}

	redis.RedisDel(userKey)

	return nil
}