예제 #1
0
파일: user.go 프로젝트: cloudcache/ohlala
// 查看粉丝
func user_Fans(ctx *goku.HttpContext) goku.ActionResulter {
	var isSelf bool
	userId, _ := strconv.ParseInt(ctx.RouteData.Params["id"], 10, 64)
	var user *models.User
	if userId > 0 {
		user = models.User_GetById(userId)
	} else {
		if u, ok := ctx.Data["user"]; ok {
			user = u.(*models.User)
			ctx.ViewData["UserMenu"] = "um-fans"
			isSelf = true
		}
	}

	if user == nil {
		ctx.ViewData["errorMsg"] = "用户不存在"
		return ctx.Render("error", nil)
	}

	page, pagesize := utils.PagerParams(ctx.Request)
	followers, _ := models.UserFollow_Followers(user.Id, page, pagesize)

	ctx.ViewData["Followers"] = models.User_ToVUsers(followers, ctx)
	ctx.ViewData["HasMoreFollowers"] = len(followers) >= pagesize

	if isSelf {
		models.Remind_Reset(user.Id, models.REMIND_FANS)
	}

	return ctx.View(models.User_ToVUser(user, ctx))

}
예제 #2
0
/**
 * 收到的评论
 */
func comment_Inbox(ctx *goku.HttpContext) goku.ActionResulter {
	user := ctx.Data["user"].(*models.User)
	page, pagesize := utils.PagerParams(ctx.Request)
	comments, total, err := models.CommentForUser_GetByPage(user.Id, page, pagesize, "")
	if err != nil {
		ctx.ViewData["errorMsg"] = err.Error()
		return ctx.Render("error", nil)
	}
	ctx.ViewData["CommentList"] = comments
	ctx.ViewData["CommentCount"] = total
	ctx.ViewData["Page"] = page
	ctx.ViewData["Pagesize"] = pagesize
	ctx.ViewData["UserMenu"] = "um-cm-inbox"
	err = models.Remind_Reset(user.Id, models.REMIND_COMMENT)
	if err != nil {
		goku.Logger().Errorln("Reset用户提醒信息数出错:", err.Error())
	}
	return ctx.View(nil)
}