Esempio n. 1
0
// 查看粉丝
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))

}
Esempio n. 2
0
// 查看关注的人
func user_Follows(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-follows"
		}
	}

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

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

	ctx.ViewData["Friends"] = models.User_ToVUsers(friends, ctx)
	ctx.ViewData["HasMoreFriends"] = len(friends) >= pagesize
	return ctx.View(models.User_ToVUser(user, ctx))

}
Esempio n. 3
0
func admin_users(ctx *goku.HttpContext) goku.ActionResulter {
	page, pagesize := utils.PagerParams(ctx.Request)
	users, total, err := models.User_GetList(page, pagesize, "")
	if err != nil {
		ctx.ViewData["errorMsg"] = err.Error()
		return ctx.Render("error", nil)
	}
	ctx.ViewData["UserList"] = users
	ctx.ViewData["UserCount"] = total
	ctx.ViewData["Page"] = page
	ctx.ViewData["Pagesize"] = pagesize
	ctx.ViewData["TabName"] = "users"
	return ctx.View(nil)
}
Esempio n. 4
0
func admin_links(ctx *goku.HttpContext) goku.ActionResulter {
	page, pagesize := utils.PagerParams(ctx.Request)
	links, total, err := models.Link_GetByPage(page, pagesize, "")
	if err != nil {
		ctx.ViewData["errorMsg"] = err.Error()
		return ctx.Render("error", nil)
	}
	ctx.ViewData["LinkList"] = links
	ctx.ViewData["TotalLinks"] = total
	ctx.ViewData["Page"] = page
	ctx.ViewData["Pagesize"] = pagesize
	ctx.ViewData["TabName"] = "links"
	return ctx.View(nil)
}
Esempio n. 5
0
func admin_topics(ctx *goku.HttpContext) goku.ActionResulter {
	page, pagesize := utils.PagerParams(ctx.Request)
	topics, total, err := models.Topic_GetByPage(page, pagesize, "")
	if err != nil {
		ctx.ViewData["errorMsg"] = err.Error()
		return ctx.Render("error", nil)
	}
	ctx.ViewData["TopicList"] = topics
	ctx.ViewData["TopicCount"] = total
	ctx.ViewData["Page"] = page
	ctx.ViewData["Pagesize"] = pagesize
	ctx.ViewData["TabName"] = "topics"
	return ctx.View(nil)
}
Esempio n. 6
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)
}
Esempio n. 7
0
		topic, _ := models.Topic_GetByName(topicName)

		if topic == nil {
			ctx.ViewData["errorMsg"] = "话题不存在"
			return ctx.Render("error", nil)
		}

		sort := ctx.Get("o") //排序方式
		t := ctx.Get("t")    //时间范围

		ctx.ViewData["Order"] = golink.ORDER_TYPE_HOT
		if _, ok := golink.ORDER_TYPE_MAP[sort]; ok {
			ctx.ViewData["Order"] = sort
		}

		page, pagesize := utils.PagerParams(ctx.Request)
		links, _ := models.Link_ForTopic(topic.Id, page, pagesize, sort, t)
		followers, _ := models.Topic_GetFollowers(topic.Id, 1, 24)

		ctx.ViewData["Links"] = models.Link_ToVLink(links, ctx)
		ctx.ViewData["HasMoreLink"] = len(links) >= golink.PAGE_SIZE
		ctx.ViewData["Followers"] = followers
		return ctx.View(models.Topic_ToVTopic(topic, ctx))

	}). //Filters(filters.NewRequireLoginFilter()). // 暂时不需要登陆吧

	/**
	 * 关注话题
	 */
	Post("follow", func(ctx *goku.HttpContext) goku.ActionResulter {