예제 #1
0
 /** Blog分页 */
 @Override
 @Transactional
 public PageConf findBlogPageList(int start, int limit, UserInfo userInfo, String type)
     throws BlogException {
   try {
     String hql =
         " select module from Blog module left join fetch module.userInfo left join fetch module.blogCategory ";
     // 通用查询匹配
     if (type != null) {
       if (type.equals("friend") && userInfo != null) {
         hql +=
             " where exists ( select friend.friend.id from Friend friend "
                 + " where friend.friend.id = module.userInfo.id and friend.userId = ? ) "
                 + " order by module.createTime desc ";
         return baseDao.findPage(start, limit, hql, userInfo.getId());
       } else if (type.equals("my") && userInfo != null) {
         // 查询我自己的日志
         hql += " where module.userInfo.id = ? order by module.createTime desc ";
         return baseDao.findPage(start, limit, hql, userInfo.getId());
       } else if (type.equals("all")) {
         //
         hql += " order by module.createTime desc ";
         return baseDao.findPage(start, limit, hql);
       } else {
         return null;
       }
     } else {
       return null;
     }
   } catch (Exception e) {
     throw new BlogException("Blog分页异常");
   }
 }