@ -84,6 +84,13 @@ func (c BaseController) GetUserInfo() info.User {
|
||||
return info.User{}
|
||||
}
|
||||
|
||||
func (c BaseController) GetUserAndBlogUrl() info.UserAndBlogUrl {
|
||||
if userId, ok := c.Session["UserId"]; ok && userId != "" {
|
||||
return userService.GetUserAndBlogUrl(userId);
|
||||
}
|
||||
return info.UserAndBlogUrl{}
|
||||
}
|
||||
|
||||
// 这里的session都是cookie中的, 与数据库session无关
|
||||
func (c BaseController) GetSession(key string) string {
|
||||
v, ok := c.Session[key]
|
||||
|
@ -24,8 +24,8 @@ type Note struct {
|
||||
// 否则, 转向登录页面
|
||||
func (c Note) Index(noteId, online string) revel.Result {
|
||||
c.SetLocale()
|
||||
userInfo := c.GetUserInfo()
|
||||
|
||||
userInfo := c.GetUserAndBlogUrl()
|
||||
|
||||
userId := userInfo.UserId.Hex()
|
||||
|
||||
// 没有登录
|
||||
@ -138,13 +138,13 @@ func (c Note) Index(noteId, online string) revel.Result {
|
||||
// 已登录, 得到用户基本信息(notebook, shareNotebook), 跳转到index.html中
|
||||
// 否则, 转向登录页面
|
||||
func (c Note) ListNotes(notebookId string) revel.Result {
|
||||
_, notes := noteService.ListNotes(c.GetUserId(), notebookId, false, c.GetPage(), pageSize, defaultSortField, false, false);
|
||||
_, notes := noteService.ListNotes(c.GetUserId(), notebookId, false, c.GetPage(), pageSize, defaultSortField, false, false)
|
||||
return c.RenderJson(notes)
|
||||
}
|
||||
|
||||
// 得到trash
|
||||
func (c Note) ListTrashNotes() revel.Result {
|
||||
_, notes := noteService.ListNotes(c.GetUserId(), "", true, c.GetPage(), pageSize, defaultSortField, false, false);
|
||||
_, notes := noteService.ListNotes(c.GetUserId(), "", true, c.GetPage(), pageSize, defaultSortField, false, false)
|
||||
return c.RenderJson(notes)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user