public Pagination<ServiceOrderView> manageOrderList(
      Pagination<ServiceOrder> page, String exployerName, String telephone) {
    List<Object> params = new ArrayList<Object>();
    StringBuffer hql = new StringBuffer("from ServiceOrder r where ovld = true ");
    if (!StringUtils.isEmpty(telephone)) {
      hql.append(" and r.mobilePhone = ? ");
      params.add(telephone);
    }
    if (!StringUtils.isEmpty(exployerName)) {
      hql.append(" and r.employer.username like ? ");
      params.add("%" + exployerName + "%");
    }

    StringBuffer countHql = new StringBuffer(" select count(r.id) ");
    countHql.append(hql);
    Object[] objParams = new Object[params.size()];
    for (int i = 0; i < objParams.length; i++) {
      objParams[i] = params.get(i);
    }
    Pagination<ServiceOrder> p =
        dao.getPageResultObjectParams(
            ServiceOrder.class, hql.toString(), page.getPageNo(), page.getPageSize(), objParams);
    List<ServiceOrder> list = p.getResult();
    List<ServiceOrderView> viewList = new ArrayList<ServiceOrderView>();
    for (ServiceOrder order : list) {
      viewList.add(order.view());
    }

    Pagination<ServiceOrderView> pa =
        new Pagination<ServiceOrderView>(viewList, p.getPageNo(), p.getPageSize());
    Long count = dao.getSingleResultByHQLObjectParams(Long.class, countHql.toString(), objParams);
    pa.setResultSize(count);
    return pa;
  }
Пример #2
0
  public Pagination<RoleView> getPageRoleList(Pagination<Role> page) {
    String hql = "from Role r";
    String countHql = "select count(r.id) from Role r";

    Pagination<Role> p = dao.getPageResult(Role.class, hql, page.getPageNo(), page.getPageSize());
    List<Role> list = p.getResult();
    List<RoleView> result = new ArrayList<RoleView>();
    for (Role role : list) {
      result.add(role.view());
    }
    Pagination<RoleView> pageView =
        new Pagination<RoleView>(result, p.getPageNo(), p.getPageSize());
    Long count = dao.getSingleResultByHQL(Long.class, countHql);
    pageView.setResultSize(count);
    return pageView;
  }