本文整理匯總了Golang中github.com/ginuerzh/sports/models.RedisLogger.UpdateRecLB方法的典型用法代碼示例。如果您正苦於以下問題:Golang RedisLogger.UpdateRecLB方法的具體用法?Golang RedisLogger.UpdateRecLB怎麽用?Golang RedisLogger.UpdateRecLB使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ginuerzh/sports/models.RedisLogger
的用法示例。
在下文中一共展示了RedisLogger.UpdateRecLB方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: taskAuthFunc
func taskAuthFunc(userid string, auth *taskAuth, redis *models.RedisLogger) error {
user := &models.Account{}
user.FindByUserid(auth.Userid)
record := &models.Record{Uid: user.Id, Task: auth.Id}
record.FindByTask(auth.Id)
awards := controllers.Awards{}
parent := &models.Article{}
parent.FindByRecord(record.Id.Hex())
if len(parent.Id) > 0 && len(auth.Reason) > 0 {
review := &models.Article{
Parent: parent.Id.Hex(),
Author: userid,
Title: auth.Reason,
Type: models.ArticleCoach,
Contents: []models.Segment{{ContentType: "TEXT", ContentText: auth.Reason}},
PubTime: time.Now(),
}
review.Save()
}
if auth.Pass {
level := user.Level()
awards = controllers.Awards{
Physical: 3 + level,
Wealth: 3 * models.Satoshi,
Score: 3 + level,
}
awards.Level = models.Score2Level(user.Props.Score+awards.Score) - level
controllers.GiveAwards(user, awards, redis)
if record.Sport != nil {
redis.UpdateRecLB(user.Id, record.Sport.Distance, int(record.Sport.Duration))
}
record.SetStatus(models.StatusFinish, auth.Reason, awards.Wealth)
if auth.Id < 1000 {
user.UpdateTask(int(auth.Id), models.StatusFinish)
}
} else {
record.SetStatus(models.StatusUnFinish, auth.Reason, 0)
if auth.Id < 1000 {
user.UpdateTask(int(auth.Id), models.StatusUnFinish)
}
parent.SetPrivilege(models.PrivPrivate)
}
// ws push
event := &models.Event{
Type: models.EventNotice,
Time: time.Now().Unix(),
Data: models.EventData{
Type: models.EventTaskDone,
To: user.Id,
Body: []models.MsgBody{
{Type: "physique_value", Content: strconv.FormatInt(awards.Physical, 10)},
{Type: "coin_value", Content: strconv.FormatInt(awards.Wealth, 10)},
},
},
}
if auth.Id < 1000 {
event.Data.Body = append(event.Data.Body, models.MsgBody{Type: "task_id", Content: strconv.Itoa(int(auth.Id))})
}
if !auth.Pass {
event.Data.Type = models.EventTaskFailure
}
redis.PubMsg(event.Type, event.Data.To, event.Bytes())
event.Save()
event = &models.Event{
Type: models.EventArticle,
Time: time.Now().Unix(),
Data: models.EventData{
Type: models.EventCoachPass,
Id: parent.Id.Hex(),
From: userid,
To: parent.Author,
Body: []models.MsgBody{
{Type: "total_count", Content: strconv.Itoa(parent.CoachReviewCount + 1)},
{Type: "image", Content: ""},
},
},
}
if !auth.Pass {
event.Data.Type = models.EventCoachNPass
}
event.Save()
redis.PubMsg(event.Type, event.Data.To, event.Bytes())
return nil
}