Browse Source

uuHelperGroupList页面的数据滚动加载

huangct 8 years ago
parent
commit
4c61839722

+ 0 - 14
jpress-model/src/main/java/io/jpress/model/Comment.java

@@ -20,7 +20,6 @@ import io.jpress.model.core.Table;
 import io.jpress.model.query.CommentQuery;
 import io.jpress.model.query.CommentQuery;
 import io.jpress.model.query.ContentQuery;
 import io.jpress.model.query.ContentQuery;
 import io.jpress.model.query.UserQuery;
 import io.jpress.model.query.UserQuery;
-import io.jpress.utils.StringUtils;
 
 
 import java.math.BigInteger;
 import java.math.BigInteger;
 
 
@@ -136,19 +135,6 @@ public class Comment extends BaseComment<Comment> {
 		return super.save();
 		return super.save();
 	}
 	}
 
 
-	//判断该用户是否以及评论过改uu软文
-	public boolean isUuUserReplied(String uuUserId) {
-		if (StringUtils.isBlank(uuUserId)) {
-			return true;
-		}
-		BigInteger contentId = getContentId();
-		long count = CommentQuery.me().findCountByContentIdAndUuUserId(contentId, new BigInteger(uuUserId));
-		if (count > 0) {
-			return true;
-		}
-		return false;
-	}
-
 	public Comment getlatestSon(BigInteger id){
 	public Comment getlatestSon(BigInteger id){
         return CommentQuery.me().findLatestSon(id);
         return CommentQuery.me().findLatestSon(id);
 	}
 	}

+ 43 - 4
jpress-web-admin/src/main/java/io/jpress/admin/controller/_ContentController.java

@@ -27,10 +27,7 @@ import io.jpress.core.render.AjaxResult;
 import io.jpress.interceptor.UCodeInterceptor;
 import io.jpress.interceptor.UCodeInterceptor;
 import io.jpress.message.Actions;
 import io.jpress.message.Actions;
 import io.jpress.message.MessageKit;
 import io.jpress.message.MessageKit;
-import io.jpress.model.Content;
-import io.jpress.model.Metadata;
-import io.jpress.model.Taxonomy;
-import io.jpress.model.User;
+import io.jpress.model.*;
 import io.jpress.model.query.*;
 import io.jpress.model.query.*;
 import io.jpress.model.router.ContentRouter;
 import io.jpress.model.router.ContentRouter;
 import io.jpress.router.RouterMapping;
 import io.jpress.router.RouterMapping;
@@ -44,6 +41,7 @@ import io.jpress.utils.StringUtils;
 
 
 import java.math.BigInteger;
 import java.math.BigInteger;
 import java.sql.SQLException;
 import java.sql.SQLException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.*;
 
 
 @RouterMapping(url = "/admin/content", viewPath = "/WEB-INF/admin/content")
 @RouterMapping(url = "/admin/content", viewPath = "/WEB-INF/admin/content")
@@ -561,4 +559,45 @@ public class _ContentController extends JBaseCRUDController<Content> {
 		return tags;
 		return tags;
 	}
 	}
 
 
+	@Before(UCodeInterceptor.class)
+	public void lazyLoad() {
+		String[] modules = new String[1];
+		modules[0] = getPara("module");
+
+		//findListInNormal 的page参数并非页数,只是行数。未改其方法源码,本人在此处直接作乘pagesize处理
+		List<Content> list = ContentQuery.me().findListInNormal(((getParaToInt("pagenumber")-1)*getParaToInt("pagesize"))+1, getParaToInt("pagesize"), getPara("orderBy"), null, null, null, modules, null, null, null, null, null, null, null, null);
+		StringBuilder htmlBuilder = new StringBuilder();
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+		for (int i=0; i < list.size(); i++) {
+			Content content = list.get(i);
+			String pushTime = content.getMetadataByKey("push_time");
+			if (pushTime == null) {
+				pushTime = "";
+			}
+			htmlBuilder.append("<tr>\n" +
+									"<td class=\"messageTitle\">"+ content.getTitle() +"</td>\n" +
+									"<td class=\"messageTime\">"+ pushTime + "</td>");
+				htmlBuilder.append(" <td class=\"isOpenMessage\">\n" +
+										"<select id=\"commentStatus"+content.getId()+"\" onchange=\"changeCommentSataus"+content.getId()+"\">");
+					if (StringUtils.isNotBlank(content.getCommentStatus()) && "close".equals(content.getCommentStatus())) {
+						htmlBuilder.append("<option value=\"close\" selected=\"selected\">关闭</option>");
+					} else {
+						htmlBuilder.append("<option value=\"close\">关闭</option>");
+					}
+
+					if (StringUtils.isNotBlank(content.getCommentStatus()) && "open".equals(content.getCommentStatus())) {
+						htmlBuilder.append("<option value=\"open\" selected=\"selected\">开启</option>");
+					} else {
+						htmlBuilder.append("option value=\"open\">开启</option>");
+					}
+					htmlBuilder.append("</select>\n" +
+									"</td>\n" +
+									"<td class=\"handleMessage\">\n" +
+										"<a class=\"replay\" href=\""+ getPara("CPATH") +"/admin/comment?t=comment&m=uuhelper&p=uuhelper&c=comment&cid="+ content.getId() +"&way=detail\">查看</a>\n" +
+									"</td>\n" +
+								"</tr>");
+		}
+		renderAjaxResultForSuccess(htmlBuilder.toString());
+	}
+
 }
 }

+ 25 - 8
jpress-web-admin/src/main/webapp/WEB-INF/admin/comment/uuHelperGroupList.html

@@ -98,13 +98,30 @@
         </div>
         </div>
         <!-- /.box-body -->
         <!-- /.box-body -->
     </div>
     </div>
-    <div class="cf pageUas">
-        <div class="pull-right " >
-            <#if page??>
-                <#include "../_inc/_paginate.html" />
-                <@paginate currentPage=page.pageNumber totalPage=page.totalPage actionUrl="?p="+(p!)+"&c="+(c!)+"&m="+(m!)+"&t="+(t!)+"&s="+(s!)+"&k="+(k!)+"&tids="+(tids!)+"&page="/>
-            </#if>
-        </div>
-    </div>
     <!-- /.row -->
     <!-- /.row -->
 </section>
 </section>
+<script type="text/javascript" src="${CTPATH}/assets/js/jquery.min.js"></script>
+<script>
+    //下拉加载更多
+    var aa = 1, timers = null;
+    //加载数据
+    var LoadingDataFn = function() {
+        $.get("${CPATH}/admin/content/lazyLoad?ucode=${ucode!}&CPATH=${CPATH!}&pagesize=10&orderBy=meta:push_time desc&module=uuhelper&pagenumber="+aa, function(result){
+            var dom = '';
+            dom += result.message;
+            $('.bodyUas').append(dom);
+        });
+
+    };
+    //初始化
+    //滚动加载方法
+    $(window).scroll(function() {
+        if (($(window).height() + $(window).scrollTop() + 60) >= $(document).height()) {
+            clearTimeout(timers);
+            timers = setTimeout(function() {
+                aa++;
+                LoadingDataFn();
+            }, 300);
+        }
+    });
+</script>