Merge branch 'dev' of codeup.aliyun.com:61c14a7efa282c88e103c23f/oak-domain into dev
This commit is contained in:
commit
b1d0bdbd3d
|
|
@ -441,19 +441,20 @@ function translateCascadeRelationFilterMaker(schema, lch, entity2, pathPrefix) {
|
|||
if (d.entity === attr && typeof d.entityId === 'string') {
|
||||
return d.entityId;
|
||||
}
|
||||
throw new Exception_1.OakUserUnpermittedException();
|
||||
}
|
||||
else {
|
||||
(0, assert_1.default)(typeof relation === 'string');
|
||||
if (typeof d["".concat(attr, "Id")] === 'string') {
|
||||
return d["".concat(attr, "Id")];
|
||||
}
|
||||
throw new Exception_1.OakUserUnpermittedException();
|
||||
}
|
||||
};
|
||||
if (relation === 2) {
|
||||
if (data instanceof Array) {
|
||||
var fkIds = (0, lodash_1.uniq)(data.map(function (d) { return getForeignKeyId_1(d); }));
|
||||
var fkIds = (0, lodash_1.uniq)(data.map(function (d) { return getForeignKeyId_1(d); }).filter(function (ele) { return !!ele; }));
|
||||
if (fkIds.length === 0) {
|
||||
return new Exception_1.OakUserUnpermittedException();
|
||||
}
|
||||
return {
|
||||
$entity: attr,
|
||||
$filter: (0, filter_1.addFilterSegment)(filterMaker2(userId), { id: { $in: fkIds } }),
|
||||
|
|
@ -461,6 +462,9 @@ function translateCascadeRelationFilterMaker(schema, lch, entity2, pathPrefix) {
|
|||
};
|
||||
}
|
||||
var fkId_1 = getForeignKeyId_1(data);
|
||||
if (!fkId_1) {
|
||||
return new Exception_1.OakUserUnpermittedException();
|
||||
}
|
||||
return {
|
||||
$entity: attr,
|
||||
$filter: (0, filter_1.addFilterSegment)(filterMaker2(userId), { id: fkId_1 }),
|
||||
|
|
@ -468,7 +472,10 @@ function translateCascadeRelationFilterMaker(schema, lch, entity2, pathPrefix) {
|
|||
}
|
||||
(0, assert_1.default)(typeof relation === 'string');
|
||||
if (data instanceof Array) {
|
||||
var fkIds = (0, lodash_1.uniq)(data.map(function (d) { return getForeignKeyId_1(d); }));
|
||||
var fkIds = (0, lodash_1.uniq)(data.map(function (d) { return getForeignKeyId_1(d); }).filter(function (ele) { return !!ele; }));
|
||||
if (fkIds.length === 0) {
|
||||
return new Exception_1.OakUserUnpermittedException();
|
||||
}
|
||||
return {
|
||||
$entity: relation,
|
||||
$filter: (0, filter_1.addFilterSegment)(filterMaker2(userId), { id: { $in: fkIds } }),
|
||||
|
|
@ -476,6 +483,9 @@ function translateCascadeRelationFilterMaker(schema, lch, entity2, pathPrefix) {
|
|||
};
|
||||
}
|
||||
var fkId = getForeignKeyId_1(data);
|
||||
if (!fkId) {
|
||||
return new Exception_1.OakUserUnpermittedException();
|
||||
}
|
||||
return {
|
||||
$entity: relation,
|
||||
$filter: (0, filter_1.addFilterSegment)(filterMaker2(userId), { id: fkId }),
|
||||
|
|
@ -486,9 +496,9 @@ function translateCascadeRelationFilterMaker(schema, lch, entity2, pathPrefix) {
|
|||
var filter_4 = operation.filter;
|
||||
if (filter_4) {
|
||||
var counter = translateCreateFilterMaker(entity2, filter_4, userId);
|
||||
if (counter instanceof Exception_1.OakUserUnpermittedException) {
|
||||
throw counter;
|
||||
}
|
||||
// if (counter instanceof OakUserUnpermittedException) {
|
||||
// throw counter;
|
||||
// }
|
||||
return counter;
|
||||
}
|
||||
throw new Exception_1.OakUserUnpermittedException();
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ type CreateRelationCounter<ED extends EntityDict & BaseEntityDict> = CreateRelat
|
|||
|
||||
|
||||
type FilterMakeFn<ED extends EntityDict & BaseEntityDict> =
|
||||
(operation: ED[keyof ED]['Operation'] | ED[keyof ED]['Selection'], userId: string) => ED[keyof ED]['Selection']['filter'] | CreateRelationCounter<ED>;
|
||||
(operation: ED[keyof ED]['Operation'] | ED[keyof ED]['Selection'], userId: string) => ED[keyof ED]['Selection']['filter'] | CreateRelationCounter<ED> | OakUserUnpermittedException<ED>;
|
||||
|
||||
function translateCascadeRelationFilterMaker<ED extends EntityDict & BaseEntityDict>(
|
||||
schema: StorageSchema<ED>,
|
||||
|
|
@ -442,19 +442,20 @@ function translateCascadeRelationFilterMaker<ED extends EntityDict & BaseEntityD
|
|||
if (d.entity === attr && typeof d.entityId === 'string') {
|
||||
return d.entityId as string;
|
||||
}
|
||||
throw new OakUserUnpermittedException();
|
||||
}
|
||||
else {
|
||||
assert(typeof relation === 'string');
|
||||
if (typeof d[`${attr}Id`] === 'string') {
|
||||
return d[`${attr}Id`] as string;
|
||||
}
|
||||
throw new OakUserUnpermittedException();
|
||||
}
|
||||
};
|
||||
if (relation === 2) {
|
||||
if (data instanceof Array) {
|
||||
const fkIds = uniq(data.map(d => getForeignKeyId(d)));
|
||||
const fkIds = uniq(data.map(d => getForeignKeyId(d)).filter(ele => !!ele));
|
||||
if (fkIds.length === 0) {
|
||||
return new OakUserUnpermittedException();
|
||||
}
|
||||
return {
|
||||
$entity: attr,
|
||||
$filter: addFilterSegment(filterMaker2(userId), { id: { $in: fkIds } }),
|
||||
|
|
@ -462,6 +463,9 @@ function translateCascadeRelationFilterMaker<ED extends EntityDict & BaseEntityD
|
|||
};
|
||||
}
|
||||
const fkId = getForeignKeyId(data);
|
||||
if (!fkId) {
|
||||
return new OakUserUnpermittedException();
|
||||
}
|
||||
return {
|
||||
$entity: attr,
|
||||
$filter: addFilterSegment(filterMaker2(userId), { id: fkId }),
|
||||
|
|
@ -469,7 +473,10 @@ function translateCascadeRelationFilterMaker<ED extends EntityDict & BaseEntityD
|
|||
}
|
||||
assert(typeof relation === 'string');
|
||||
if (data instanceof Array) {
|
||||
const fkIds = uniq(data.map(d => getForeignKeyId(d)));
|
||||
const fkIds = uniq(data.map(d => getForeignKeyId(d)).filter(ele => !!ele));
|
||||
if (fkIds.length === 0) {
|
||||
return new OakUserUnpermittedException();
|
||||
}
|
||||
return {
|
||||
$entity: relation,
|
||||
$filter: addFilterSegment(filterMaker2(userId), { id: { $in: fkIds } }),
|
||||
|
|
@ -477,6 +484,9 @@ function translateCascadeRelationFilterMaker<ED extends EntityDict & BaseEntityD
|
|||
};
|
||||
}
|
||||
const fkId = getForeignKeyId(data);
|
||||
if (!fkId) {
|
||||
return new OakUserUnpermittedException();
|
||||
}
|
||||
return {
|
||||
$entity: relation,
|
||||
$filter: addFilterSegment(filterMaker2(userId), { id: fkId }),
|
||||
|
|
@ -487,9 +497,9 @@ function translateCascadeRelationFilterMaker<ED extends EntityDict & BaseEntityD
|
|||
const { filter } = operation as ED[keyof ED]['Selection'];
|
||||
if (filter) {
|
||||
const counter = translateCreateFilterMaker(entity2, filter, userId);
|
||||
if (counter instanceof OakUserUnpermittedException) {
|
||||
throw counter;
|
||||
}
|
||||
// if (counter instanceof OakUserUnpermittedException) {
|
||||
// throw counter;
|
||||
// }
|
||||
return counter;
|
||||
}
|
||||
throw new OakUserUnpermittedException();
|
||||
|
|
|
|||
Loading…
Reference in New Issue