getRelevantIds原来的逻辑有问题,已修正
This commit is contained in:
parent
2bcecfc4f7
commit
d7ebc7bd9a
|
|
@ -31,12 +31,12 @@ exports.desc = {
|
||||||
name: 'index_entity_relation',
|
name: 'index_entity_relation',
|
||||||
attributes: [
|
attributes: [
|
||||||
{
|
{
|
||||||
name: 'destEntity',
|
name: 'destEntity'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "relationId",
|
name: "relationId"
|
||||||
},
|
},
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -45,15 +45,15 @@ exports.desc = {
|
||||||
name: 'namespace_language',
|
name: 'namespace_language',
|
||||||
attributes: [
|
attributes: [
|
||||||
{
|
{
|
||||||
name: 'namespace',
|
name: 'namespace'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'language',
|
name: 'language'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
config: {
|
config: {
|
||||||
unique: true,
|
unique: true
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@ exports.ActionDefDict = exports.actions = void 0;
|
||||||
const IActionDef = {
|
const IActionDef = {
|
||||||
stm: {
|
stm: {
|
||||||
apply: ['active', 'applied'],
|
apply: ['active', 'applied'],
|
||||||
abandon: ['active', 'abandoned'],
|
abandon: ['active', 'abandoned']
|
||||||
},
|
},
|
||||||
is: 'active',
|
is: 'active'
|
||||||
};
|
};
|
||||||
exports.actions = ["count", "stat", "download", "select", "aggregate", "create", "remove", "update", "apply", "abandon"];
|
exports.actions = ["count", "stat", "download", "select", "aggregate", "create", "remove", "update", "apply", "abandon"];
|
||||||
exports.ActionDefDict = {
|
exports.ActionDefDict = {
|
||||||
|
|
|
||||||
|
|
@ -55,9 +55,9 @@ exports.desc = {
|
||||||
attributes: [
|
attributes: [
|
||||||
{
|
{
|
||||||
name: 'iState',
|
name: 'iState',
|
||||||
direction: 'ASC',
|
direction: 'ASC'
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -37,18 +37,18 @@ exports.desc = {
|
||||||
name: 'index_targetEntity_entityId_name',
|
name: 'index_targetEntity_entityId_name',
|
||||||
attributes: [
|
attributes: [
|
||||||
{
|
{
|
||||||
name: 'entity',
|
name: 'entity'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'entityId',
|
name: 'entityId'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'name',
|
name: 'name'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
config: {
|
config: {
|
||||||
unique: true,
|
unique: true
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -29,18 +29,18 @@ exports.desc = {
|
||||||
name: 'index_entity_relation_path',
|
name: 'index_entity_relation_path',
|
||||||
attributes: [
|
attributes: [
|
||||||
{
|
{
|
||||||
name: "sourceRelationId",
|
name: "sourceRelationId"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'path',
|
name: 'path'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "destRelationId",
|
name: "destRelationId"
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
config: {
|
config: {
|
||||||
unique: true,
|
unique: true
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ exports.ActionDefDict = exports.actions = void 0;
|
||||||
exports.actions = ["count", "stat", "download", "select", "aggregate", "create", "remove", "update", "grant", "revoke", "mergeTo"];
|
exports.actions = ["count", "stat", "download", "select", "aggregate", "create", "remove", "update", "grant", "revoke", "mergeTo"];
|
||||||
const UserActionDef = {
|
const UserActionDef = {
|
||||||
stm: {
|
stm: {
|
||||||
mergeTo: ['normal', 'merged'],
|
mergeTo: ['normal', 'merged']
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
exports.ActionDefDict = {
|
exports.ActionDefDict = {
|
||||||
userState: UserActionDef
|
userState: UserActionDef
|
||||||
|
|
|
||||||
|
|
@ -36,21 +36,21 @@ exports.desc = {
|
||||||
name: 'index_user_entity_entityId_relation',
|
name: 'index_user_entity_entityId_relation',
|
||||||
attributes: [
|
attributes: [
|
||||||
{
|
{
|
||||||
name: "userId",
|
name: "userId"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'entity',
|
name: 'entity'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'entityId',
|
name: 'entityId'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "relationId",
|
name: "relationId"
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
config: {
|
config: {
|
||||||
unique: true,
|
unique: true
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1322,22 +1322,33 @@ function getRelevantIds(filter) {
|
||||||
}
|
}
|
||||||
if (filter?.$and) {
|
if (filter?.$and) {
|
||||||
const idss = filter.$and.map((ele) => getRelevantIds(ele));
|
const idss = filter.$and.map((ele) => getRelevantIds(ele));
|
||||||
|
// and有一个不能判断就返回空集
|
||||||
|
if (idss.find(ele => ele.length === 0)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
idsAnd = (0, lodash_1.intersection)(...idss);
|
idsAnd = (0, lodash_1.intersection)(...idss);
|
||||||
}
|
}
|
||||||
if (filter?.$or) {
|
if (filter?.$or) {
|
||||||
const idss = filter.$or.map((ele) => getRelevantIds(ele));
|
const idss = filter.$or.map((ele) => getRelevantIds(ele));
|
||||||
|
// or有一个不能判断就返回空集
|
||||||
|
if (idss.find(ele => ele.length === 0)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
idsOr = (0, lodash_1.union)(...idss);
|
idsOr = (0, lodash_1.union)(...idss);
|
||||||
}
|
}
|
||||||
if (filter?.id) {
|
if (filter?.id) {
|
||||||
if (typeof filter.id === 'string') {
|
if (typeof filter.id === 'string') {
|
||||||
ids = [filter.id];
|
ids = [filter.id];
|
||||||
}
|
}
|
||||||
if (filter.id?.$eq) {
|
else if (filter.id?.$eq) {
|
||||||
ids = [filter.id.$eq];
|
ids = [filter.id.$eq];
|
||||||
}
|
}
|
||||||
if (filter.id?.$in && filter.id.$in instanceof Array) {
|
else if (filter.id?.$in && filter.id.$in instanceof Array) {
|
||||||
ids = filter.id.$in;
|
ids = filter.id.$in;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 三者如果有基一,直接返回,如果大于一返回intersection
|
// 三者如果有基一,直接返回,如果大于一返回intersection
|
||||||
if (!ids && !idsAnd && !idsOr) {
|
if (!ids && !idsAnd && !idsOr) {
|
||||||
|
|
|
||||||
|
|
@ -1492,16 +1492,28 @@ export function getRelevantIds<ED extends EntityDict & BaseEntityDict, T extends
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter?.$and) {
|
if (filter?.$and) {
|
||||||
const idss = filter.$and.map(
|
const idss: string[][] = filter.$and.map(
|
||||||
(ele: ED[T]['Selection']['filter']) => getRelevantIds(ele)
|
(ele: ED[T]['Selection']['filter']) => getRelevantIds(ele)
|
||||||
);
|
);
|
||||||
|
// and有一个不能判断就返回空集
|
||||||
|
if (idss.find(
|
||||||
|
ele => ele.length === 0
|
||||||
|
)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
idsAnd = intersection(...idss);
|
idsAnd = intersection(...idss);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter?.$or) {
|
if (filter?.$or) {
|
||||||
const idss = filter.$or.map(
|
const idss: string[][] = filter.$or.map(
|
||||||
(ele: ED[T]['Selection']['filter']) => getRelevantIds(ele)
|
(ele: ED[T]['Selection']['filter']) => getRelevantIds(ele)
|
||||||
);
|
);
|
||||||
|
// or有一个不能判断就返回空集
|
||||||
|
if (idss.find(
|
||||||
|
ele => ele.length === 0
|
||||||
|
)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
idsOr = union(...idss);
|
idsOr = union(...idss);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1509,12 +1521,15 @@ export function getRelevantIds<ED extends EntityDict & BaseEntityDict, T extends
|
||||||
if (typeof filter.id === 'string') {
|
if (typeof filter.id === 'string') {
|
||||||
ids = [filter.id];
|
ids = [filter.id];
|
||||||
}
|
}
|
||||||
if (filter.id?.$eq) {
|
else if (filter.id?.$eq) {
|
||||||
ids = [filter.id.$eq as string];
|
ids = [filter.id.$eq as string];
|
||||||
}
|
}
|
||||||
if (filter.id?.$in && filter.id.$in instanceof Array) {
|
else if (filter.id?.$in && filter.id.$in instanceof Array) {
|
||||||
ids = filter.id.$in;
|
ids = filter.id.$in;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 三者如果有基一,直接返回,如果大于一返回intersection
|
// 三者如果有基一,直接返回,如果大于一返回intersection
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue