本文整理匯總了Golang中github.com/ginuerzh/sports/models.Account類的典型用法代碼示例。如果您正苦於以下問題:Golang Account類的具體用法?Golang Account怎麽用?Golang Account使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Account類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: newAddrHandler
func newAddrHandler(r *http.Request, w http.ResponseWriter,
redis *models.RedisLogger, user *models.Account) {
wal, err := getWallet(user.Wallet.Id, user.Wallet.Key)
if err != nil {
writeResponse(r.RequestURI, w, nil, errors.NewError(errors.DbError, err.Error()))
return
}
k, err := wal.GenKey("")
if err != nil {
writeResponse(r.RequestURI, w, nil, errors.NewError(errors.DbError, err.Error()))
return
}
wal.AddKey(k)
if _, err = saveWallet(user.Wallet.Id, wal); err != nil {
writeResponse(r.RequestURI, w, nil, errors.NewError(errors.DbError, err.Error()))
return
}
user.Wallet.Addrs = append(user.Wallet.Addrs, k.PubKey)
if err = user.AddWalletAddr(k.PubKey); err != nil {
writeResponse(r.RequestURI, w, nil, err)
return
}
writeResponse(r.RequestURI, w, k, nil)
}
示例2: sendDevHandler
func sendDevHandler(request *http.Request, resp http.ResponseWriter,
redis *models.RedisLogger, user *models.Account, p Parameter) {
form := p.(sendDevForm)
err := user.AddDevice(form.Token)
writeResponse(request.RequestURI, resp, nil, err)
}
示例3: setPushHandler
func setPushHandler(request *http.Request, resp http.ResponseWriter,
redis *models.RedisLogger, user *models.Account, p Parameter) {
form := p.(setPushForm)
err := user.SetPush(form.Enabled)
writeResponse(request.RequestURI, resp, nil, err)
}
示例4: setEquipHandler
func setEquipHandler(request *http.Request, resp http.ResponseWriter,
user *models.Account, p Parameter) {
form := p.(setEquipForm)
err := user.SetEquip(form.Equips)
writeResponse(request.RequestURI, resp, map[string]interface{}{"ExpEffect": Awards{}}, err)
}
示例5: logoutHandler
func logoutHandler(request *http.Request, resp http.ResponseWriter,
redis *models.RedisLogger, user *models.Account, p Parameter) {
redis.DelOnlineUser(p.TokenId())
if len(user.Devs) > 0 {
user.RmDevice(user.Devs[0])
}
writeResponse(request.RequestURI, resp, nil, nil)
}
示例6: userAuthRequestHandler
func userAuthRequestHandler(r *http.Request, w http.ResponseWriter,
redis *models.RedisLogger, user *models.Account, p Parameter) {
form := p.(authRequestForm)
err := user.SetAuthInfo(form.Type, form.Images, form.Desc)
redis.AddAuthCoach(user.Id)
writeResponse(r.RequestURI, w, nil, err)
}
示例7: loadUserHandler
func loadUserHandler(c martini.Context, user *models.Account, redis *models.RedisLogger, r *http.Request, w http.ResponseWriter) {
if find, err := user.FindByUserid(user.Id); !find {
if err == nil {
err = errors.NewError(errors.NotExistsError)
}
writeResponse(r.RequestURI, w, nil, err)
return
}
}
示例8: setPasswordHandler
func setPasswordHandler(r *http.Request, w http.ResponseWriter,
user *models.Account, p Parameter) {
form := p.(setPasswordForm)
if user.Password != Md5(form.Old) {
writeResponse(r.RequestURI, w, nil, errors.NewError(errors.PasswordError, "原密碼錯誤"))
return
}
err := user.SetPassword(Md5(form.New))
writeResponse(r.RequestURI, w, nil, err)
}
示例9: setPhotosHandler
func setPhotosHandler(request *http.Request, resp http.ResponseWriter, redis *models.RedisLogger,
user *models.Account, p Parameter) {
form := p.(setPhotosForm)
awards := Awards{}
if !user.PhotoSet {
awards.Wealth = 10 * int64(len(form.Pics)) * models.Satoshi
awards.Score = 10 * int64(len(form.Pics))
}
err := user.AddPhotos(form.Pics)
GiveAwards(user, awards, redis)
writeResponse(request.RequestURI, resp, map[string]interface{}{"ExpEffect": awards}, err)
}
示例10: taskReferralsHandler
func taskReferralsHandler(r *http.Request, w http.ResponseWriter,
redis *models.RedisLogger, user *models.Account) {
if user.Taskid > len(models.NewTasks) {
writeResponse(r.RequestURI, w, nil, errors.NewError(errors.AccessError))
return
}
task := models.NewTasks[user.Taskid]
excludes := redis.TaskSharers()
friends := redis.Friends(models.RelFriend, user.Id)
excludes = append(excludes, user.Id)
excludes = append(excludes, friends...)
users, _ := user.TaskReferrals(task.Type, excludes)
var referrals []*referral
for i, _ := range users {
ref := &referral{
Userid: users[i].Id,
Nickname: users[i].Nickname,
Profile: users[i].Profile,
Gender: users[i].Gender,
Images: users[i].Photos,
Birthday: users[i].Birth,
Lastlog: users[i].LastLogin.Unix(),
Location: users[i].Loc,
}
if users[i].Ratios.RunRecv > 0 {
ref.RunRatio = float32(users[i].Ratios.RunAccept) / float32(users[i].Ratios.RunRecv)
}
if users[i].Ratios.PostRecv > 0 {
ref.PostRatio = float32(users[i].Ratios.PostAccept) / float32(users[i].Ratios.PostRecv)
}
if users[i].Ratios.PKRecv > 0 {
ref.PkRatio = float32(users[i].Ratios.PKAccept) / float32(users[i].Ratios.PKRecv)
}
if task.Type == models.TaskRunning || task.Type == models.TaskGame {
rec, _ := users[i].LastRecord("run")
ref.LastId = rec.Id.Hex()
ref.LastTime = rec.PubTime.Unix()
} else if task.Type == models.TaskPost {
article := users[i].LatestArticle()
ref.LastId = article.Id.Hex()
ref.LastTime = article.PubTime.Unix()
}
referrals = append(referrals, ref)
}
respData := map[string]interface{}{"referrals": referrals}
writeResponse(r.RequestURI, w, respData, nil)
}
示例11: recommendHandler
func recommendHandler(r *http.Request, w http.ResponseWriter,
redis *models.RedisLogger, user *models.Account, p Parameter) {
form := p.(recommendForm)
excludes := redis.Friends(models.RelFollowing, user.Id)
excludes = append(excludes, redis.Friends(models.RelBlacklist, user.Id)...)
users, _ := user.Recommend(excludes)
var list []*leaderboardResp
for i, _ := range users {
if users[i].Id == user.Id {
continue
}
rel := redis.Relationship(user.Id, users[i].Id)
if rel == models.RelFollowing || rel == models.RelFriend {
continue
}
lb := &leaderboardResp{
Userid: users[i].Id,
Score: users[i].Props.Score,
Level: users[i].Level(),
Profile: users[i].Profile,
Nickname: users[i].Nickname,
Gender: users[i].Gender,
LastLog: users[i].LastLogin.Unix(),
Birth: users[i].Birth,
Location: users[i].Loc,
Addr: users[i].LocAddr,
Phone: users[i].Phone,
Actor: users[i].Actor,
}
lb.Distance, _ = redis.RecStats(users[i].Id)
lb.Status = users[i].LatestArticle().Title
list = append(list, lb)
}
respData := map[string]interface{}{
"members_list": list,
"page_frist_id": form.Paging.First,
"page_last_id": form.Paging.Last,
}
writeResponse(r.RequestURI, w, respData, nil)
}
示例12: loginAwardsHandler
func loginAwardsHandler(request *http.Request, resp http.ResponseWriter,
redis *models.RedisLogger, user *models.Account) {
a := user.LoginAwards
if (user.LoginDays-1)%7 == 0 || len(a) == 0 {
a = []int64{}
startDay := ((user.LoginDays - 1) / 7) * 7
level := user.Level()
score := user.Props.Score
for i := 0; i < 7; i++ {
awards := loginAwards(startDay+i+1, int(level))
a = append(a, awards.Wealth, awards.Score)
score = score + awards.Score
level = models.Score2Level(score)
}
user.SetLoginAwards(a)
}
index := (user.LoginDays - 1) % 7
awards := Awards{Wealth: a[index*2], Score: a[index*2+1]}
awards.Level = models.Score2Level(user.Props.Score+awards.Score) - user.Level()
GiveAwards(user, awards, redis)
loginAwards := []int64{}
for i := 0; i < 7; i++ {
loginAwards = append(loginAwards, a[i*2])
}
respData := map[string]interface{}{
"continuous_logined_days": user.LoginDays,
"login_reward_list": loginAwards,
}
writeResponse(request.RequestURI, resp, respData, nil)
}
示例13: searchHandler
func searchHandler(r *http.Request, w http.ResponseWriter,
user *models.Account, form searchForm) {
users := []models.Account{}
var err error
if form.Nearby > 0 {
form.Paging.Count = 50
users, err = user.SearchNear(&form.Paging, 50000)
} else {
users, err = models.SearchUsers(form.Nickname, &form.Paging)
}
var list []*leaderboardResp
for i, _ := range users {
if users[i].Id == user.Id {
continue
}
lb := &leaderboardResp{
Userid: users[i].Id,
Score: users[i].Props.Score,
Level: users[i].Level(),
Profile: users[i].Profile,
Nickname: users[i].Nickname,
Gender: users[i].Gender,
LastLog: users[i].LastLogin.Unix(),
Birth: users[i].Birth,
Location: users[i].Loc,
Phone: users[i].Phone,
Actor: users[i].Actor,
}
list = append(list, lb)
}
respData := map[string]interface{}{
"members_list": list,
"page_frist_id": form.Paging.First,
"page_last_id": form.Paging.Last,
}
writeResponse(r.RequestURI, w, respData, err)
}
示例14: articleListHandler
func articleListHandler(request *http.Request, resp http.ResponseWriter,
redis *models.RedisLogger, user *models.Account, p Parameter) {
var articles []models.Article
var err error
form := p.(articleListForm)
if len(form.Tag) > 0 {
_, articles, err = models.GetArticles(form.Tag, &form.Paging, true)
} else if form.Circle {
followings := redis.Friends(models.RelFollowing, user.Id)
followings = append(followings, user.Id) // self included
_, articles, err = models.GetFollowingsArticles(followings, &form.Paging)
} else {
excludes := redis.Friends(models.RelFollowing, user.Id)
excludes = append(excludes, redis.Friends(models.RelBlacklist, user.Id)...)
excludes = append(excludes, user.Id)
recommends, _ := user.Recommend(excludes)
ids := []string{}
for i, _ := range recommends {
ids = append(ids, recommends[i].Id)
}
_, articles, err = models.GetRecommendArticles(ids, &form.Paging)
}
jsonStructs := make([]*articleJsonStruct, len(articles))
for i, _ := range articles {
u := &models.Account{}
u.FindByUserid(articles[i].Author)
author := convertUser(u, redis)
jsonStructs[i] = convertArticle(user, &articles[i], author)
}
respData := make(map[string]interface{})
respData["page_frist_id"] = form.Paging.First
respData["page_last_id"] = form.Paging.Last
//respData["page_item_count"] = total
respData["articles_without_content"] = jsonStructs
writeResponse(request.RequestURI, resp, respData, err)
}
示例15: purchaseListHandler
func purchaseListHandler(r *http.Request, w http.ResponseWriter,
redis *models.RedisLogger, user *models.Account, p Parameter) {
form := p.(purchaseListForm)
_, txs, _ := user.Txs(&form.Paging)
list := []*purchaseStruct{}
for _, tx := range txs {
list = append(list, &purchaseStruct{
Coins: tx.Coins,
Value: tx.Value,
Time: tx.Time.Unix(),
})
}
respData := map[string]interface{}{
"payCoinList": list,
"page_frist_id": form.Paging.First,
"page_last_id": form.Paging.Last,
}
writeResponse(r.RequestURI, w, respData, nil)
}