// 系统预设的群组 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 }
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 }
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 }
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 }