コード例 #1
0
  /**
   * 获取栏目下 所有文章
   *
   * @param name
   * @param size
   * @return
   */
  @SuppressWarnings("unchecked")
  public List<Articles> getDyniwork(String name, int size) {
    List<Catalogs> catas = new ArrayList<Catalogs>(0); // 设置需要查找的根栏目
    Catalogs catalogs = catalogFreeMarkerManager.getCatByName(name); // 根据栏目名称取得该栏目
    catas.add(catalogs);
    List<Catalogs> cataList = new ArrayList<Catalogs>(0); // 设置此栏目及其所有子级栏目
    getAllCatas(catas, cataList);
    Integer[] ids = new Integer[cataList.size()]; // 取得所有栏目名称
    for (int i = 0; i < cataList.size(); i++) {
      ids[i] = cataList.get(i).getId();
    }

    StringBuffer hql = new StringBuffer("from Articles a where a.catalog.id in (");

    for (Integer id : ids) { // 拼接查询用hql
      hql.append(id).append(",");
    }
    hql.replace(hql.lastIndexOf(","), hql.length(), ")")
        .append(" and a.audited = ? " + "order by a.onTop DESC ,serialNo ,createTime DESC");

    Page page = new Page(Page.start(1, size), size);
    page = pageQuery(page, hql.toString(), new Object[] {CmsConstants.Y});

    return page.getData();
  }
コード例 #2
0
 /**
  * 根据栏目ID获得指定个数的推荐文章的信息,结合首页flash使用
  *
  * @param catalogName 栏目名称
  * @param size 获得文章的个数
  * @return
  */
 @SuppressWarnings("unchecked")
 public Map getEliteArticlesInfo(String catalogName, Integer size, String ctx) {
   String hql =
       "from Articles a where a.catalog.name=? and a.audited=? and a.isElite=? order by serialNo, createTime DESC";
   Page page = new Page(Page.start(1, size), size);
   page = pageQuery(page, hql, new Object[] {catalogName, CmsConstants.Y, CmsConstants.Y});
   Map eliteMap = null;
   if (page.getData() != null) {
     eliteMap = new HashMap();
     String titles = "";
     String imgs = "";
     String urls = "";
     for (Object a : page.getData()) {
       // 前台不显示文章标题,用空格代替
       titles = titles + ((Articles) a).getShortTitle() + "|";
       if (StringUtils.isNotBlank(((Articles) a).getFlashImg())) {
         imgs = imgs + ctx + ((Articles) a).getFlashImg() + "|";
       } else { // 如果推荐文章的图片不存在用默认代替
         imgs = imgs + ctx + CmsConstants.ELITE_ART_IMG + "|";
       }
       urls = urls + ctx + ((Articles) a).getPath() + "|";
     }
     eliteMap.put("titles", cutLastChar(titles));
     eliteMap.put("imgs", cutLastChar(imgs));
     eliteMap.put("urls", cutLastChar(urls));
   }
   return eliteMap;
 }
コード例 #3
0
 /**
  * @param name 栏目名
  * @param size 个数
  * @return list
  */
 @SuppressWarnings("unchecked")
 public List<Articles> getArtsByCatName(String name, int size) {
   String hql =
       "from Articles a "
           + "where a.catalog.name=? and a.audited=? "
           + "order by a.onTop DESC ,serialNo ,createTime DESC";
   Page page = new Page(Page.start(1, size), size);
   page = pageQuery(page, hql, new Object[] {name, CmsConstants.Y});
   return page.getData();
 }
コード例 #4
0
 /** 重写父类的index方法,实现分页检索风险评估信息 */
 @Override
 public String index() {
   StringBuffer hql = new StringBuffer();
   hql.append("from ExpertCategory ec where 1=1 ");
   List<Object> args = new ArrayList<Object>();
   if (StringUtils.isNotBlank(getModel().getName())) {
     hql.append(" and ec.name like ?");
     args.add(MatchMode.ANYWHERE.toMatchString(getModel().getName()));
   }
   Page page = PageUtil.getPage(getPageNo(), getPageSize());
   getManager().pageQuery(page, hql.toString(), args.toArray());
   items = page.getData();
   restorePageData(page);
   return INDEX;
 }
コード例 #5
0
 /**
  * 分页查询文章
  *
  * @param cataName 栏目名
  * @param pageNo 页号
  * @param pageSize 一页记录数
  * @return Page
  */
 public Page queryArticles(String cataName, int pageNo, int pageSize) {
   String hql =
       "from Articles a "
           + "where a.catalog.name=? and a.audited=? "
           + "order by a.onTop DESC ,serialNo ,createTime DESC";
   Page page = new Page(Page.start(pageNo, pageSize), pageSize);
   return pageQuery(page, hql, new Object[] {cataName, CmsConstants.Y});
 }
コード例 #6
0
ファイル: CatAction.java プロジェクト: PabloRPalma/systop
 /**
  * 地震目录查询返回结果 按照所选条件分页查询地震目录数据
  *
  * @return
  */
 public String list() {
   if (StringUtils.isNotBlank(model.getTableName())) {
     try {
       model.setPage(getPage());
       // 测震SCHEMA
       model.setSchema(dataSourceManager.getSeismicSchema());
       model.setSortProperty(getSortProperty());
       model.setSortDir(getSortDir());
       // limit查询,设定start和size
       int start = Page.start(getPageNo(), getPageSize());
       model.setStart(start);
       model.setSize(getPageSize());
       logger.debug("list方法,开始记录:{},pageSize:{}", start, getPageSize());
       if (model.getStartDate() != null) {
         Date startDate = DateUtil.firstSecondOfDate(model.getStartDate());
         model.setStartDate(startDate);
       }
       if (model.getEndDate() != null) {
         Date endDate = DateUtil.lastSecondOfDate(model.getEndDate());
         model.setEndDate(endDate);
       }
       // 查询地震目录
       Page page = gridCatDao.query(model);
       logger.debug("查询出的记录数:{}", page.getData().size());
       getRequest().setAttribute("items", page.getData());
       cats = page.getData(); // 供震相、Seed使用的数据
       restorePageData(page.getRows(), getPageSize());
     } catch (Exception e) {
       logger.error("数据查询错误{}", e.getMessage());
       e.printStackTrace();
       clean();
     }
   }
   return "list";
 }