|
|
@@ -5,6 +5,7 @@ import java.util.List;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
+import com.x.base.core.project.tools.SortTools;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
import com.google.gson.JsonElement;
|
|
|
@@ -24,11 +25,15 @@ import com.x.bbs.entity.BBSReplyInfo;
|
|
|
|
|
|
import net.sf.ehcache.Element;
|
|
|
|
|
|
+
|
|
|
+/**
|
|
|
+ * @apiNote 根据主帖的ID 返回针对主帖的回复列表(其中要包含一个标志 及说明针对该回复的回复内容条数 )
|
|
|
+ * @author O2LEE
|
|
|
+ */
|
|
|
public class ActionListWithSubjectForPage extends BaseAction {
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(ActionListWithSubjectForPage.class);
|
|
|
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
protected ActionResult<List<Wo>> execute(HttpServletRequest request, EffectivePerson effectivePerson, Integer page,
|
|
|
Integer count, JsonElement jsonElement) throws Exception {
|
|
|
ActionResult<List<Wo>> result = new ActionResult<>();
|
|
|
@@ -39,14 +44,13 @@ public class ActionListWithSubjectForPage extends BaseAction {
|
|
|
wrapIn = this.convertToWrapIn(jsonElement, Wi.class);
|
|
|
} catch (Exception e) {
|
|
|
check = false;
|
|
|
- Exception exception = new ExceptionReplyInfoProcess(e,
|
|
|
- "系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString());
|
|
|
+ Exception exception = new ExceptionReplyInfoProcess(e,"系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString());
|
|
|
result.error(exception);
|
|
|
logger.error(e, effectivePerson, request, null);
|
|
|
}
|
|
|
|
|
|
if (check) {
|
|
|
- String cacheKey = wrapIn.getSubjectId() + "#" + page + "#" + count;
|
|
|
+ String cacheKey = wrapIn.getSubjectId() + "#" + page + "#" + count + "#" + wrapIn.getNoLevel();
|
|
|
Element element = cache.get(cacheKey);
|
|
|
|
|
|
if ((null != element) && (null != element.getObjectValue())) {
|
|
|
@@ -54,7 +58,7 @@ public class ActionListWithSubjectForPage extends BaseAction {
|
|
|
result.setData(result_cache.getData());
|
|
|
result.setCount(result_cache.getCount());
|
|
|
} else {
|
|
|
- result = getReplyQueryResult(wrapIn, request, effectivePerson, page, count);
|
|
|
+ result = getReplyQueryResult( wrapIn, request, effectivePerson, page, count );
|
|
|
cache.put(new Element(cacheKey, result));
|
|
|
}
|
|
|
}
|
|
|
@@ -62,9 +66,10 @@ public class ActionListWithSubjectForPage extends BaseAction {
|
|
|
}
|
|
|
|
|
|
public ActionResult<List<Wo>> getReplyQueryResult(Wi wrapIn, HttpServletRequest request,
|
|
|
- EffectivePerson effectivePerson, Integer page, Integer count) {
|
|
|
+ EffectivePerson effectivePerson, Integer page, Integer count) throws Exception {
|
|
|
ActionResult<List<Wo>> result = new ActionResult<>();
|
|
|
List<Wo> wraps = new ArrayList<>();
|
|
|
+ List<Wo> wrapSubReplies = new ArrayList<>();
|
|
|
List<BBSReplyInfo> replyInfoList = null;
|
|
|
List<BBSReplyInfo> replyInfoList_out = new ArrayList<BBSReplyInfo>();
|
|
|
Long total = 0L;
|
|
|
@@ -86,11 +91,10 @@ public class ActionListWithSubjectForPage extends BaseAction {
|
|
|
}
|
|
|
if (check) {
|
|
|
try {
|
|
|
- total = replyInfoService.countWithSubjectForPage(wrapIn.getSubjectId());
|
|
|
+ total = replyInfoService.countWithSubjectForPage(wrapIn.getSubjectId(), wrapIn.getNoLevel() );
|
|
|
} catch (Exception e) {
|
|
|
check = false;
|
|
|
- Exception exception = new ExceptionReplyInfoProcess(e,
|
|
|
- "根据主题ID查询主题内所有的回复数量时发生异常。Subject:" + wrapIn.getSubjectId());
|
|
|
+ Exception exception = new ExceptionReplyInfoProcess(e,"根据主题ID查询主题内所有的回复数量时发生异常。Subject:" + wrapIn.getSubjectId());
|
|
|
result.error(exception);
|
|
|
logger.error(e, effectivePerson, request, null);
|
|
|
}
|
|
|
@@ -98,11 +102,10 @@ public class ActionListWithSubjectForPage extends BaseAction {
|
|
|
if (check) {
|
|
|
if (total > 0) {
|
|
|
try {
|
|
|
- replyInfoList = replyInfoService.listWithSubjectForPage(wrapIn.getSubjectId(), page * count);
|
|
|
+ replyInfoList = replyInfoService.listWithSubjectForPage( wrapIn.getSubjectId(), wrapIn.getNoLevel(), page * count );
|
|
|
} catch (Exception e) {
|
|
|
check = false;
|
|
|
- Exception exception = new ExceptionReplyInfoProcess(e,
|
|
|
- "根据主题ID查询主题内所有的回复列表时发生异常。Subject:" + wrapIn.getSubjectId());
|
|
|
+ Exception exception = new ExceptionReplyInfoProcess(e,"根据主题ID查询主题内所有的回复列表时发生异常。Subject:" + wrapIn.getSubjectId());
|
|
|
result.error(exception);
|
|
|
logger.error(e, effectivePerson, request, null);
|
|
|
}
|
|
|
@@ -119,10 +122,10 @@ public class ActionListWithSubjectForPage extends BaseAction {
|
|
|
int endIndex = page * count;
|
|
|
for (int i = 0; replyInfoList != null && i < replyInfoList.size(); i++) {
|
|
|
if (i < replyInfoList.size() && i >= startIndex && i < endIndex) {
|
|
|
- replyInfoList_out.add(replyInfoList.get(i));
|
|
|
+ replyInfoList_out.add( replyInfoList.get(i) );
|
|
|
}
|
|
|
}
|
|
|
- if (ListTools.isNotEmpty(replyInfoList_out)) {
|
|
|
+ if (ListTools.isNotEmpty( replyInfoList_out )) {
|
|
|
try {
|
|
|
wraps = Wo.copier.copy(replyInfoList_out);
|
|
|
} catch (Exception e) {
|
|
|
@@ -135,6 +138,8 @@ public class ActionListWithSubjectForPage extends BaseAction {
|
|
|
}
|
|
|
if (check) {
|
|
|
if (ListTools.isNotEmpty(wraps)) {
|
|
|
+
|
|
|
+ List<BBSReplyInfo> subReplies = null;
|
|
|
for (Wo wo : wraps) {
|
|
|
if (StringUtils.isNotEmpty(wo.getCreatorName())) {
|
|
|
wo.setCreatorNameShort(wo.getCreatorName().split("@")[0]);
|
|
|
@@ -142,11 +147,27 @@ public class ActionListWithSubjectForPage extends BaseAction {
|
|
|
if (StringUtils.isNotEmpty(wo.getAuditorName())) {
|
|
|
wo.setAuditorNameShort(wo.getAuditorName().split("@")[0]);
|
|
|
}
|
|
|
+
|
|
|
+ //查询一下该回复是否存在下级回复,以及下级回复的数量,除了第一条,其他的都去掉内容,避免大量的网络传输
|
|
|
+ subReplies = replyInfoService.listRelysWithRelyId( wo.getId() );
|
|
|
+ if( ListTools.isNotEmpty( subReplies )){
|
|
|
+ wrapSubReplies = Wo.copier.copy( subReplies );
|
|
|
+ SortTools.desc( wrapSubReplies, "createTime" );
|
|
|
+ for( int i=0; i<wrapSubReplies.size(); i++ ){
|
|
|
+ if( i > 0 ){
|
|
|
+ wrapSubReplies.get(i).setContent(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ wo.setSubReplyTotal( wrapSubReplies.size() );
|
|
|
+ wo.setSubReplies( wrapSubReplies );
|
|
|
+ }
|
|
|
}
|
|
|
+ result.setCount(total);
|
|
|
+ SortTools.desc( wraps, "createTime" );
|
|
|
}
|
|
|
}
|
|
|
result.setData(wraps);
|
|
|
- result.setCount(total);
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@@ -154,7 +175,18 @@ public class ActionListWithSubjectForPage extends BaseAction {
|
|
|
|
|
|
@FieldDescribe("主题Id")
|
|
|
private String subjectId = null;
|
|
|
-
|
|
|
+
|
|
|
+ @FieldDescribe("是否平级显示所有的的回复, 如果为true则只显示第一层")
|
|
|
+ private Boolean noLevel = false;
|
|
|
+
|
|
|
+ public Boolean getNoLevel() {
|
|
|
+ return noLevel;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setNoLevel(Boolean noLevel) {
|
|
|
+ this.noLevel = noLevel;
|
|
|
+ }
|
|
|
+
|
|
|
public static List<String> Excludes = new ArrayList<String>(JpaObject.FieldsUnmodify);
|
|
|
|
|
|
public String getSubjectId() {
|
|
|
@@ -169,8 +201,7 @@ public class ActionListWithSubjectForPage extends BaseAction {
|
|
|
public static class Wo extends BBSReplyInfo {
|
|
|
private static final long serialVersionUID = -5076990764713538973L;
|
|
|
public static List<String> Excludes = new ArrayList<String>();
|
|
|
- public static WrapCopier<BBSReplyInfo, Wo> copier = WrapCopierFactory.wo(BBSReplyInfo.class, Wo.class, null,
|
|
|
- JpaObject.FieldsInvisible);
|
|
|
+ public static WrapCopier<BBSReplyInfo, Wo> copier = WrapCopierFactory.wo(BBSReplyInfo.class, Wo.class, null, JpaObject.FieldsInvisible);
|
|
|
|
|
|
@FieldDescribe("创建人姓名")
|
|
|
private String creatorNameShort = "";
|
|
|
@@ -178,6 +209,28 @@ public class ActionListWithSubjectForPage extends BaseAction {
|
|
|
@FieldDescribe("审核人姓名")
|
|
|
private String auditorNameShort = "";
|
|
|
|
|
|
+ @FieldDescribe("下级回复的数量,默认为0")
|
|
|
+ private Integer subReplyTotal = 0;
|
|
|
+
|
|
|
+ @FieldDescribe("下级回复的数量,默认为0")
|
|
|
+ private List<Wo> subReplies;
|
|
|
+
|
|
|
+ public List<Wo> getSubReplies() {
|
|
|
+ return subReplies;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setSubReplies(List<Wo> subReplies) {
|
|
|
+ this.subReplies = subReplies;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Integer getSubReplyTotal() {
|
|
|
+ return subReplyTotal;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setSubReplyTotal(Integer subReplyTotal) {
|
|
|
+ this.subReplyTotal = subReplyTotal;
|
|
|
+ }
|
|
|
+
|
|
|
public String getCreatorNameShort() {
|
|
|
return creatorNameShort;
|
|
|
}
|