forked from philsong/ohlala
/
comment.go
73 lines (66 loc) · 1.84 KB
/
comment.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package controllers
import (
"fmt"
"github.com/QLeelulu/goku"
"github.com/philsong/ohlala/golink/utils"
//"github.com/QLeelulu/goku/form"
"github.com/philsong/ohlala/golink/filters"
"github.com/philsong/ohlala/golink/models"
"strconv"
//"time"
//"github.com/philsong/ohlala/golink"
//"html/template"
)
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)
}
return ctx.Json(htmlObject)
}
/**
* 收到的评论
*/
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)
}