本文整理匯總了Golang中github.com/ginuerzh/sports/models.Account.LatestArticle方法的典型用法代碼示例。如果您正苦於以下問題:Golang Account.LatestArticle方法的具體用法?Golang Account.LatestArticle怎麽用?Golang Account.LatestArticle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ginuerzh/sports/models.Account
的用法示例。
在下文中一共展示了Account.LatestArticle方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: taskShareHandler
func taskShareHandler(r *http.Request, w http.ResponseWriter,
redis *models.RedisLogger, user *models.Account, p Parameter) {
form := p.(taskShareForm)
if form.TaskId > len(models.NewTasks) {
writeResponse(r.RequestURI, w, nil, errors.NewError(errors.AccessError))
return
}
//task := models.NewTasks[form.TaskId]
// ws push
event := &models.Event{
Type: models.EventSystem,
Time: time.Now().Unix(),
Data: models.EventData{
//Type: models.EventRunShare,
Id: user.Id,
From: user.Id,
To: form.Userid,
},
}
switch form.Type {
case models.TaskRunning:
record, _ := user.LastRecord("run")
latlng := strconv.FormatFloat(form.Lat, 'f', 7, 64) + "," +
strconv.FormatFloat(form.Lng, 'f', 7, 64)
event.Data.Type = models.EventRunShare
event.Data.Body = []models.MsgBody{
{Type: "record_id", Content: record.Id.Hex()},
{Type: "latlng", Content: latlng},
{Type: "locaddr", Content: form.Addr},
{Type: "time", Content: strconv.FormatInt(form.Time, 10)},
{Type: "addr_image", Content: form.Image},
}
case models.TaskPost:
event.Data.Type = models.EventPostShare
article := user.LatestArticle()
event.Data.Body = []models.MsgBody{
{Type: "article_id", Content: article.Id.Hex()},
}
case models.TaskGame:
record, _ := user.LastRecord("run")
event.Data.Type = models.EventPKShare
event.Data.Body = []models.MsgBody{
{Type: "record_id", Content: record.Id.Hex()},
}
default:
writeResponse(r.RequestURI, w, nil, errors.NewError(errors.AccessError))
return
}
event.Save()
redis.PubMsg(event.Type, event.Data.To, event.Bytes())
u := &models.Account{Id: form.Userid}
u.UpdateRatio(form.Type, false)
redis.SetTaskShare(form.Userid, true)
if _, err := consumeCoin(user.Wallet.Addr, form.Coin); err == nil {
redis.ConsumeCoins(user.Id, form.Coin)
}
writeResponse(r.RequestURI, w, nil, nil)
}