Explorar o código

调整回复查询的参数,避免前端相关的修改。通过subject查询回复的时候增加showSubReply参数来控制在同一级显示所有的回复,还是只显示第一级的回复(不显示下级回复)

o2lee %!s(int64=5) %!d(string=hai) anos
pai
achega
77286797be

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

@@ -51,14 +51,20 @@ public class BBSReplyInfoFactory extends AbstractFactory {
 		return em.createQuery( cq.where(p) ).getResultList();
 		return em.createQuery( cq.where(p) ).getResultList();
 	}
 	}
 
 
-	//@MethodDescribe( "根据主贴ID统计主贴的回复数量" )
-	public Long countBySubjectId(String subjectId, Boolean noLevel) throws Exception {
+	/**
+	 *
+	 * @param subjectId
+	 * @param showSubReply 是否平级显示所有的的回复, 如果为false则只显示第一层
+	 * @return
+	 * @throws Exception
+	 */
+	public Long countBySubjectId(String subjectId, Boolean showSubReply) throws Exception {
 		EntityManager em = this.entityManagerContainer().get( BBSReplyInfo.class );
 		EntityManager em = this.entityManagerContainer().get( BBSReplyInfo.class );
 		CriteriaBuilder cb = em.getCriteriaBuilder();
 		CriteriaBuilder cb = em.getCriteriaBuilder();
 		CriteriaQuery<Long> cq = cb.createQuery(Long.class);
 		CriteriaQuery<Long> cq = cb.createQuery(Long.class);
 		Root<BBSReplyInfo> root = cq.from( BBSReplyInfo.class);
 		Root<BBSReplyInfo> root = cq.from( BBSReplyInfo.class);
 		Predicate p = cb.equal( root.get( BBSReplyInfo_.subjectId ), subjectId );
 		Predicate p = cb.equal( root.get( BBSReplyInfo_.subjectId ), subjectId );
-		if( !noLevel ){
+		if( !showSubReply ){
 			p = cb.and( p,cb.equal(root.get( BBSReplyInfo_.parentId ), ""));
 			p = cb.and( p,cb.equal(root.get( BBSReplyInfo_.parentId ), ""));
 		}
 		}
 		cq.select( cb.count( root ) );
 		cq.select( cb.count( root ) );
@@ -87,9 +93,16 @@ public class BBSReplyInfoFactory extends AbstractFactory {
 		cq.select( cb.count( root ) );		
 		cq.select( cb.count( root ) );		
 		return em.createQuery(cq.where(p)).getSingleResult();
 		return em.createQuery(cq.where(p)).getSingleResult();
 	}
 	}
-	
-	//@MethodDescribe( "根据主题ID获取该主题所有的回复信息对象列表" )
-	public List<BBSReplyInfo> listWithSubjectForPage(String subjectId, Boolean noLevel, Integer maxCount) throws Exception {
+
+	/**
+	 *根据主题ID获取该主题所有的回复信息对象列表
+	 * @param subjectId
+	 * @param showSubReply 是否平级显示所有的的回复, 如果为false则只显示第一层
+	 * @param maxCount
+	 * @return
+	 * @throws Exception
+	 */
+	public List<BBSReplyInfo> listWithSubjectForPage(String subjectId, Boolean showSubReply, Integer maxCount) throws Exception {
 		if( subjectId == null ){
 		if( subjectId == null ){
 			throw new Exception( "subjectId can not null." );
 			throw new Exception( "subjectId can not null." );
 		}
 		}
@@ -98,7 +111,7 @@ public class BBSReplyInfoFactory extends AbstractFactory {
 		CriteriaQuery<BBSReplyInfo> cq = cb.createQuery( BBSReplyInfo.class );
 		CriteriaQuery<BBSReplyInfo> cq = cb.createQuery( BBSReplyInfo.class );
 		Root<BBSReplyInfo> root = cq.from( BBSReplyInfo.class );
 		Root<BBSReplyInfo> root = cq.from( BBSReplyInfo.class );
 		Predicate p = cb.equal( root.get( BBSReplyInfo_.subjectId ), subjectId );
 		Predicate p = cb.equal( root.get( BBSReplyInfo_.subjectId ), subjectId );
-		if( !noLevel ){
+		if( !showSubReply ){
 			p = cb.and( p, cb.equal(root.get( BBSReplyInfo_.parentId ), ""));
 			p = cb.and( p, cb.equal(root.get( BBSReplyInfo_.parentId ), ""));
 		}
 		}
 		cq.orderBy( cb.desc( root.get( BBSReplyInfo_.createTime ) ) );
 		cq.orderBy( cb.desc( root.get( BBSReplyInfo_.createTime ) ) );

+ 10 - 11
o2server/x_bbs_assemble_control/src/main/java/com/x/bbs/assemble/control/jaxrs/replyinfo/ActionListWithSubjectForPage.java

@@ -42,6 +42,9 @@ public class ActionListWithSubjectForPage extends BaseAction {
 
 
 		try {
 		try {
 			wrapIn = this.convertToWrapIn(jsonElement, Wi.class);
 			wrapIn = this.convertToWrapIn(jsonElement, Wi.class);
+			if( wrapIn.getShowSubReply() == null ){
+				wrapIn.setShowSubReply(true);
+			}
 		} catch (Exception e) {
 		} catch (Exception e) {
 			check = false;
 			check = false;
 			Exception exception = new ExceptionReplyInfoProcess(e,"系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString());
 			Exception exception = new ExceptionReplyInfoProcess(e,"系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString());
@@ -50,7 +53,7 @@ public class ActionListWithSubjectForPage extends BaseAction {
 		}
 		}
 
 
 		if (check) {
 		if (check) {
-			String cacheKey = wrapIn.getSubjectId() + "#" + page + "#" + count + "#" + wrapIn.getNoLevel();
+			String cacheKey = wrapIn.getSubjectId() + "#" + page + "#" + count + "#" + wrapIn.getShowSubReply();
 			Element element = cache.get(cacheKey);
 			Element element = cache.get(cacheKey);
 
 
 			if ((null != element) && (null != element.getObjectValue())) {
 			if ((null != element) && (null != element.getObjectValue())) {
@@ -91,7 +94,7 @@ public class ActionListWithSubjectForPage extends BaseAction {
 		}
 		}
 		if (check) {
 		if (check) {
 			try {
 			try {
-				total = replyInfoService.countWithSubjectForPage(wrapIn.getSubjectId(), wrapIn.getNoLevel() );
+				total = replyInfoService.countWithSubjectForPage(wrapIn.getSubjectId(), wrapIn.getShowSubReply() );
 			} catch (Exception e) {
 			} catch (Exception e) {
 				check = false;
 				check = false;
 				Exception exception = new ExceptionReplyInfoProcess(e,"根据主题ID查询主题内所有的回复数量时发生异常。Subject:" + wrapIn.getSubjectId());
 				Exception exception = new ExceptionReplyInfoProcess(e,"根据主题ID查询主题内所有的回复数量时发生异常。Subject:" + wrapIn.getSubjectId());
@@ -102,7 +105,7 @@ public class ActionListWithSubjectForPage extends BaseAction {
 		if (check) {
 		if (check) {
 			if (total > 0) {
 			if (total > 0) {
 				try {
 				try {
-					replyInfoList = replyInfoService.listWithSubjectForPage( wrapIn.getSubjectId(), wrapIn.getNoLevel(), page * count );
+					replyInfoList = replyInfoService.listWithSubjectForPage( wrapIn.getSubjectId(), wrapIn.getShowSubReply(), page * count );
 				} catch (Exception e) {
 				} catch (Exception e) {
 					check = false;
 					check = false;
 					Exception exception = new ExceptionReplyInfoProcess(e,"根据主题ID查询主题内所有的回复列表时发生异常。Subject:" + wrapIn.getSubjectId());
 					Exception exception = new ExceptionReplyInfoProcess(e,"根据主题ID查询主题内所有的回复列表时发生异常。Subject:" + wrapIn.getSubjectId());
@@ -176,16 +179,12 @@ public class ActionListWithSubjectForPage extends BaseAction {
 		@FieldDescribe("主题Id")
 		@FieldDescribe("主题Id")
 		private String subjectId = null;
 		private String subjectId = null;
 
 
-		@FieldDescribe("是否平级显示所有的的回复, 如果为true则只显示第一层")
-		private Boolean noLevel = false;
+		@FieldDescribe("是否平级显示所有的的回复, 如果为false则只显示第一层")
+		private Boolean showSubReply = true;
 
 
-		public Boolean getNoLevel() {
-			return noLevel;
-		}
+		public Boolean getShowSubReply() { return showSubReply; }
 
 
-		public void setNoLevel(Boolean noLevel) {
-			this.noLevel = noLevel;
-		}
+		public void setShowSubReply(Boolean showSubReply) { this.showSubReply = showSubReply; }
 
 
 		public static List<String> Excludes = new ArrayList<String>(JpaObject.FieldsUnmodify);
 		public static List<String> Excludes = new ArrayList<String>(JpaObject.FieldsUnmodify);
 
 

+ 4 - 4
o2server/x_bbs_assemble_control/src/main/java/com/x/bbs/assemble/control/service/BBSReplyInfoService.java

@@ -180,27 +180,27 @@ public class BBSReplyInfoService {
 		}
 		}
 	}
 	}
 
 
-	public List<BBSReplyInfo> listWithSubjectForPage(String subjectId, Boolean noLevel, int maxCount) throws Exception {
+	public List<BBSReplyInfo> listWithSubjectForPage(String subjectId, Boolean showSubReply, int maxCount) throws Exception {
 		if( subjectId == null ){
 		if( subjectId == null ){
 			throw new Exception( "subjectId can not null." );
 			throw new Exception( "subjectId can not null." );
 		}
 		}
 		Business business = null;
 		Business business = null;
 		try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
 		try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
 			business = new Business(emc);
 			business = new Business(emc);
-			return business.replyInfoFactory().listWithSubjectForPage( subjectId, noLevel, maxCount );
+			return business.replyInfoFactory().listWithSubjectForPage( subjectId, showSubReply, maxCount );
 		}catch( Exception e ){
 		}catch( Exception e ){
 			throw e;
 			throw e;
 		}
 		}
 	}
 	}
 	
 	
-	public Long countWithSubjectForPage(String subjectId, Boolean noLevel) throws Exception {
+	public Long countWithSubjectForPage(String subjectId, Boolean showSubReply) throws Exception {
 		if( subjectId == null ){
 		if( subjectId == null ){
 			throw new Exception( "subjectId can not null." );
 			throw new Exception( "subjectId can not null." );
 		}
 		}
 		Business business = null;
 		Business business = null;
 		try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
 		try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
 			business = new Business(emc);
 			business = new Business(emc);
-			return business.replyInfoFactory().countBySubjectId( subjectId, noLevel );
+			return business.replyInfoFactory().countBySubjectId( subjectId, showSubReply );
 		}catch( Exception e ){
 		}catch( Exception e ){
 			throw e;
 			throw e;
 		}
 		}