本文整理匯總了Golang中github.com/ginuerzh/sports/models.RedisLogger.SetRelationship方法的典型用法代碼示例。如果您正苦於以下問題:Golang RedisLogger.SetRelationship方法的具體用法?Golang RedisLogger.SetRelationship怎麽用?Golang RedisLogger.SetRelationship使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ginuerzh/sports/models.RedisLogger
的用法示例。
在下文中一共展示了RedisLogger.SetRelationship方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: recvHeartHandler
func recvHeartHandler(r *http.Request, w http.ResponseWriter,
redis *models.RedisLogger, user *models.Account, p Parameter) {
form := p.(recvHeartForm)
// ws push
event := &models.Event{
Type: models.EventSystem,
Time: time.Now().Unix(),
Data: models.EventData{
Type: models.EventRecvHeart,
Id: user.Id,
From: user.Id,
To: form.Sender,
Body: []models.MsgBody{
{Type: "userid", Content: user.Id},
},
},
}
awards := Awards{}
if form.Accept {
redis.SetRelationship(user.Id, []string{form.Sender}, models.RelFriend, true)
event.Save()
redis.PubMsg(models.EventSystem, form.Sender, event.Bytes())
awards.Wealth = 1 * models.Satoshi
GiveAwards(user, awards, redis)
}
redis.SetHeartRecv(user.Id, false)
writeResponse(r.RequestURI, w, map[string]interface{}{"ExpEffect": awards}, nil)
}
示例2: blacklistHandler
func blacklistHandler(request *http.Request, resp http.ResponseWriter,
redis *models.RedisLogger, user *models.Account, p Parameter) {
form := p.(relationshipForm)
redis.SetRelationship(user.Id, form.Userids, models.RelBlacklist, form.Blacklist)
writeResponse(request.RequestURI, resp, map[string]interface{}{"ExpEffect": Awards{}}, nil)
}
示例3: followHandler
func followHandler(request *http.Request, resp http.ResponseWriter,
client *ApnClient, redis *models.RedisLogger, user *models.Account, p Parameter) {
form := p.(relationshipForm)
for _, peer := range form.Userids {
if redis.Relationship(peer, user.Id) == models.RelBlacklist {
writeResponse(request.RequestURI, resp, nil, errors.NewError(errors.DbError, "對方已屏蔽了你!"))
return
}
}
redis.SetRelationship(user.Id, form.Userids, models.RelFollowing, form.Follow)
writeResponse(request.RequestURI, resp, map[string]interface{}{"ExpEffect": Awards{}}, nil)
for _, userid := range form.Userids {
u := &models.Account{}
u.FindByUserid(userid)
event := &models.Event{
Type: models.EventMsg,
Time: time.Now().Unix(),
Data: models.EventData{
Type: models.EventSub,
Id: user.Id + "-" + u.Id,
From: user.Id,
To: u.Id,
Body: []models.MsgBody{
{Type: "nikename", Content: user.Nickname},
{Type: "image", Content: user.Profile},
},
},
}
if form.Follow {
/*
if err := event.Save(); err == nil {
redis.IncrEventCount(u.Id, event.Data.Type, 1)
}
*/
event.Upsert()
event.Data.Body = append(event.Data.Body,
models.MsgBody{Type: "new_count", Content: "1"})
redis.PubMsg(models.EventMsg, u.Id, event.Bytes())
// apple push
if u.Push {
go sendApn(client, user.Nickname+"關注了你!", u.EventCount("", ""), u.Devs...)
}
} else {
//count := u.DelEvent(models.EventSub, user.Id, user.Id, u.Id)
//redis.IncrEventCount(u.Id, models.EventSub, -count)
event.Delete()
}
}
}
示例4: taskSharedHandler
func taskSharedHandler(r *http.Request, w http.ResponseWriter,
redis *models.RedisLogger, user *models.Account, p Parameter) {
form := p.(taskSharedForm)
u := &models.Account{}
u.FindByUserid(form.Sender)
// ws push
event := &models.Event{
Type: models.EventSystem,
Time: time.Now().Unix(),
Data: models.EventData{
Id: user.Id,
From: user.Id,
To: form.Sender,
},
}
var article *models.Article
switch form.Type {
case models.TaskRunning:
event.Data.Type = models.EventRunShared
article = &models.Article{
Author: user.Id,
PubTime: time.Now(),
Contents: []models.Segment{
{ContentType: "TEXT", ContentText: "我和" + u.Nickname + "約好一起跑步,有想一起參加的嗎?" +
"\n跑步地點: " + form.Addr +
"\n跑步時間: " + time.Unix(form.Time, 0).Format("2006-01-02 3:04 PM")},
{ContentType: "IMAGE", ContentText: form.Image},
},
}
case models.TaskPost:
article := &models.Article{}
if find, _ := article.FindById(form.ArticleId); find {
article.SetThumb(user.Id, true)
}
event.Data.Type = models.EventPostShared
case models.TaskGame:
event.Data.Type = models.EventPKShared
result := u.Nickname + " 主動PK " + user.Nickname + "大獲全勝。"
if u.Props.Score < user.Props.Score {
result = u.Nickname + " 主動PK " + user.Nickname + "大敗虧輸。"
}
article = &models.Article{
Author: user.Id,
Type: "pk",
PubTime: time.Now(),
Contents: []models.Segment{
{ContentType: "TEXT", ContentText: result},
{ContentType: "IMAGE", ContentText: form.Image},
},
}
default:
writeResponse(r.RequestURI, w, nil, errors.NewError(errors.AccessError))
return
}
awards := Awards{}
if form.Accept {
redis.SetRelationship(user.Id, []string{form.Sender}, models.RelFriend, true)
event.Save()
redis.PubMsg(models.EventSystem, form.Sender, event.Bytes())
user.UpdateRatio(form.Type, true)
if article != nil {
article.Save()
}
awards.Wealth = 1 * models.Satoshi
GiveAwards(user, awards, redis)
}
redis.SetTaskShare(user.Id, false)
writeResponse(r.RequestURI, w, map[string]interface{}{"ExpEffect": awards}, nil)
}