Search in sources :

Example 16 with BussinessLog

use of com.zyd.blog.business.annotation.BussinessLog in project OneBlog by zhangyd-c.

the class RenderController method article.

/**
 * 文章详情
 *
 * @param model
 * @param articleId
 * @return
 */
@GetMapping("/article/{articleId}")
@BussinessLog(value = "进入文章[{2}]详情页", platform = PlatformEnum.WEB)
public ModelAndView article(Model model, @PathVariable("articleId") Long articleId) {
    Article article = bizArticleService.getByPrimaryKey(articleId);
    if (article == null || ArticleStatusEnum.UNPUBLISHED.getCode() == article.getStatusEnum().getCode()) {
        return ResultUtil.forward("/error/404");
    }
    if (article.getPrivate()) {
        article.setPassword(null);
        article.setContent(null);
        article.setContentMd(null);
    }
    if (article.getRequiredAuth()) {
        User sessionUser = SessionUtil.getUser();
        if (null != sessionUser) {
            article.setRequiredAuth(false);
        }
    }
    model.addAttribute("article", article);
    // 上一篇下一篇
    model.addAttribute("other", bizArticleService.getPrevAndNextArticles(article.getCreateTime()));
    // 相关文章
    model.addAttribute("relatedList", bizArticleService.listRelatedArticle(SIDEBAR_ARTICLE_SIZE, article));
    model.addAttribute("articleDetail", true);
    return ResultUtil.view("article");
}
Also used : User(com.zyd.blog.business.entity.User) Article(com.zyd.blog.business.entity.Article) GetMapping(org.springframework.web.bind.annotation.GetMapping) BussinessLog(com.zyd.blog.business.annotation.BussinessLog)

Example 17 with BussinessLog

use of com.zyd.blog.business.annotation.BussinessLog in project OneBlog by zhangyd-c.

the class RestWebSiteController method robots.

@GetMapping(value = "/robots.txt", produces = { "text/plain" })
@BussinessLog(value = "查看robots", platform = PlatformEnum.WEB)
public String robots() {
    Template template = templateService.getTemplate(TemplateKeyEnum.TM_ROBOTS);
    Map<String, Object> map = new HashMap<>();
    map.put("config", configService.getConfigs());
    return FreeMarkerUtil.template2String(template.getRefValue(), map, true);
}
Also used : HashMap(java.util.HashMap) Template(com.zyd.blog.business.entity.Template) GetMapping(org.springframework.web.bind.annotation.GetMapping) BussinessLog(com.zyd.blog.business.annotation.BussinessLog)

Example 18 with BussinessLog

use of com.zyd.blog.business.annotation.BussinessLog in project OneBlog by zhangyd-c.

the class RenderController method type.

/**
 * 分类列表(分页)
 *
 * @param typeId
 * @param pageNumber
 * @param model
 * @return
 */
@GetMapping("/type/{typeId}/{pageNumber}")
@BussinessLog(value = "进入文章分类[{1}]列表第{2}页", platform = PlatformEnum.WEB)
public ModelAndView type(@PathVariable("typeId") Long typeId, @PathVariable("pageNumber") Integer pageNumber, Model model) {
    ArticleConditionVO vo = new ArticleConditionVO();
    vo.setTypeId(typeId);
    vo.setPageNumber(pageNumber);
    model.addAttribute("url", "type/" + typeId);
    loadIndexPage(vo, model);
    return ResultUtil.view(INDEX_URL);
}
Also used : ArticleConditionVO(com.zyd.blog.business.vo.ArticleConditionVO) GetMapping(org.springframework.web.bind.annotation.GetMapping) BussinessLog(com.zyd.blog.business.annotation.BussinessLog)

Aggregations

BussinessLog (com.zyd.blog.business.annotation.BussinessLog)18 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)9 PostMapping (org.springframework.web.bind.annotation.PostMapping)9 GetMapping (org.springframework.web.bind.annotation.GetMapping)7 ArticleConditionVO (com.zyd.blog.business.vo.ArticleConditionVO)4 User (com.zyd.blog.business.entity.User)3 HashMap (java.util.HashMap)3 JSONObject (com.alibaba.fastjson.JSONObject)2 Article (com.zyd.blog.business.entity.Article)2 Notice (com.zyd.blog.business.entity.Notice)2 FileUploader (com.zyd.blog.file.FileUploader)2 VirtualFile (com.zyd.blog.file.entity.VirtualFile)2 ZhydCommentException (com.zyd.blog.framework.exception.ZhydCommentException)2 GlobalFileUploader (com.zyd.blog.plugin.file.GlobalFileUploader)2 JSONArray (com.alibaba.fastjson.JSONArray)1 Comment (com.zyd.blog.business.entity.Comment)1 Template (com.zyd.blog.business.entity.Template)1 PlatformEnum (com.zyd.blog.business.enums.PlatformEnum)1 ZhydArticleException (com.zyd.blog.framework.exception.ZhydArticleException)1 ZhydException (com.zyd.blog.framework.exception.ZhydException)1