fix(common): pretty error msg for invalid joint filter

This commit is contained in:
ioito
2022-07-14 20:31:42 +08:00
parent 93ea09c967
commit 69ad3c12e2
+9
View File
@@ -214,6 +214,15 @@ func applyListItemsGeneralJointFilters(manager IModelManager, q *sqlchemy.SQuery
if jointModelManager == nil {
return nil, httperrors.NewResourceNotFoundError("invalid joint resources %s", jfc.GetJointModelName())
}
hasKey := false
for _, colume := range manager.TableSpec().Columns() {
if colume.Name() == jfc.OriginKey {
hasKey = true
}
}
if !hasKey {
return q, httperrors.NewInputParameterError("invalid joint filter %s, because %s doesn't have %s field", f, manager.Keyword(), jfc.OriginKey)
}
schFields := searchFields(jointModelManager, userCred)
if schFields.Contains(jfc.GetField()) {
sq := jointModelManager.Query(jfc.RelatedKey)