示例#1
0
  public String save() {
    boolean flag = false;
    MessageComment messageComment = getMessageComment();

    try {
      messageCommentService.saveEntity(messageComment);
      bbsMessageQuery = bbsMessageService.findBBSMessageQuery(messageComment.getMessageid());
      commentslist = bbsMessageService.queryCommentsByMsgId(messageComment.getMessageid());
      flag = true;
      super.reponseWriter(JSON.toJSONString(flag));
    } catch (NumberFormatException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "bbs_detail";
  }
示例#2
0
 /**
  * 标记精华贴
  *
  * @throws IOException
  */
 public void essence() throws IOException {
   response.setHeader("Content-type", "text/html;chartset=utf8");
   response.setCharacterEncoding("utf8");
   PrintWriter out = response.getWriter();
   String id = request.getParameter("id");
   try {
     BBSMessage bbsMessage = bbsMessageService.findEntityById(Long.valueOf(id), BBSMessage.class);
     bbsMessage.setIsessence(1);
     bbsMessageService.saveEntity(bbsMessage);
     out.print("标记成功");
   } catch (NumberFormatException e) {
     e.printStackTrace();
     out.print("标记失败");
   } catch (Exception e) {
     e.printStackTrace();
     out.print("标记失败");
   } finally {
     out.flush();
     out.close();
   }
 }
示例#3
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";
  }
示例#4
0
 public void delete() {
   boolean flag = false;
   String id = request.getParameter("id");
   try {
     bbsMessageService.removeEntityById(Long.valueOf(id), BBSMessage.class);
     flag = true;
     super.reponseWriter(JSON.toJSONString(flag));
   } catch (NumberFormatException e) {
     e.printStackTrace();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
示例#5
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";
  }
示例#6
0
  /** 查询主页 */
  public void query() {
    String page = request.getParameter("page"); // 当前页数
    String rows = request.getParameter("rows"); // 每页显示行数

    try {
      BBSMessage bbsMessage = new BBSMessage();
      Pager pager =
          bbsMessageService.queryBBSMessageByPage(
              bbsMessage, Integer.valueOf(rows), Integer.valueOf(page));
      super.reponseWriter(JSON.toJSONString(pager));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
示例#7
0
 public void update() {
   boolean flag = false;
   String id = request.getParameter("id");
   BBSMessage bbsMessage = getBBSMessage();
   try {
     bbsMessage.setId(Long.valueOf(id));
     bbsMessageService.saveEntity(bbsMessage);
     flag = true;
     super.reponseWriter(JSON.toJSONString(flag));
   } catch (NumberFormatException e) {
     e.printStackTrace();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
示例#8
0
  public void save() {
    boolean flag = false;
    BBSMessage bbsMessage = getBBSMessage();

    try {
      bbsMessage.setScannum(Long.parseLong("0"));
      bbsMessage.setIsessence(0);
      bbsMessageService.saveEntity(bbsMessage);
      flag = true;
      super.reponseWriter(JSON.toJSONString(flag));
    } catch (NumberFormatException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
示例#9
0
  public String addMsg() {
    boolean flag = false;
    BBSMessage bbsMessage = getBBSMessage();

    try {
      bbsMessage.setScannum(Long.parseLong("0"));
      bbsMessage.setIsessence(0);
      bbsMessageService.saveEntity(bbsMessage);
      flag = true;
    } catch (NumberFormatException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
    if (flag) {
      return "bbs_index";
    } else {
      errmsg = "发帖失败";
      return "bbs_sent";
    }
  }