|
@@ -192,27 +192,26 @@ public class RelationInstanceService extends BaseService {
|
|
|
|
|
|
public PagedResponse<ObjectNode> queryObject(JacksonCriteria criteria) {
|
|
|
PagedResponse response = new PagedResponse();
|
|
|
+ boolean onlyCount = criteria.isOnlyCount();
|
|
|
+ boolean withoutCount = criteria.isWithoutCount();
|
|
|
+
|
|
|
response.setCount(0L);
|
|
|
super.checkParam(response, RwdConstants.QUERY_GROUPCODE, RwdConstants.QUERY_PROJECTID);
|
|
|
if (!response.success()) {
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
- JacksonCriteria objectCriteria = JacksonCriteria.newInstance();
|
|
|
- JsonNode objectNode = criteria.getCriteria().get("objectCriteria");
|
|
|
- if (objectNode != null && objectNode.isObject()) {
|
|
|
- objectCriteria.getCriteria().setAll((ObjectNode) objectNode);
|
|
|
- }
|
|
|
-
|
|
|
+ // 第一步查关系,需要查出数据
|
|
|
+ criteria.setOnlyCount(false);
|
|
|
+ criteria.setWithoutCount(true);
|
|
|
PagedResponse<RelationInstanceModel> queryResp = query(criteria);
|
|
|
List<RelationInstanceModel> data = queryResp.getData();
|
|
|
if (data == null || data.size() == 0) {
|
|
|
- if (objectNode == null || !objectNode.isObject()) {
|
|
|
- response.setCount(queryResp.getCount());
|
|
|
- return response;
|
|
|
- }
|
|
|
+ response.setCount(queryResp.getCount());
|
|
|
+ return response;
|
|
|
}
|
|
|
|
|
|
+ // 从关系数据中整理出要查询的对象的id
|
|
|
List<String> objectIds = null;
|
|
|
if (criteria.getCriteria().has(RwdConstants.RELATION_OBJ_FROM)) {
|
|
|
objectIds = data.stream().map(RelationInstanceModel::getObjTo).collect(Collectors.toList());
|
|
@@ -222,15 +221,28 @@ public class RelationInstanceService extends BaseService {
|
|
|
if (objectIds == null || objectIds.size() == 0) {
|
|
|
return response;
|
|
|
}
|
|
|
+
|
|
|
+ // 第二步查询对象
|
|
|
+ JacksonCriteria objectCriteria = JacksonCriteria.newInstance();
|
|
|
+ JsonNode objectNode = criteria.getCriteria().get("objectCriteria");
|
|
|
+ if (objectNode != null && objectNode.isObject()) {
|
|
|
+ objectCriteria.getCriteria().setAll((ObjectNode) objectNode);
|
|
|
+ }
|
|
|
objectCriteria.add("id", objectIds);
|
|
|
+ objectCriteria.setOnlyCount(onlyCount); // 区分是否只返回统计
|
|
|
+ objectCriteria.setWithoutCount(withoutCount);
|
|
|
|
|
|
Set<String> withColumns = criteria.getWithColumns();
|
|
|
if (withColumns != null && withColumns.size() > 0) {
|
|
|
objectCriteria.setWithColumns(withColumns);
|
|
|
}
|
|
|
PagedResponse<ObjectNode> query = objectInstanceQueryService.query(objectCriteria);
|
|
|
- response.setData(query.getData());
|
|
|
- response.setCount(query.getCount());
|
|
|
+ if (!withoutCount) {
|
|
|
+ response.setCount(query.getCount());
|
|
|
+ }
|
|
|
+ if (!onlyCount) {
|
|
|
+ response.setData(query.getData());
|
|
|
+ }
|
|
|
return response;
|
|
|
}
|
|
|
|