public String saveCommentHtml( String albumid, Member member, String userIp, String comcontent, String fcommentedid) { // 取当前时间 Date now = new Date(System.currentTimeMillis()); albums a = new albums(); a.setAlbumid(albumid); Albumcomment albumcomm = new Albumcomment(); albumcomm.setCommentedcontent(comcontent); // 留言内容 albumcomm.setAlbums(a); // 被留言的相册 albumcomm.setCommenteddate(now); // 留言时间 albumcomm.setMember(member); // 会员信息 albumcomm.setUserip(userIp); // 留言用户IP albumcomm.setUsername(member.getNikename()); // 留言用户姓名 // 处理父留言 if (null != fcommentedid && fcommentedid.length() > 0) { Albumcomment parent = new Albumcomment(); parent.setCommentedid(fcommentedid); albumcomm.setParent(parent); } albumCommentDao.save(albumcomm); // 查询留言信息,已经排好序 List<Albumcomment> list = getListByAlbum(albumid); // 处理留言HTML return appendHtml(list, albumid); }
private void commentTree(String fid, List<Albumcomment> listold) { // 循环查找子回复内容 for (Albumcomment b : listold) { if (null == fid || fid.length() == 0) { if (null == b.getParent()) { tree.add(b); commentTree(b.getCommentedid(), listold); } } else { if (null != b.getParent() && b.getParent().getCommentedid().equals(fid)) { tree.add(b); commentTree(b.getCommentedid(), listold); } } } }