예제 #1
0
 /**
  * 修改文件
  *
  * @param articleId
  * @param folderId
  * @param adminId
  * @param title
  * @param summary
  * @param content
  * @param status
  * @param file
  * @param time
  * @return
  * @throws UploadException
  * @throws IOException
  * @throws FolderNotFoundException
  */
 @CacheEvict(value = "article", allEntries = true)
 public Article updateArticle(
     long articleId,
     long folderId,
     long adminId,
     String title,
     String summary,
     String content,
     ArticleConstant.Status status,
     MultipartFile file,
     String time)
     throws UploadException, IOException, FolderNotFoundException {
   Date now = new Date();
   Article article = articleDao.getArticleById(articleId);
   FolderVo folder = folderService.getFolderById(folderId);
   String picture = article.getPicture();
   if (file != null && !file.isEmpty()) {
     picture = MediaUtils.saveImage(file, folder.getWidth(), folder.getHeight());
   }
   article.setFolderId(folder.getFolderId());
   article.setPath(folder.getPath());
   article.setAdminId(adminId);
   article.setTitle(title);
   article.setSummary(summary);
   article.setContent(content);
   article.setViewCount(0);
   article.setCommentCount(0);
   article.setPicture(picture);
   article.setStatus(status);
   if (article.getCheck().equals(ArticleConstant.check.no)) {
     article.setCheck(ArticleConstant.check.init);
   }
   if (StringUtils.isBlank(time)) {
     article.setCreateTime(now);
   } else {
     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
     Date date;
     try {
       date = sdf.parse(time);
     } catch (ParseException e) {
       date = now;
     }
     article.setCreateTime(date);
   }
   articleDao.updateArticle(article);
   return article;
 }
예제 #2
0
 /**
  * 得到目录的显示的文件分页
  *
  * @param folderId
  * @return pageVo
  * @throws FolderNotFoundException
  */
 @Cacheable(value = "article")
 public PageVo<ArticleVo> getArticlePageByFolderId(long folderId, int pageNum, int rows)
     throws FolderNotFoundException {
   PageVo<ArticleVo> pageVo = new PageVo<ArticleVo>(pageNum);
   FolderVo folder = folderService.getFolderById(folderId);
   pageVo.setRows(rows);
   pageVo.setCount(articleDao.getArticleCountOfDisplayByPath(folder.getPath()));
   List<ArticleVo> articlelist =
       articleDao.getArticleListOfDisplayByPath(
           folder.getPath(), pageVo.getOffset(), pageVo.getRows());
   for (ArticleVo artcle : articlelist) {
     FolderVo artcleFolder = folderService.getFolderById(artcle.getFolderId());
     artcle.setFolder(artcleFolder);
   }
   pageVo.setList(articlelist);
   return pageVo;
 }