Explorar el Código

Merge branch 'feature/BBS.addMyReplySortTypeConfig' into 'develop'

Merge of feature/BBS.addMyReplySortTypeConfigBBS添加控制我的回贴列表排序方式的配置项

See merge request o2oa/o2oa!251
李义 hace 5 años
padre
commit
5b79d2e293

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

@@ -198,7 +198,7 @@ public class BBSReplyInfoFactory extends AbstractFactory {
 	}
 
 	//@MethodDescribe( "根据指定用户姓名、论坛ID,主版块ID, 版块ID查询符合条件的所有回复对象列表" )
-	public List<BBSReplyInfo> listReplyForPage( String creatorName, String forumId, String mainSectionId, String sectionId, String subjectId, Integer maxCount ) throws Exception {
+	public List<BBSReplyInfo> listReplyForPage( String creatorName, String forumId, String mainSectionId, String sectionId, String subjectId, String orderType, Integer maxCount ) throws Exception {
 		Boolean allFilterNull = true;
 		if( StringUtils.isNotEmpty( creatorName ) ){
 			allFilterNull = false;
@@ -241,7 +241,11 @@ public class BBSReplyInfoFactory extends AbstractFactory {
 		if( StringUtils.isNotEmpty( subjectId ) ){
 			p = cb.and( p, cb.equal( root.get( BBSReplyInfo_.subjectId ), subjectId ) );
 		}
-		cq.orderBy( cb.asc( root.get( BBSReplyInfo_.orderNumber ) ) );
+		if( StringUtils.equalsIgnoreCase(orderType, "DESC")){
+			cq.orderBy( cb.desc( root.get( BBSReplyInfo_.createTime ) ) );
+		}else{
+			cq.orderBy( cb.asc( root.get( BBSReplyInfo_.createTime ) ) );
+		}
 		return em.createQuery(cq.where(p)).setMaxResults( maxCount ).getResultList();
 	}
 	

+ 2 - 1
o2server/x_bbs_assemble_control/src/main/java/com/x/bbs/assemble/control/jaxrs/replyinfo/ActionListMyReplyForPages.java

@@ -33,6 +33,7 @@ public class ActionListMyReplyForPages extends BaseAction {
 		List<BBSReplyInfo> replyInfoList_out = new ArrayList<BBSReplyInfo>();
 		Long total = 0L;
 		Boolean check = true;
+		String config_BBS_MYREPLY_SORTTYPE = configSettingService.getValueWithConfigCode("BBS_MYREPLY_SORTTYPE");
 
 		if (check) {
 			if (page == null) {
@@ -62,7 +63,7 @@ public class ActionListMyReplyForPages extends BaseAction {
 		if (check) {
 			if (total > 0) {
 				try {
-					replyInfoList = replyInfoService.listReplyByUserNameForPage(effectivePerson.getDistinguishedName(),
+					replyInfoList = replyInfoService.listReplyByUserNameForPage(effectivePerson.getDistinguishedName(), config_BBS_MYREPLY_SORTTYPE,
 							page * count);
 				} catch (Exception e) {
 					check = false;

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

@@ -305,5 +305,17 @@ public class BBSConfigSettingService{
 			logger.warn( "system init system config 'BBS_REPLY_SORTTYPE' got an exception." );
 			logger.error(e);
 		}
+
+		value = "DESC";
+		type = "select";
+		selectContent = "ASC|DESC";
+		isMultiple = false;
+		description = "我的回贴列表排序模式:可选值:ASC|DESC, 按创建时间正序|倒序,单选。";
+		try {
+			checkAndInitSystemConfig("BBS_MYREPLY_SORTTYPE", "我的回贴排序模式", value, description, type, selectContent, isMultiple, ++ordernumber );
+		} catch (Exception e) {
+			logger.warn( "system init system config 'BBS_MYREPLY_SORTTYPE' got an exception." );
+			logger.error(e);
+		}
 	}
 }

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

@@ -226,14 +226,14 @@ public class BBSReplyInfoService {
 		}
 	}
 
-	public List<BBSReplyInfo> listReplyByUserNameForPage(String creatorName, int maxCount ) throws Exception {
+	public List<BBSReplyInfo> listReplyByUserNameForPage(String creatorName, String orderType, int maxCount ) throws Exception {
 		if( creatorName == null ){
 			throw new Exception( "creatorName can not null." );
 		}
 		Business business = null;
 		try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
 			business = new Business(emc);
-			return business.replyInfoFactory().listReplyForPage( creatorName, null, null, null, null, maxCount );
+			return business.replyInfoFactory().listReplyForPage( creatorName, null, null, null, null, orderType, maxCount );
 		}catch( Exception e ){
 			throw e;
 		}