@AuthPermission @ResponseBody @RequestMapping("saveArticle") public String saveArticle(Article article, HttpServletRequest request) { try { String errMsg = ValidateUtils.articleValidate(article); if (errMsg != null) { return JsonResponseUtils.badResult(errMsg); } article.setAuthorId(CommonsUtils.getUserIdFromSession(request)); article.setAuthorName(CommonsUtils.getUserNameFromSession(request)); articleService.save(article); return JsonResponseUtils.ok(); } catch (Exception e) { LOG.error("保存文章失败,", e); return JsonResponseUtils.badResult(e.getMessage()); } }
@AuthPermission @RequestMapping("list") public String list(HttpServletRequest request) { try { Long authorId = CommonsUtils.getUserIdFromSession(request); List<Article> list = articleService.pageList(authorId); request.setAttribute("list", list); return "articleList"; } catch (Exception e) { LOG.error("获取文章列表失败,", e); return JsonResponseUtils.badResult(e.getMessage()); } }