예제 #1
0
  /** 查询发帖列表 */
  @SuppressWarnings({"unchecked", "rawtypes"})
  public String queryBBSMessageList() {
    String title = request.getParameter("title");
    String page = request.getParameter("page"); // 当前页数
    String rows = request.getParameter("rows"); // 每页显示行数
    String timeperiod = request.getParameter("timeperiod");
    String isessence = request.getParameter("isessence");
    if (null == page || page.equals("")) {
      page = "1";
    }
    if (null == rows || rows.equals("")) {
      rows = "30";
    }
    currentPage = Integer.parseInt(page);
    prePage = currentPage - 1;
    nextPage = currentPage + 1;
    try {
      BBSMessageQuery bbMessageQuery = new BBSMessageQuery();

      if (null != title && !title.equals("")) {
        bbMessageQuery.setTitle(title);
      } else {
        bbMessageQuery.setTitle("");
      }
      if (null != timeperiod && !timeperiod.equals("")) {
        bbMessageQuery.setQueryPeriod(timeperiod);
      } else {
        bbMessageQuery.setQueryPeriod("");
      }

      if (null != isessence && !isessence.equals("")) {
        bbMessageQuery.setIsessence(Integer.parseInt(isessence));
      } else {
        bbMessageQuery.setIsessence(0);
      }
      Map map =
          bbsMessageService.queryBBSMessageForPage(
              bbMessageQuery, Integer.valueOf(rows), Integer.valueOf(page));
      bbsmessagelist = (List<BBSMessageQuery>) map.get(Constant.BBSMESSAGE_LIST);
      totalCount = (Integer) map.get(Constant.TOTALCOUNT);
      totalPageCount = (Integer) map.get(Constant.TOTALPAGECOUNT);
      totalpages = new ArrayList<Integer>();
      for (int i = Integer.valueOf(page); i <= totalPageCount; i++) {
        totalpages.add(i);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "bbs_result";
  }
예제 #2
0
  public String queryBBSMessageDetail() {
    super.commonQuery();
    String id = request.getParameter("id");
    try {
      bbsMessageQuery = bbsMessageService.findBBSMessageQuery(Long.parseLong(id));
      BBSMessage bbs = new BBSMessage();
      bbs.setId(bbsMessageQuery.getId());
      bbs.setContent(bbsMessageQuery.getContent());
      bbs.setCreateTime(bbsMessageQuery.getCreateTime());
      bbs.setScannum(bbsMessageQuery.getScannum() + 1);
      bbs.setTitle(bbsMessageQuery.getTitle());
      bbs.setUserid(bbsMessageQuery.getUserid());

      bbsMessageService.saveEntity(bbs);
      commentslist = bbsMessageService.queryCommentsByMsgId(Long.parseLong(id));
    } catch (NumberFormatException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "bbs_detail";
  }