提交 1838e2e2 编写于 作者: O o2null

Merge branch 'fix/bbs#414' into 'wrdp'

listSubjectForPage方法增加日期条件查询

See merge request o2oa/o2oa!2286
......@@ -55,7 +55,7 @@ public class BBSSubjectInfoFactory extends AbstractFactory {
}
//@MethodDescribe( "根据版块信息查询所有需要展现的所有置顶主题列表" )
public List<String> listAllTopSubject( String forumId, String mainSectionId, String sectionId, String creatorName ) throws Exception {
public List<String> listAllTopSubject( String forumId, String mainSectionId, String sectionId, String creatorName, Date startTime , Date endTime ) throws Exception {
if( forumId == null || forumId.isEmpty() ){
throw new Exception( "forumId is null!" );
}
......@@ -71,6 +71,14 @@ public class BBSSubjectInfoFactory extends AbstractFactory {
p = cb.and( p, cb.equal( root.get( BBSSubjectInfo_.creatorName ), creatorName ) );
}
if(startTime!= null) {
p = cb.and(p, cb.greaterThanOrEqualTo(root.get(BBSSubjectInfo_.createTime), startTime));
}
if(endTime!= null) {
p = cb.and(p, cb.lessThanOrEqualTo(root.get(BBSSubjectInfo_.createTime), endTime));
}
Predicate top_or = null;
Predicate top_toforum_or = null;
Predicate top_tomainsection_or = null;
......@@ -101,6 +109,8 @@ public class BBSSubjectInfoFactory extends AbstractFactory {
}
}
if( top_or != null ){
p = cb.and( p, top_or );
}
......
package com.x.bbs.assemble.control.jaxrs.subjectinfo;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -138,7 +139,7 @@ public class ActionSubjectListForPage extends BaseAction {
//查询出所有的置顶贴
if ( check && wrapIn != null && wrapIn.getWithTopSubject() != null && wrapIn.getWithTopSubject() ) {
try {
subjectInfoList_top = subjectInfoServiceAdv.listAllTopSubject( sectionInfo, wrapIn.getCreatorName(), viewSectionIds );
subjectInfoList_top = subjectInfoServiceAdv.listAllTopSubject( sectionInfo, wrapIn.getCreatorName(), viewSectionIds ,wrapIn.getStartTime() , wrapIn.getEndTime());
if( subjectInfoList_top != null ){
topTotal = subjectInfoList_top.size();
try {
......@@ -173,7 +174,8 @@ public class ActionSubjectListForPage extends BaseAction {
selectTopInSection = false; //置顶贴的处理已经在前面处理过了,置顶贴已经放到一个List里,不需要再次查询出来了,后续的查询过滤置顶贴
if( selectTotal > 0 ){
try{
total = subjectInfoServiceAdv.countSubjectInSectionForPage( wrapIn.getSearchContent(), wrapIn.getForumId(), wrapIn.getMainSectionId(), wrapIn.getSectionId(), wrapIn.getCreatorName(), wrapIn.getNeedPicture(), selectTopInSection, viewSectionIds ,wrapIn.getStartTime() , wrapIn.getEndTime());
total = subjectInfoServiceAdv.countSubjectInSectionForPage( wrapIn.getSearchContent(), wrapIn.getForumId(), wrapIn.getMainSectionId(), wrapIn.getSectionId(),
wrapIn.getCreatorName(), wrapIn.getNeedPicture(), selectTopInSection, viewSectionIds ,wrapIn.getStartTime() , wrapIn.getEndTime());
} catch (Exception e) {
check = false;
Exception exception = new ExceptionSubjectFilter( e );
......@@ -378,6 +380,8 @@ public class ActionSubjectListForPage extends BaseAction {
public String getCacheKey(EffectivePerson effectivePerson, Boolean isBBSManager) {
StringBuffer sb = new StringBuffer();
String pattern = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
if( StringUtils.isNotEmpty( effectivePerson.getDistinguishedName() )) {
sb.append( effectivePerson.getDistinguishedName() );
}
......@@ -413,6 +417,16 @@ public class ActionSubjectListForPage extends BaseAction {
sb.append( "#" );
sb.append( creatorName );
}
if( startTime != null ) {
sb.append( "#" );
sb.append( formatter.format(startTime));
}
if( endTime != null ) {
sb.append( "#" );
sb.append( formatter.format(endTime));
}
sb.append( "#" );
sb.append( needPicture );
sb.append( "#" );
......
......@@ -76,7 +76,7 @@ public class ActionSubjectListTop extends BaseAction {
}
if (check) {
try {
subjectInfoList = subjectInfoServiceAdv.listAllTopSubject(sectionInfo, null, viewSectionIds);
subjectInfoList = subjectInfoServiceAdv.listAllTopSubject(sectionInfo, null, viewSectionIds,null,null);
} catch (Exception e) {
check = false;
Exception exception = new ExceptionSubjectFilter(e);
......
......@@ -399,7 +399,7 @@ public class BBSSubjectInfoService {
* @return
* @throws Exception
*/
public List<BBSSubjectInfo> listAllTopSubject( EntityManagerContainer emc, BBSSectionInfo sectionInfo, String creatorName, List<String> viewSectionIds ) throws Exception {
public List<BBSSubjectInfo> listAllTopSubject( EntityManagerContainer emc, BBSSectionInfo sectionInfo, String creatorName, List<String> viewSectionIds ,Date startTime , Date endTime ) throws Exception {
String forumId = null;
String mainSectionId = null;
String sectionId = null;
......@@ -417,7 +417,7 @@ public class BBSSubjectInfoService {
Business business = null;
List<String> ids = null;
business = new Business( emc );
ids = business.subjectInfoFactory().listAllTopSubject( forumId, mainSectionId, sectionId, creatorName );
ids = business.subjectInfoFactory().listAllTopSubject( forumId, mainSectionId, sectionId, creatorName , startTime , endTime );
if( ListTools.isNotEmpty( ids ) ){
return business.subjectInfoFactory().list( ids );
}
......
......@@ -160,12 +160,12 @@ public class BBSSubjectInfoServiceAdv {
* @return
* @throws Exception
*/
public List<BBSSubjectInfo> listAllTopSubject( BBSSectionInfo sectionInfo, String creatorName, List<String> viewSectionIds ) throws Exception {
public List<BBSSubjectInfo> listAllTopSubject( BBSSectionInfo sectionInfo, String creatorName, List<String> viewSectionIds , Date startTime , Date endTime ) throws Exception {
if( sectionInfo == null ){
throw new Exception( "sectionInfo is null." );
}
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
return subjectInfoService.listAllTopSubject( emc, sectionInfo, creatorName, viewSectionIds );
return subjectInfoService.listAllTopSubject( emc, sectionInfo, creatorName, viewSectionIds , startTime , endTime);
}catch( Exception e ){
throw e;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册