提交 6fe023ca 编写于 作者: O o2null

Merge branch '内容管理返回评论列表中增加是否点赞' into 'develop'

内容管理返回评论列表中增加是否点赞

See merge request o2oa/o2oa!329
......@@ -14,88 +14,86 @@ import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.cms.core.entity.DocumentCommentInfo;
import com.x.cms.core.express.tools.filter.QueryFilter;
import net.sf.ehcache.Element;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* 文档评论分页查询
* @author sword
*/
public class ActionListPageWithFilter extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionListPageWithFilter.class);
protected ActionResult<List<Wo>> execute( HttpServletRequest request, EffectivePerson effectivePerson, Integer pageNum, Integer count, JsonElement jsonElement ) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wos = new ArrayList<>();
ResultObject resultObject = null;
Wi wrapIn = null;
Boolean check = true;
Element element = null;
QueryFilter queryFilter = null;
try {
wrapIn = this.convertToWrapIn(jsonElement, Wi.class);
} catch (Exception e) {
check = false;
Exception exception = new ExceptionCommentQuery(e, "系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString());
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
if( check ) {
queryFilter = wrapIn.getQueryFilter();
}
if( check ) {
Cache.CacheKey cacheKey = new Cache.CacheKey( this.getClass(), effectivePerson.getDistinguishedName(),
pageNum, count, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter.getContentSHA1() );
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey );
if (optional.isPresent()) {
resultObject = (ResultObject)optional.get();
result.setCount( resultObject.getTotal() );
result.setData( resultObject.getWos() );
} else {
try {
Long total = documentCommentInfoQueryService.countWithFilter(effectivePerson, queryFilter );
List<DocumentCommentInfo> documentCommentInfoList = documentCommentInfoQueryService.listWithFilter( effectivePerson, count, pageNum, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter);
if( ListTools.isNotEmpty( documentCommentInfoList )) {
for( DocumentCommentInfo documentCommentInfo : documentCommentInfoList ) {
Wo wo = Wo.copier.copy(documentCommentInfo);
wo.setContent( documentCommentInfoQueryService.getCommentContent(documentCommentInfo.getId() ));
wos.add( wo );
Wi wrapIn = this.convertToWrapIn(jsonElement, Wi.class);
QueryFilter queryFilter = wrapIn.getQueryFilter();
Cache.CacheKey cacheKey = new Cache.CacheKey( this.getClass(), effectivePerson.getDistinguishedName(),
pageNum, count, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter.getContentSHA1() );
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey );
if (optional.isPresent()) {
resultObject = (ResultObject)optional.get();
result.setCount( resultObject.getTotal() );
result.setData( resultObject.getWos() );
} else {
try {
Long total = documentCommentInfoQueryService.countWithFilter(effectivePerson, queryFilter );
List<DocumentCommentInfo> documentCommentInfoList = documentCommentInfoQueryService.listWithFilter( effectivePerson, count, pageNum, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter);
if( ListTools.isNotEmpty( documentCommentInfoList )) {
for( DocumentCommentInfo documentCommentInfo : documentCommentInfoList ) {
Wo wo = Wo.copier.copy(documentCommentInfo);
wo.setContent( documentCommentInfoQueryService.getCommentContent(documentCommentInfo.getId()));
if(ListTools.isNotEmpty(docCommendQueryService.listByCommentAndPerson(documentCommentInfo.getId(), effectivePerson.getDistinguishedName(), 1))){
wo.setIsCommend(true);
}else{
wo.setIsCommend(false);
}
wos.add( wo );
}
resultObject = new ResultObject( total, wos );
CacheManager.put(cacheCategory, cacheKey, resultObject );
result.setCount( resultObject.getTotal() );
result.setData( resultObject.getWos() );
} catch (Exception e) {
check = false;
logger.warn("系统查询评论信息列表时发生异常!");
result.error(e);
logger.error(e, effectivePerson, request, null);
}
}
resultObject = new ResultObject( total, wos );
CacheManager.put(cacheCategory, cacheKey, resultObject );
result.setCount( resultObject.getTotal() );
result.setData( resultObject.getWos() );
} catch (Exception e) {
logger.warn("系统查询评论信息列表时发生异常!");
result.error(e);
logger.error(e, effectivePerson, request, null);
}
}
return result;
}
public static class Wi extends WrapInQueryDocumentCommentInfo{
}
public static class Wo extends DocumentCommentInfo {
private Long rank;
private static final long serialVersionUID = -5076990764713538973L;
static WrapCopier<DocumentCommentInfo, Wo> copier = WrapCopierFactory.wo( DocumentCommentInfo.class, Wo.class, null, ListTools.toList(JpaObject.FieldsInvisible));
private Long rank;
@FieldDescribe("内容")
private String content = "";
@FieldDescribe( "评论是否已被当前用户点赞." )
private Boolean isCommend = false;
public String getContent() {
return content;
}
......@@ -103,7 +101,7 @@ public class ActionListPageWithFilter extends BaseAction {
public void setContent(String content) {
this.content = content;
}
public Long getRank() {
return rank;
}
......@@ -112,22 +110,24 @@ public class ActionListPageWithFilter extends BaseAction {
this.rank = rank;
}
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
public Boolean getIsCommend() {
return isCommend;
}
static WrapCopier<DocumentCommentInfo, Wo> copier = WrapCopierFactory.wo( DocumentCommentInfo.class, Wo.class, null, ListTools.toList(JpaObject.FieldsInvisible));
public void setIsCommend(Boolean isCommend) {
this.isCommend = isCommend;
}
}
public static class ResultObject {
private Long total;
private List<Wo> wos;
public ResultObject() {}
public ResultObject(Long count, List<Wo> data) {
this.total = count;
this.wos = data;
......@@ -149,4 +149,4 @@ public class ActionListPageWithFilter extends BaseAction {
this.wos = wos;
}
}
}
\ No newline at end of file
}
......@@ -22,6 +22,7 @@ public class BaseAction extends StandardJaxrsAction {
protected DocumentQueryService documentInfoServiceAdv = new DocumentQueryService();
protected CommentCommendPersistService commentCommendPersistService = new CommentCommendPersistService();
protected DocCommendQueryService docCommendQueryService = new DocCommendQueryService();
protected DocCommendPersistService docCommendPersistService = new DocCommendPersistService();
}
......@@ -12,6 +12,7 @@ import com.x.base.core.project.cache.Cache;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.cms.assemble.control.Business;
import com.x.cms.core.entity.*;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.entity.JpaObject;
......@@ -25,10 +26,6 @@ import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.cms.assemble.control.ThisApplication;
import com.x.cms.core.entity.AppInfo;
import com.x.cms.core.entity.CategoryInfo;
import com.x.cms.core.entity.Document;
import com.x.cms.core.entity.Log;
import com.x.cms.core.entity.content.Data;
import com.x.cms.core.entity.element.Form;
......@@ -338,6 +335,10 @@ public class ActionQueryViewDocument extends BaseAction {
}
}
if(ListTools.isNotEmpty(docCommendQueryService.listByDocAndPerson(id, effectivePerson.getDistinguishedName(), 1, DocumentCommend.COMMEND_TYPE_DOCUMENT))){
wo.setIsCommend(true);
}
wo.setIsManager( isManager );
wo.setIsAppAdmin( isAppAdmin );
wo.setIsCategoryAdmin( isCategoryAdmin );
......@@ -367,12 +368,16 @@ public class ActionQueryViewDocument extends BaseAction {
@FieldDescribe( "作为查看的CMS文档表单." )
private WoForm readForm;
@FieldDescribe( "文档是否已被当前用户点赞." )
private Boolean isCommend = false;
private Boolean isAppAdmin = false;
private Boolean isCategoryAdmin = false;
private Boolean isManager = false;
private Boolean isCreator = false;
private Boolean isEditor = false;
public WoDocument getDocument() {
return document;
}
......@@ -381,14 +386,6 @@ public class ActionQueryViewDocument extends BaseAction {
this.document = document;
}
// public List<WoFileInfo> getAttachmentList() {
// return attachmentList;
// }
//
// public void setAttachmentList(List<WoFileInfo> attachmentList) {
// this.attachmentList = attachmentList;
// }
public List<WoLog> getDocumentLogList() {
return documentLogList;
}
......@@ -461,6 +458,13 @@ public class ActionQueryViewDocument extends BaseAction {
this.isCreator = isCreator;
}
public Boolean getIsCommend() {
return isCommend;
}
public void setIsCommend(Boolean isCommend) {
this.isCommend = isCommend;
}
}
public static class WoDocument extends Document {
......
......@@ -13,18 +13,7 @@ import com.x.base.core.project.organization.Person;
import com.x.base.core.project.tools.ListTools;
import com.x.cms.assemble.control.Business;
import com.x.cms.assemble.control.ThisApplication;
import com.x.cms.assemble.control.service.AppInfoServiceAdv;
import com.x.cms.assemble.control.service.CategoryInfoServiceAdv;
import com.x.cms.assemble.control.service.DocCommendPersistService;
import com.x.cms.assemble.control.service.DocumentPersistService;
import com.x.cms.assemble.control.service.DocumentQueryService;
import com.x.cms.assemble.control.service.DocumentViewRecordServiceAdv;
import com.x.cms.assemble.control.service.FileInfoServiceAdv;
import com.x.cms.assemble.control.service.FormServiceAdv;
import com.x.cms.assemble.control.service.LogService;
import com.x.cms.assemble.control.service.PermissionQueryService;
import com.x.cms.assemble.control.service.QueryViewService;
import com.x.cms.assemble.control.service.UserManagerService;
import com.x.cms.assemble.control.service.*;
import com.x.cms.core.entity.*;
import com.x.query.core.entity.Item;
import org.apache.commons.lang3.StringUtils;
......@@ -40,6 +29,7 @@ public class BaseAction extends StandardJaxrsAction {
protected DocumentQueryService documentQueryService = new DocumentQueryService();
protected DocCommendPersistService docCommendPersistService = new DocCommendPersistService();
protected DocCommendQueryService docCommendQueryService = new DocCommendQueryService();
protected FormServiceAdv formServiceAdv = new FormServiceAdv();
protected CategoryInfoServiceAdv categoryInfoServiceAdv = new CategoryInfoServiceAdv();
......
......@@ -30,6 +30,20 @@ public class DocCommendQueryService {
}
}
public List<String> listByCommentAndPerson(String commentId, String personName, Integer maxCount) throws Exception {
if( StringUtils.isEmpty( commentId ) ){
return null;
}
if( StringUtils.isEmpty( personName ) ){
return null;
}
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
return docCommendService.listByCommentAndPerson(emc, commentId, personName, maxCount);
} catch ( Exception e ) {
throw e;
}
}
public List<String> listByDocument( String docId, Integer maxCount, String type) throws Exception {
if( StringUtils.isEmpty( docId ) ){
return null;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册