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