前台缓存中允许外键空指针

This commit is contained in:
Xu Chang 2023-08-23 16:44:00 +08:00
parent 132b3b2902
commit c42b4d49b0
2 changed files with 5 additions and 4 deletions

View File

@ -477,8 +477,8 @@ var RelationAuth = /** @class */ (function () {
RelationAuth.prototype.filterActionAuths = function (entity, filter, actionAuths, context, actions) {
return actionAuths.map(function (ele) {
var paths = ele.paths, relation = ele.relation, relationId = ele.relationId;
if (relationId) {
(0, assert_1.default)(relation);
// 在cache中可能出现relation外键指向的对象为null的情况要容错
if (relation) {
var userRelations = relation.userRelation$relation;
if (userRelations.length > 0) {
var entityIds = (0, lodash_1.uniq)(userRelations.map(function (ele) { return ele.entityId; }));

View File

@ -572,8 +572,9 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
return actionAuths.map(
(ele) => {
const { paths, relation, relationId } = ele;
if (relationId) {
assert(relation);
// 在cache中可能出现relation外键指向的对象为null的情况要容错
if (relation) {
const { userRelation$relation: userRelations } = relation;
if (userRelations!.length > 0) {
const entityIds = uniq(userRelations!.map(ele => ele.entityId));