public ListInfo getCommnetList(String sql, int offset, int maxItem) throws DocCommentManagerException { // TODO Auto-generated method stub DBUtil db = new DBUtil(); DBUtil dbUtil = new DBUtil(); try { db.executeSelect(sql, offset, maxItem); List tempList = new ArrayList(); ListInfo listInfo = new ListInfo(); for (int i = 0; i < db.size(); i++) { DocComment docComment = new DocComment(); int comment_id = db.getInt(i, "comment_id"); docComment.setCommentId(comment_id); docComment.setDocId(db.getInt(i, "doc_id")); String doc_comment = db.getString(i, "doc_comment"); docComment.setDocComment(doc_comment); docComment.setUserName(db.getString(i, "user_name")); docComment.setSubTime(db.getDate(i, "comtime")); docComment.setUserIP(db.getString(i, "user_ip")); docComment.setSrcCommentId(db.getInt(i, "src_comment_id")); docComment.setDocTitle(db.getString(i, "docTitle")); docComment.setStatus(db.getInt(i, "status")); String sql1 = "select word from td_cms_doccomment_dict"; dbUtil.executeSelect(sql1); if (dbUtil.size() > 0) { for (int j = 0; j < dbUtil.size(); j++) { if (doc_comment.indexOf(dbUtil.getString(j, "word")) >= 0) { // 判断是否报警 docComment.setAlarm(1); // 设置报警 } } } sql1 = "select id from td_cms_doccom_impeachinfo where comment_id =" + comment_id; dbUtil.executeSelect(sql1); if (dbUtil.size() > 0) { // 判断是否有举报信息 docComment.setImpeachFlag(1); // 设置为有举报信息 } tempList.add(docComment); } listInfo.setDatas(tempList); listInfo.setTotalSize(db.getTotalSize()); return listInfo; } catch (SQLException e) { e.printStackTrace(); throw new DocCommentManagerException("获取评论列表失败!" + e.getMessage()); } }
public DocComment getCommentByComId(int docCommentId) throws DocCommentManagerException { // TODO Auto-generated method stub DBUtil db = new DBUtil(); String sql = "select * from td_cms_doc_comment where comment_id = " + docCommentId; try { db.executeSelect(sql); if (db.size() > 0) { DocComment docComment = new DocComment(); docComment.setCommentId(db.getInt(0, "comment_id")); docComment.setDocId(db.getInt(0, "doc_id")); docComment.setDocComment(db.getString(0, "doc_comment")); docComment.setUserName(db.getString(0, "user_name")); docComment.setUserIP(db.getString(0, "user_ip")); docComment.setSubTime(db.getDate(0, "comtime")); docComment.setSrcCommentId(db.getInt(0, "src_comment_id")); docComment.setStatus(db.getInt(0, "status")); return docComment; } else return null; } catch (SQLException e) { e.printStackTrace(); throw new DocCommentManagerException("获取指定评论!" + e.getMessage()); } }