Пример #1
0
 /** 显示用户列表(tab方式) */
 @RequestMapping(value = "/listtabUsers")
 public ModelAndView listtabUsers(Page page) throws Exception {
   ModelAndView mv = this.getModelAndView();
   PageData pd = new PageData();
   pd = this.getPageData();
   List<PageData> userList = userService.listAllUser(pd); // 列出用户列表
   mv.setViewName("system/user/user_tb_list");
   mv.addObject("userList", userList);
   mv.addObject("pd", pd);
   mv.addObject(Const.SESSION_QX, this.getHC()); // 按钮权限
   return mv;
 }
Пример #2
0
  /*
   * 导出用户信息到EXCEL
   * @return
   */
  @RequestMapping(value = "/excel")
  public ModelAndView exportExcel() {
    ModelAndView mv = this.getModelAndView();
    PageData pd = new PageData();
    pd = this.getPageData();
    try {
      if (Jurisdiction.buttonJurisdiction(menuUrl, "cha")) {
        // 检索条件===
        String USERNAME = pd.getString("USERNAME");
        if (null != USERNAME && !"".equals(USERNAME)) {
          USERNAME = USERNAME.trim();
          pd.put("USERNAME", USERNAME);
        }
        String lastLoginStart = pd.getString("lastLoginStart");
        String lastLoginEnd = pd.getString("lastLoginEnd");
        if (lastLoginStart != null && !"".equals(lastLoginStart)) {
          lastLoginStart = lastLoginStart + " 00:00:00";
          pd.put("lastLoginStart", lastLoginStart);
        }
        if (lastLoginEnd != null && !"".equals(lastLoginEnd)) {
          lastLoginEnd = lastLoginEnd + " 00:00:00";
          pd.put("lastLoginEnd", lastLoginEnd);
        }
        // 检索条件===

        Map<String, Object> dataMap = new HashMap<String, Object>();
        List<String> titles = new ArrayList<String>();

        titles.add("用户名"); // 1
        titles.add("编号"); // 2
        titles.add("姓名"); // 3
        titles.add("职位"); // 4
        titles.add("手机"); // 5
        titles.add("邮箱"); // 6
        titles.add("最近登录"); // 7
        titles.add("上次登录IP"); // 8

        dataMap.put("titles", titles);

        List<PageData> userList = userService.listAllUser(pd);
        List<PageData> varList = new ArrayList<PageData>();
        for (int i = 0; i < userList.size(); i++) {
          PageData vpd = new PageData();
          vpd.put("var1", userList.get(i).getString("USERNAME")); // 1
          vpd.put("var2", userList.get(i).getString("NUMBER")); // 2
          vpd.put("var3", userList.get(i).getString("NAME")); // 3
          vpd.put("var4", userList.get(i).getString("ROLE_NAME")); // 4
          vpd.put("var5", userList.get(i).getString("PHONE")); // 5
          vpd.put("var6", userList.get(i).getString("EMAIL")); // 6
          vpd.put("var7", userList.get(i).getString("LAST_LOGIN")); // 7
          vpd.put("var8", userList.get(i).getString("IP")); // 8
          varList.add(vpd);
        }
        dataMap.put("varList", varList);
        ObjectExcelView erv = new ObjectExcelView(); // 执行excel操作
        mv = new ModelAndView(erv, dataMap);
      }
    } catch (Exception e) {
      logger.error(e.toString(), e);
    }
    return mv;
  }