當前位置: 首頁>>代碼示例>>Golang>>正文


Golang RedisLogger.FriendCount方法代碼示例

本文整理匯總了Golang中github.com/ginuerzh/sports/models.RedisLogger.FriendCount方法的典型用法代碼示例。如果您正苦於以下問題:Golang RedisLogger.FriendCount方法的具體用法?Golang RedisLogger.FriendCount怎麽用?Golang RedisLogger.FriendCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/ginuerzh/sports/models.RedisLogger的用法示例。


在下文中一共展示了RedisLogger.FriendCount方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: friendCountHandler

func friendCountHandler(request *http.Request, resp http.ResponseWriter,
	redis *models.RedisLogger, user *models.Account) {
	follows, followers, friends, blacklist := redis.FriendCount(user.Id)
	respData := map[string]int{
		"friend_count":    friends,
		"attention_count": follows,
		"fans_count":      followers,
		"defriend_count":  blacklist,
	}
	writeResponse(request.RequestURI, resp, respData, nil)
}
開發者ID:shevilangle,項目名稱:sports,代碼行數:11,代碼來源:account.go

示例2: adminLoginHandler

func adminLoginHandler(w http.ResponseWriter, redis *models.RedisLogger, form jsgenLoginForm) {
	user := &models.Account{}

	log.Println(form.Username, form.Password)
	h := md5.New()
	io.WriteString(h, form.Password)
	pwd := fmt.Sprintf("%x", h.Sum(nil))

	find := false
	var err error
	if find, err = user.FindByUserPass(strings.ToLower(form.Username), pwd); !find {
		if err == nil {
			err = AuthError
		} else {
			err = DbError
		}
	}

	if err != nil {
		writeResponse(w, false, nil, nil, err)
		return
	}

	redis.LogLogin(user.Id)

	info := &User{
		Id:          user.Id,
		Name:        user.Nickname,
		Nickname:    user.Nickname,
		Email:       "",
		Locked:      user.TimeLimit != 0,
		Social:      social{},
		Sex:         user.Gender,
		Role:        1,
		Avatar:      user.Profile,
		Desc:        user.About,
		Date:        user.RegTime.Unix() * 1000,
		Score:       user.Score,
		ReadTime:    0,
		LastLogin:   user.LastLogin.Unix() * 1000,
		FollowList:  redis.Friends(models.RelFollowing, user.Id),
		TagsList:    []string{},
		Articles:    user.ArticleCount(),
		Collections: 0,
		MarkList:    []int{},
		Unread:      []string{},
		ReceiveList: []string{},
		SendList:    []string{},
	}
	info.Follow, info.Fans, _, _ = redis.FriendCount(user.Id)

	writeResponse(w, true, info, nil, nil)
}
開發者ID:shevilangle,項目名稱:sports,代碼行數:53,代碼來源:account.go

示例3: convertUser

func convertUser(user *models.Account, redis *models.RedisLogger) *userJsonStruct {
	info := &userJsonStruct{
		Userid:   user.Id,
		Nickname: user.Nickname,
		Email:    user.Email,
		Phone:    user.Phone,
		Type:     user.Role,
		About:    user.About,
		Profile:  user.Profile,
		RegTime:  user.RegTime.Unix(),
		Height:   user.Height,
		Weight:   user.Weight,
		Birth:    user.Birth,
		Actor:    user.Actor,
		Location: user.Loc,
		Addr:     user.LocAddr,

		Sign:        user.Sign,
		Emotion:     user.Emotion,
		Profession:  user.Profession,
		Hometown:    user.Hometown,
		OftenAppear: user.Oftenappear,
		Hobby:       user.Hobby,

		//Rank:   userRank(user.Level),
		Online: redis.IsOnline(user.Id),
		Gender: user.Gender,
		//Follows:   len(redis.Follows(user.Id)),
		//Followers: len(redis.Followers(user.Id)),
		Posts: user.ArticleCount(),

		//Props: redis.UserProps(user.Id),
		Props: models.Props{
			Physical: user.Props.Physical,
			Literal:  user.Props.Literal,
			Mental:   user.Props.Mental,
			Wealth:   redis.GetCoins(user.Id),
			Score:    user.Props.Score,
			Level:    user.Level(),
		},

		Photos:     user.Photos,
		CoverImage: user.CoverImage,

		Wallet:  user.Wallet.Addr,
		LastLog: user.LastLogin.Unix(),
		Setinfo: user.Setinfo,
		Ban:     user.TimeLimit,
		Auth:    user.Auth,
	}

	balance, _ := getBalance(user.Wallet.Addrs)
	var wealth int64
	if balance != nil {
		for _, b := range balance.Addrs {
			wealth += (b.Confirmed + b.Unconfirmed)
		}
	}
	info.Props.Wealth = wealth

	info.Follows, info.Followers, _, _ = redis.FriendCount(user.Id)

	/*
		if user.Privilege == 5 {
			info.Actor = "coach"
		} else if user.Privilege == 10 {
			info.Actor = "admin"
		}

			if user.Addr != nil {
				info.Addr = user.Addr.String()
			}
	*/

	if user.Equips != nil {
		info.Equips = *user.Equips
	}

	if info.Auth != nil {
		if info.Auth.IdCard == nil {
			info.Auth.IdCard = info.Auth.IdCardTmp
		}
		if info.Auth.Cert == nil {
			info.Auth.Cert = info.Auth.CertTmp
		}
		if info.Auth.Record == nil {
			info.Auth.Record = info.Auth.RecordTmp
		}
	}

	return info
}
開發者ID:shevilangle,項目名稱:sports,代碼行數:92,代碼來源:account.go


注:本文中的github.com/ginuerzh/sports/models.RedisLogger.FriendCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。