Beispiel #1
0
  @RequestMapping
  @ResponseBody
  public Page<SysDept> grid(Page page, String condition, HttpServletRequest request) {
    try {
      page.setAutoCount(true);

      String hql = "from SysDept t where 1=1 " + page.getOrderByString("t.treeId asc");

      QueryTranslate queryTranslate = new QueryTranslate(hql, condition);

      // 查询
      page = sysDeptService.findByPage(page, queryTranslate.toString());
    } catch (Exception e) {
      log.error("error", e);
    }

    return page;
  }
Beispiel #2
0
  @RequestMapping
  public String exportExcel(Page page, String condition, String colModel, Model model) {
    try {
      String hql = "from SysDept t where 1=1 " + page.getOrderByString("t.treeId asc");
      QueryTranslate queryTranslate = new QueryTranslate(hql, condition);

      String filePath = "D://temp";
      String fileName = "test.xls";

      String filename =
          ExcelExporter.export(
              colModel, sysDeptService, filePath, fileName, queryTranslate.toString());

      model.addAttribute("filePath", filePath);
      model.addAttribute("fileName", fileName);
    } catch (Exception e) {
      log.error("error", e);
    }

    return "common/dataExport";
  }