Ejemplo n.º 1
0
  public String getIndex() {

    Map<String, Object> session = ActionContext.getContext().getSession();

    // 已注册用户数
    int userCount = userInfoService.findUserCount();
    // 已发布图书数
    int bookCount = bookService.findBookCount();
    // 已注册作者数
    int authorCount = authorService.findAuthorCount();

    // 存放5条点击量最高的图书数据
    listHits = bookService.find5BooksOrderByHits();

    // 存放5条好评最高的图书数据
    listGrade = bookService.find5BookOrderByGrade();

    // 取右侧图书数据
    PageHelper.Page<Book> page = bookService.findAllWithPage(1, Cons.DEFAULTPAGESIZE);

    listBooks = page.getResult();

    totalPage = (int) page.getPages();
    currentPageNum = page.getPageNum();

    session.put("userCount", userCount);

    session.put("bookCount", bookCount);

    session.put("authorCount", authorCount);

    UserInfo userInfo = (UserInfo) session.get("userInfo");
    if (userInfo != null) {

      int messageCount = userMessageService.findUserMessageCountByUserId(userInfo.getUserId());
      System.out.println("消息数:" + messageCount);

      session.put("messageCount", messageCount);

      int markCount = userBookMarksService.findUserBookMarksCountByUserId(userInfo.getUserId());
      System.out.println("书签数:" + markCount);

      session.put("markCount", markCount);

      int collectionCount =
          userCollectionService.findUserCollectionCountByUserId(userInfo.getUserId());
      session.put("collectionCount", collectionCount);
    }

    return "index";
  }
Ejemplo n.º 2
0
  // 获得下一页的数据
  public String getNextPage() {

    if (currentPageNum == totalPage) currentPageNum = 1;
    else currentPageNum = currentPageNum + 1;

    Page<Book> page = bookService.findAllWithPage(currentPageNum, Cons.DEFAULTPAGESIZE);

    currentPageNum = page.getPageNum();

    Map<String, Object> map = new HashMap<String, Object>();

    List<Book> list = page.getResult();

    map.put("currentPageNum", currentPageNum);
    map.put("list", list);

    this.setMap(map);
    return SUCCESS;
  }