Exemple #1
0
// 查看粉丝
func user_Fans(ctx *goku.HttpContext) goku.ActionResulter {

	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"
		}
	}

	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
	return ctx.View(models.User_ToVUser(user, ctx))

}
Exemple #2
0
// 新用户引导
func home_guideForNew(ctx *goku.HttpContext) goku.ActionResulter {
	pagesize := 30
	users, totalUser, err := models.User_GetList(1, pagesize, "link_count desc")
	if err != nil {
		ctx.ViewData["errorMsg"] = err.Error()
		return ctx.Render("error", nil)
	}
	topics, totalTopic, err := models.Topic_GetByPage(1, pagesize, "link_count desc")
	if err != nil {
		ctx.ViewData["errorMsg"] = err.Error()
		return ctx.Render("error", nil)
	}
	ctx.ViewData["Users"] = models.User_ToVUsers(users, ctx)
	ctx.ViewData["TotalUser"] = totalUser
	ctx.ViewData["Topics"] = models.Topic_ToVTopics(topics, ctx)
	ctx.ViewData["TotalTopics"] = totalTopic
	return ctx.Render("guide", nil)
}