vote := &models.Vote{0, 0, false, "请求错误"} id, err1 := strconv.ParseInt(ctx.RouteData.Params["id"], 10, 64) votetype, err2 := strconv.Atoi(ctx.RouteData.Params["cid"]) var score int = 1 //vote up if votetype == 2 { //vote down score = -1 } var userId int64 = (ctx.Data["user"].(*models.User)).Id if err1 == nil && err2 == nil { vote = models.VoteLink(id, userId, score, golink.SITERUNTIME) } return ctx.Json(vote) }).Filters(filters.NewRequireLoginFilter()). /** * 投票评论 */ Post("comment", func(ctx *goku.HttpContext) goku.ActionResulter { vote := &models.Vote{0, 0, false, "请求错误"} id, err1 := strconv.ParseInt(ctx.RouteData.Params["id"], 10, 64) //topId, err2 := strconv.Atoi(ctx.RouteData.Params["topid"]) votetype, err3 := strconv.Atoi(ctx.RouteData.Params["cid"]) var score int = 1 //vote up if votetype == 2 { score = -1 //vote down }
* 查看一个链接的评论 */ Get("show", link_show). /** * 提交链接的表单页面 */ Get("submit", func(ctx *goku.HttpContext) goku.ActionResulter { ctx.ViewData["Values"] = map[string]string{ "title": ctx.Get("t"), "context": ctx.Get("u"), } return ctx.View(nil) }).Filters(filters.NewRequireLoginFilter()). /** * 提交一个链接并保存到数据库 */ Post("submit", func(ctx *goku.HttpContext) goku.ActionResulter { f := forms.CreateLinkSubmitForm() f.FillByRequest(ctx.Request) success, linkId, errorMsgs := models.Link_SaveForm(f, (ctx.Data["user"].(*models.User)).Id) if success { return ctx.Redirect(fmt.Sprintf("/link/%d", linkId)) } else { ctx.ViewData["Errors"] = errorMsgs
) var _ = goku.Controller("home"). // index Get("index", home_index). // 关于 Get("about", home_about). // 免责声明 Get("disclaimer", home_disclaimer). // 合作伙伴 Get("partner", home_partner). // 联系信息 Get("contact", home_contact). // load more Get("loadmorelink", home_loadMoreLink). Filters(filters.NewRequireLoginFilter(), filters.NewAjaxFilter()) // func home_index(ctx *goku.HttpContext) goku.ActionResulter { u, ok := ctx.Data["user"] if !ok || u == nil { return ctx.Redirect("/discover") } user := u.(*models.User) ot := ctx.Get("o") if ot == "" { ot = "hot" } ctx.ViewData["Order"] = ot links, _ := models.Link_ForUser(user.Id, ot, 1, golink.PAGE_SIZE) //models.Link_GetByPage(1, 20)
) var _ = goku.Controller("link"). /** * 查看某评论 */ Get("permacoment", link_permacoment). /** * 查看一个链接的评论 */ Get("show", link_show). /** * 删除link */ Post("ajax-del", link_ajaxDel).Filters(filters.NewRequireLoginFilter(), filters.NewAjaxFilter()). /** * 提交一个链接并保存到数据库 */ Post("submit", link_submit).Filters(filters.NewRequireLoginFilter()). /** * 提交评论并保存到数据库 */ Post("ajax-comment", link_ajax_comment).Filters(filters.NewRequireLoginFilter(), filters.NewAjaxFilter()). /** * 提交评论并保存到数据库 */ Post("inc-click", link_incClick).Filters(filters.NewAjaxFilter()).
type CommentHtml struct { Html string } /** * 评论 */ var _ = goku.Controller("comment"). /** * 加载更多评论 */ Post("loadmore", comment_LoadMore). /** * 收到的评论 */ Get("inbox", comment_Inbox).Filters(filters.NewRequireLoginFilter()) /** * 加载更多评论 */ func comment_LoadMore(ctx *goku.HttpContext) goku.ActionResulter { htmlObject := CommentHtml{""} exceptIds := ctx.Get("except_ids") fmt.Println("exceptIds:", exceptIds) parentPath := ctx.Get("parent_path") sortType := ctx.Get("sort_type") topId, err1 := strconv.ParseInt(ctx.Get("top_parent_id"), 10, 64) linkId, err2 := strconv.ParseInt(ctx.Get("link_id"), 10, 64) if err1 == nil && err2 == nil { htmlObject.Html = models.GetSortComments(exceptIds, parentPath, topId, linkId, sortType, "", true)