Browse Source

评论逻辑添加判断用户是否已经评论过文章。
调整在后台软文列表页在筛选下的分页

huangct 8 years ago
parent
commit
ad9c7499b1

+ 24 - 1
jpress-model/src/main/java/io/jpress/model/Content.java

@@ -198,7 +198,7 @@ public class Content extends BaseContent<Content> implements ISortModel<Content>
 		}
 		}
 		return metadatas;
 		return metadatas;
 	}
 	}
-	
+
 	public String getMetadataByKey(String key) {
 	public String getMetadataByKey(String key) {
 		Metadata metadata = MetaDataQuery.me().findByTypeAndIdAndKey(METADATA_TYPE, getId(), key);
 		Metadata metadata = MetaDataQuery.me().findByTypeAndIdAndKey(METADATA_TYPE, getId(), key);
 		return metadata.getMetaValue();
 		return metadata.getMetaValue();
@@ -467,4 +467,27 @@ public class Content extends BaseContent<Content> implements ISortModel<Content>
 		super.setSlug(slug);
 		super.setSlug(slug);
 	}
 	}
 
 
+	//判断该移动端用户是否以及评论过此uu软文
+	public boolean isUuUserReplied(BigInteger uuUserId) {
+		if (uuUserId == null) {
+			return false;
+		}
+		long count = CommentQuery.me().findCountByContentIdAndUuUserId(getId(), uuUserId);
+		if (count > 0) {
+			return true;
+		}
+		return false;
+	}
+
+	//判断该官网用户是否以及评论过此uu软文
+	public boolean isUserReplied(BigInteger userId) {
+		if (userId == null) {
+			return false;
+		}
+		long count = CommentQuery.me().findCountByContentIdAndUserId(getId(), userId);
+		if (count > 0) {
+			return true;
+		}
+		return false;
+	}
 }
 }

+ 7 - 1
jpress-model/src/main/java/io/jpress/model/query/CommentQuery.java

@@ -251,11 +251,17 @@ public class CommentQuery extends JBaseQuery {
 		return count;
 		return count;
 	}
 	}
 
 
+	//查当前移动端用户是否评论过此文章
 	public long findCountByContentIdAndUuUserId(BigInteger contentId, BigInteger uuUserId) {
 	public long findCountByContentIdAndUuUserId(BigInteger contentId, BigInteger uuUserId) {
 		return DAO.doFindCount(" content_id = ? and uu_user_id=? ", contentId, uuUserId);
 		return DAO.doFindCount(" content_id = ? and uu_user_id=? ", contentId, uuUserId);
 	}
 	}
 
 
-	//只获取最新的一条回复
+	//查当前官网用户是否评论过此文章
+	public long findCountByContentIdAndUserId(BigInteger contentId, BigInteger userId) {
+		return DAO.doFindCount(" content_id = ? and user_id=? ", contentId, userId);
+	}
+
+	//只获取最新的一条作者回复(子回复)
 	public Comment findLatestSon(BigInteger id) {
 	public Comment findLatestSon(BigInteger id) {
 		Comment comment = null;
 		Comment comment = null;
 		List<Comment> list = DAO.find("SELECT * from jpress_comment where parent_id= " + id +" ORDER BY created desc LIMIT 1");
 		List<Comment> list = DAO.find("SELECT * from jpress_comment where parent_id= " + id +" ORDER BY created desc LIMIT 1");

+ 1 - 1
jpress-web-admin/src/main/webapp/WEB-INF/admin/content/_index_include.html

@@ -184,7 +184,7 @@
 
 
 				<#if page??>
 				<#if page??>
 					<#include "../_inc/_paginate.html" />
 					<#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="/>
+					<@paginate currentPage=page.pageNumber totalPage=page.totalPage actionUrl="?p="+(p!)+"&c="+(c!)+"&m="+(m!)+"&t="+(t!)+"&s="+(s!)+"&k="+(k!)+"&pushTime="+(defaultPushTime!)+"&author="+(defaultAuthor!)+"&copyRight="+(defaultCopyRight!)+"&taxonomy="+(defaultTaxonomy!)+"&tids="+(tids!)+"&page="/>
 				</#if>
 				</#if>
 
 
 			</div>
 			</div>

+ 2 - 2
jpress-web-template-usoftchina/src/main/webapp/templates/usoftchina/content_uuhelper.html

@@ -223,7 +223,7 @@
             <div class="readCount"><div><span>阅读 <em>${content.view_count!'0'}</em></span><span> <img src="/jpress/static/jpress/admin/image/hands.png" alt=""><em>${content.vote_up!'0'}</em></span></div><p>${(content.getMetadataByKey("copy_right"))!}</p></div>
             <div class="readCount"><div><span>阅读 <em>${content.view_count!'0'}</em></span><span> <img src="/jpress/static/jpress/admin/image/hands.png" alt=""><em>${content.vote_up!'0'}</em></span></div><p>${(content.getMetadataByKey("copy_right"))!}</p></div>
         </div>
         </div>
         <div class="footer">
         <div class="footer">
-            <#if content.isCommentEnable() >
+            <#if content.isCommentEnable() && !(content.isUuUserReplied(userid) || (USER?? && content.isUserReplied(USER.id)))>
                 <form action="${CPATH}/comment/submit" method="post"  id="comment">
                 <form action="${CPATH}/comment/submit" method="post"  id="comment">
                     <input type="hidden" name="cid" value="${(content.id)!}" >
                     <input type="hidden" name="cid" value="${(content.id)!}" >
                     <input type="hidden" id="parent_id" name="parent_id" >
                     <input type="hidden" id="parent_id" name="parent_id" >
@@ -317,7 +317,7 @@
     timers = null;
     timers = null;
     //加载数据
     //加载数据
     var LoadingDataFn = function() {
     var LoadingDataFn = function() {
-        $.get("${CPATH}/admin/comment/lazyLoad?ucode=${ucode}&contId=${(content.id)!}&pagesize=1&pagenumber="+aa, function(result){
+        $.get("${CPATH}/admin/comment/lazyLoad?ucode=${ucode!}&contId=${(content.id)!}&pagesize=1&pagenumber="+aa, function(result){
             var dom = '';
             var dom = '';
             dom += result.message;
             dom += result.message;
             $('.footer-section').append(dom);
             $('.footer-section').append(dom);