Exemple #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";
  }
Exemple #2
0
  private Pagination<UserPrize> getUserPrizePage(int offset, int limit) {
    Pagination<UserPrize> resp = null;
    List<UserPrize> iterms = new ArrayList<UserPrize>();
    Pagination<Prize> page = prizeService.getPagination(offset, limit);
    List<String> userIds = new ArrayList<String>();

    if (page != null && page.getItems() != null) {
      for (Prize prize : page.getItems()) {
        userIds.add(prize.getUserId());
      }
      Map<String, User> map = userService.getUserMap(userIds);
      for (Prize prize : page.getItems()) {
        iterms.add(new UserPrize(prize, map.get(prize.getUserId())));
      }
    }
    resp = new Pagination<UserPrize>(iterms, page.getTotalCount(), limit, offset);
    return resp;
  }