Пример #1
0
  @RequestMapping(value = {"/index", "/index.html", "/index.jsp", "/index.do"})
  public String index(
      HttpServletRequest request,
      @RequestParam(defaultValue = "0") int offset,
      @RequestParam(defaultValue = "15") int limit,
      Model model) {

    if (!configService.isUserLogin(request)) {
      return "redirect:login";
    }

    Pagination<UserPrize> datas = getUserPrizePage(offset, limit);
    model.addAttribute("datas", datas);
    model.addAttribute("totalPrize", prizeService.getTotalPrize());

    int userNum = userService.countUser();
    int taskNum = taskService.countTask();
    int helpNum = friendHelperService.countFriendHelper();
    model.addAttribute("userNum", userNum);
    model.addAttribute("taskNum", taskNum);
    model.addAttribute("helpNum", helpNum);

    int helpAndNoTaskNum = friendHelperService.countFriendHelperAndNotCreateTask();
    model.addAttribute("helpAndNoTaskNum", helpAndNoTaskNum);

    int TaskAndDoHelpNum = taskService.countCreateTaskAndDoHelper();
    model.addAttribute("TaskAndDoHelpNum", TaskAndDoHelpNum);

    int uniqueNameNum = userService.countUniqueTrueNameUser();
    model.addAttribute("uniqueNameNum", uniqueNameNum);

    return "admin";
  }
Пример #2
0
  @RequestMapping(value = "/download", method = RequestMethod.GET)
  public void csvDownLoad(
      ModelMap model, HttpServletRequest request, HttpServletResponse httpServletResponse)
      throws Exception {

    if (!configService.isUserLogin(request)) {
      return;
    }

    Pagination<TaskHelpRE> page = friendHelperService.getTasKUserPagination(0, 50);

    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
    StringBuffer fileName =
        new StringBuffer("task-help-").append(dateFormat.format(new Date())).append(".txt");

    httpServletResponse.setContentType("application/octet-stream");
    httpServletResponse.addHeader(
        "Content-Disposition", "attachment; filename=" + fileName.toString());
    BufferedWriter write = null;
    try {
      write = new BufferedWriter(new OutputStreamWriter(httpServletResponse.getOutputStream()));
      do {
        List<TaskHelpRE> items = page.getItems();
        writeTaskHelperREList(write, items);
        // get next page
        page =
            friendHelperService.getTasKUserPagination(
                page.getCurrentPage() * page.getPageSize(), page.getPageSize());
      } while (page.getCurrentPage() < page.getPages());

    } catch (IOException e) {
      throw e;
    } finally {
      try {
        if (write != null) {
          write.flush();
          write.close();
        }
      } catch (IOException e) {
        throw e;
      }
    }
  }