|
@@ -12,9 +12,11 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.persagy.dmp.basic.model.QueryCriteria;
|
|
|
import com.persagy.dmp.basic.model.QueryOperator;
|
|
|
import com.persagy.dmp.basic.utils.JsonNodeUtils;
|
|
|
+import com.persagy.dmp.common.constant.ValidEnum;
|
|
|
import com.persagy.dmp.common.model.entity.BaseEntity;
|
|
|
import com.persagy.dmp.digital.entity.ObjectDigital;
|
|
|
import com.persagy.dmp.digital.entity.ObjectRelation;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
@@ -251,6 +253,10 @@ public class ObjectDigitalCriteriaHelper {
|
|
|
* @param isFrom
|
|
|
*/
|
|
|
private static void ensureRelationIds(ObjectNode criteria, boolean isFrom) {
|
|
|
+
|
|
|
+
|
|
|
+ criteria.put("valid", ValidEnum.TRUE.getType());
|
|
|
+ }*/
|
|
|
String flagKey = isFrom ? QueryOperator.RELATION_FROM.getIndex() : QueryOperator.RELATION_TO.getIndex();
|
|
|
String selectKey = isFrom ? ObjectRelation.OBJ_FROM : ObjectRelation.OBJ_TO;
|
|
|
String whereKey = isFrom ? "objTo" : "objFrom";
|
|
@@ -259,6 +265,12 @@ public class ObjectDigitalCriteriaHelper {
|
|
|
if(relationCond == null || relationCond.size() <= 0 || !relationCond.isObject()) {
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ ObjectNode jsonNode = (ObjectNode) relationCond;
|
|
|
+ if(jsonNode.get("valid") == null){
|
|
|
+ jsonNode.put("valid",ValidEnum.TRUE.getType());
|
|
|
+ relationCond = jsonNode;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
QueryWrapper<ObjectRelation> wrapper = new QueryWrapper<>();
|
|
@@ -283,6 +295,7 @@ public class ObjectDigitalCriteriaHelper {
|
|
|
addWhereCond(relationCond, inSql, "graphId");
|
|
|
addWhereCond(relationCond, inSql, "graphCode");
|
|
|
addWhereCond(relationCond, inSql, "relCode");
|
|
|
+ addObjectWhereCond(relationCond, inSql, "valid");
|
|
|
addWhereCond(relationCond, inSql, whereKey);
|
|
|
inSql.append(")");
|
|
|
ObjectNode inObj = criteria.putObject(BaseEntity.PROP_ID);
|
|
@@ -304,4 +317,18 @@ public class ObjectDigitalCriteriaHelper {
|
|
|
inSql.append("and " + column + " = '" + value + "' ");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ * 添加where条件
|
|
|
+ * @param node json对象
|
|
|
+ * @param inSql in条件
|
|
|
+ * @param field 属性名
|
|
|
+ */
|
|
|
+ private static void addObjectWhereCond(JsonNode node, StringBuilder inSql, String field) {
|
|
|
+ Object nodeValue = JsonNodeUtils.getNodeValue(node.get(field));
|
|
|
+ if(nodeValue != null) {
|
|
|
+ String column = StrUtil.toUnderlineCase(field);
|
|
|
+ inSql.append("and " + column + " = " + nodeValue + " ");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|