コード例 #1
0
ファイル: LinkService.java プロジェクト: jacking124/jeesite
 @Transactional(readOnly = false)
 public void save(Link link) {
   // 如果没有审核权限,则将当前内容改为待审核状态
   if (!SecurityUtils.getSubject().isPermitted("cms:link:audit")) {
     link.setDelFlag(Link.DEL_FLAG_AUDIT);
   }
   // 如果栏目不需要审核,则将该内容设为发布状态
   if (link.getCategory() != null && StringUtils.isNotBlank(link.getCategory().getId())) {
     Category category = categoryDao.get(link.getCategory().getId());
     if (!Article.YES.equals(category.getIsAudit())) {
       link.setDelFlag(Article.DEL_FLAG_NORMAL);
     }
   }
   linkDao.clear();
   linkDao.save(link);
 }
コード例 #2
0
ファイル: LinkService.java プロジェクト: jacking124/jeesite
 @Transactional(readOnly = false)
 public Page<Link> find(Page<Link> page, Link link, boolean isDataScopeFilter) {
   // 更新过期的权重,间隔为“6”个小时
   Date updateExpiredWeightDate = (Date) CacheUtils.get("updateExpiredWeightDateByLink");
   if (updateExpiredWeightDate == null
       || (updateExpiredWeightDate != null
           && updateExpiredWeightDate.getTime() < new Date().getTime())) {
     linkDao.updateExpiredWeight();
     CacheUtils.put("updateExpiredWeightDateByLink", DateUtils.addHours(new Date(), 6));
   }
   DetachedCriteria dc = linkDao.createDetachedCriteria();
   dc.createAlias("category", "category");
   dc.createAlias("category.site", "category.site");
   if (link.getCategory() != null
       && StringUtils.isNotBlank(link.getCategory().getId())
       && !Category.isRoot(link.getCategory().getId())) {
     Category category = categoryDao.get(link.getCategory().getId());
     if (category != null) {
       dc.add(
           Restrictions.or(
               Restrictions.eq("category.id", category.getId()),
               Restrictions.like("category.parentIds", "%," + category.getId() + ",%")));
       dc.add(Restrictions.eq("category.site.id", category.getSite().getId()));
       link.setCategory(category);
     } else {
       dc.add(Restrictions.eq("category.site.id", Site.getCurrentSiteId()));
     }
   } else {
     dc.add(Restrictions.eq("category.site.id", Site.getCurrentSiteId()));
   }
   if (StringUtils.isNotEmpty(link.getTitle())) {
     dc.add(Restrictions.like("title", "%" + link.getTitle() + "%"));
   }
   if (link.getCreateBy() != null && StringUtils.isNotBlank(link.getCreateBy().getId())) {
     dc.add(Restrictions.eq("createBy.id", link.getCreateBy().getId()));
   }
   if (isDataScopeFilter) {
     dc.createAlias("category.office", "categoryOffice").createAlias("createBy", "createBy");
     dc.add(dataScopeFilter(UserUtils.getUser(), "categoryOffice", "createBy"));
   }
   dc.add(Restrictions.eq(Link.FIELD_DEL_FLAG, link.getDelFlag()));
   dc.addOrder(Order.desc("weight"));
   dc.addOrder(Order.desc("updateDate"));
   return linkDao.find(page, dc);
 }