Просмотр исходного кода

BUG修复:企业社区贴子回复数据中上级回复标识为空时无法查询出回复数据的问题
以及主贴删除后,回复内容未删除的问题

o2lee 5 лет назад
Родитель
Сommit
5d43f73c5e

+ 11 - 2
o2server/x_bbs_assemble_control/src/main/java/com/x/bbs/assemble/control/factory/BBSReplyInfoFactory.java

@@ -64,10 +64,14 @@ public class BBSReplyInfoFactory extends AbstractFactory {
 		CriteriaQuery<Long> cq = cb.createQuery(Long.class);
 		Root<BBSReplyInfo> root = cq.from( BBSReplyInfo.class);
 		Predicate p = cb.equal( root.get( BBSReplyInfo_.subjectId ), subjectId );
+
 		if( !showSubReply ){
-			p = cb.and( p,cb.equal(root.get( BBSReplyInfo_.parentId ), ""));
+			Predicate p_showSubReply = cb.isNull( root.get( BBSReplyInfo_.parentId ));
+			p_showSubReply = cb.or( p_showSubReply, cb.equal( root.get( BBSReplyInfo_.parentId), ""));
+			p = cb.and( p, p_showSubReply);
 		}
 		cq.select( cb.count( root ) );
+//		System.out.println( ">>>>>SQL:" + em.createQuery(cq.where(p)).toString() );
 		return em.createQuery(cq.where(p)).getSingleResult();
 	}
 	
@@ -112,12 +116,17 @@ public class BBSReplyInfoFactory extends AbstractFactory {
 		Root<BBSReplyInfo> root = cq.from( BBSReplyInfo.class );
 		Predicate p = cb.equal( root.get( BBSReplyInfo_.subjectId ), subjectId );
 		if( !showSubReply ){
-			p = cb.and( p, cb.equal(root.get( BBSReplyInfo_.parentId ), ""));
+			Predicate p_showSubReply = cb.isNull( root.get( BBSReplyInfo_.parentId ));
+			p_showSubReply = cb.or( p_showSubReply, cb.equal( root.get( BBSReplyInfo_.parentId), ""));
+			p = cb.and( p, p_showSubReply);
 		}
+
 		cq.orderBy( cb.desc( root.get( BBSReplyInfo_.createTime ) ) );
 		if( maxCount == null ){
+//			System.out.println( ">>>>>SQL:" + em.createQuery(cq.where(p)).toString() );
 			return em.createQuery(cq.where(p)).getResultList();
 		}else{
+//			System.out.println( ">>>>>SQL:" + em.createQuery(cq.where(p)).setMaxResults( maxCount ).toString() );
 			return em.createQuery(cq.where(p)).setMaxResults( maxCount ).getResultList();
 		}
 	}

+ 1 - 0
o2server/x_bbs_assemble_control/src/main/java/com/x/bbs/assemble/control/service/BBSSubjectInfoService.java

@@ -245,6 +245,7 @@ public class BBSSubjectInfoService {
 		emc.beginTransaction( BBSSectionInfo.class );
 		emc.beginTransaction( BBSSubjectInfo.class );
 		emc.beginTransaction( BBSSubjectContent.class );
+		emc.beginTransaction( BBSReplyInfo.class );
 		emc.beginTransaction( BBSVoteOption.class );
 		emc.beginTransaction( BBSVoteOptionGroup.class );
 		emc.beginTransaction( BBSVoteRecord.class );

+ 1 - 1
o2server/x_bbs_assemble_control/src/main/java/com/x/bbs/assemble/control/service/BBSSubjectInfoServiceAdv.java

@@ -114,7 +114,7 @@ public class BBSSubjectInfoServiceAdv {
 	 * 3、论坛主题数量-1
 	 * 4、版块回复数量-n,如果有主版块,主版块回复数量-n
 	 * 5、论坛回复数量-n
-	 * @param id
+	 * @param subjectId
 	 * @throws Exception
 	 */
 	public void delete( String subjectId ) throws Exception {