From 3db7d1c4ab84078dcc03485ac8b14cde812f5399 Mon Sep 17 00:00:00 2001 From: o2sword <171715986@qq.com> Date: Thu, 5 Nov 2020 14:29:43 +0800 Subject: [PATCH] =?UTF-8?q?cms=E5=A2=9E=E5=8A=A0=E6=A0=B9=E6=8D=AEid?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2doc=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=8E=A5=E5=8F=A32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/ActionQueryListDocumentData.java | 54 ++++++++----------- 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionQueryListDocumentData.java b/o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionQueryListDocumentData.java index a84b270fa1..034dd84980 100644 --- a/o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionQueryListDocumentData.java +++ b/o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionQueryListDocumentData.java @@ -35,50 +35,38 @@ public class ActionQueryListDocumentData extends BaseAction { business = new Business(emc); } List wos = new ArrayList<>(); - if(wi.getDocIds()!=null) { - List unitNames = userManagerService.listUnitNamesWithPerson(effectivePerson.getDistinguishedName()); - List groupNames = userManagerService.listGroupNamesByPerson(effectivePerson.getDistinguishedName()); - for(String id : wi.getDocIds()){ - Cache.CacheKey cacheKey = new Cache.CacheKey(this.getClass(), id, effectivePerson.getDistinguishedName()); - Optional optional = CacheManager.get(cacheCategory, cacheKey); - if (optional.isPresent()) { - wos.add((Wo)optional.get()); - } else { - Wo wo = getDocumentQueryResult(business,id, effectivePerson, unitNames, groupNames); - if(wo != null) { - wos.add(wo); - CacheManager.put(cacheCategory, cacheKey, wo); - } - } - } + if(wi.getDocIds()!=null && !wi.getDocIds().isEmpty()) { + wos = getDocumentQueryResult(business, wi.getDocIds(), effectivePerson); } result.setData(wos); return result; } - /** - * 获取需要返回的文档信息对象 - * @param id - * @param effectivePerson - * @return - */ - private Wo getDocumentQueryResult(Business business, String id, EffectivePerson effectivePerson, List unitNames, List groupNames) throws Exception { - Wo wo = new Wo(); - Document document = documentQueryService.view( id, effectivePerson ); - if ( document != null ){ + private List getDocumentQueryResult(Business business, List ids, EffectivePerson effectivePerson) throws Exception { + List wos = new ArrayList<>(); + Wo wo = null; + List docs = documentQueryService.list(ids); + List unitNames = userManagerService.listUnitNamesWithPerson(effectivePerson.getDistinguishedName()); + List groupNames = userManagerService.listGroupNamesByPerson(effectivePerson.getDistinguishedName()); + for (Document document : docs){ if(this.hasReadPermission(business, document, unitNames, groupNames, effectivePerson, null)) { - WoDocument woOutDocument = WoDocument.copier.copy(document); - wo.setDocId(id); - wo.setDocument(woOutDocument); - if (woOutDocument != null) { + Cache.CacheKey cacheKey = new Cache.CacheKey(this.getClass(), document.getId()); + Optional optional = CacheManager.get(cacheCategory, cacheKey); + if (optional.isPresent()) { + wo = (Wo)optional.get(); + } else { + wo = new Wo(); + WoDocument woOutDocument = WoDocument.copier.copy(document); + wo.setDocId(document.getId()); + wo.setDocument(woOutDocument); wo.setData(documentQueryService.getDocumentData(document)); + CacheManager.put(cacheCategory, cacheKey, wo); } - }else{ - return null; + wos.add(wo); } } - return wo; + return wos; } public static class Wo extends GsonPropertyObject { -- GitLab