store相关的一些小问题
This commit is contained in:
parent
1ba3a724e4
commit
db1928449f
|
|
@ -1077,7 +1077,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|||
*/
|
||||
CascadeStore.prototype.doUpdateSingleRow = function (entity, operation, context, option) {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var data, action, operId, filter, now, _a, modiCreate, addTimestamp_1, result_1, createInner, multipleCreate, data_2, data_2_1, d, createSingleOper, e_4_1, createOper, _b, ids_1, selection, rows, modiUpsert, upsertModis, _c, originData, originId, createOper, updateAttrCount, result_2;
|
||||
var data, action, operId, filter, now, _a, modiCreate, addTimestamp_1, result_1, createInner, multipleCreate, data_2, data_2_1, d, createSingleOper, e_4_1, operatorId, createOper, _b, ids_1, selection, rows, modiUpsert, upsertModis, _c, originData, originId, createOper, updateAttrCount, result_2;
|
||||
var e_4, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
||||
var _this = this;
|
||||
return tslib_1.__generator(this, function (_o) {
|
||||
|
|
@ -1260,6 +1260,10 @@ var CascadeStore = /** @class */ (function (_super) {
|
|||
if (!(!option.dontCreateOper && !['oper', 'operEntity', 'modiEntity', 'modi'].includes(entity))) return [3 /*break*/, 22];
|
||||
// 按照框架要求生成Oper和OperEntity这两个内置的对象
|
||||
(0, assert_1.default)(operId);
|
||||
return [4 /*yield*/, context.getCurrentUserId(true)];
|
||||
case 16:
|
||||
operatorId = _o.sent();
|
||||
if (!operatorId) return [3 /*break*/, 22];
|
||||
_e = {
|
||||
id: 'dummy',
|
||||
action: 'create'
|
||||
|
|
@ -1267,11 +1271,9 @@ var CascadeStore = /** @class */ (function (_super) {
|
|||
_f = {
|
||||
id: operId,
|
||||
action: action,
|
||||
data: data
|
||||
data: data,
|
||||
operatorId: operatorId
|
||||
};
|
||||
return [4 /*yield*/, context.getCurrentUserId()];
|
||||
case 16:
|
||||
_f.operatorId = _o.sent();
|
||||
if (!(data instanceof Array)) return [3 /*break*/, 18];
|
||||
_g = {
|
||||
id: 'dummy',
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ function getRelevantIds(filter) {
|
|||
}
|
||||
// 因为要准确判定id,如果有其它的过滤条件,可能会使实际处理的行数少于id指向的行数,只能返回空数组
|
||||
var attrs = Object.keys(filter);
|
||||
if ((0, lodash_1.union)(attrs, ['id', '$and', '$or']).length > 3) {
|
||||
if ((0, lodash_1.intersection)(attrs, ['id', '$and', '$or']).length > 3) {
|
||||
return [];
|
||||
}
|
||||
if (filter === null || filter === void 0 ? void 0 : filter.$and) {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ export interface Context<ED extends EntityDict> {
|
|||
toString(): Promise<string>;
|
||||
getScene(): string | undefined;
|
||||
setScene(scene?: string): void;
|
||||
getCurrentUserId(): Promise<string | undefined>;
|
||||
getCurrentUserId(allowUnloggedIn?: boolean): Promise<string | undefined>;
|
||||
getHeader(key: string): string | string[] | undefined;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1166,41 +1166,44 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict, Cxt e
|
|||
if (!option.dontCreateOper && !['oper', 'operEntity', 'modiEntity', 'modi'].includes(entity as string)) {
|
||||
// 按照框架要求生成Oper和OperEntity这两个内置的对象
|
||||
assert(operId);
|
||||
const createOper: CreateOperOperation = {
|
||||
id: 'dummy',
|
||||
action: 'create',
|
||||
data: {
|
||||
id: operId,
|
||||
action,
|
||||
data,
|
||||
operatorId: await context.getCurrentUserId(),
|
||||
operEntity$oper: data instanceof Array ? {
|
||||
id: 'dummy',
|
||||
action: 'create',
|
||||
data: await Promise.all(
|
||||
data.map(
|
||||
async (ele) => ({
|
||||
id: await generateNewId(),
|
||||
entity: entity as string,
|
||||
entityId: ele.id,
|
||||
})
|
||||
)
|
||||
),
|
||||
} : [{
|
||||
id: 'dummy',
|
||||
action: 'create',
|
||||
data: {
|
||||
id: await generateNewId(),
|
||||
entity: entity as string,
|
||||
entityId: (data as ED[T]['CreateSingle']['data']).id,
|
||||
},
|
||||
}]
|
||||
},
|
||||
};
|
||||
await this.cascadeUpdate('oper', createOper, context, {
|
||||
dontCollect: true,
|
||||
dontCreateOper: true,
|
||||
});
|
||||
const operatorId = await context.getCurrentUserId(true);
|
||||
if (operatorId) {
|
||||
const createOper: CreateOperOperation = {
|
||||
id: 'dummy',
|
||||
action: 'create',
|
||||
data: {
|
||||
id: operId,
|
||||
action,
|
||||
data,
|
||||
operatorId,
|
||||
operEntity$oper: data instanceof Array ? {
|
||||
id: 'dummy',
|
||||
action: 'create',
|
||||
data: await Promise.all(
|
||||
data.map(
|
||||
async (ele) => ({
|
||||
id: await generateNewId(),
|
||||
entity: entity as string,
|
||||
entityId: ele.id,
|
||||
})
|
||||
)
|
||||
),
|
||||
} : [{
|
||||
id: 'dummy',
|
||||
action: 'create',
|
||||
data: {
|
||||
id: await generateNewId(),
|
||||
entity: entity as string,
|
||||
entityId: (data as ED[T]['CreateSingle']['data']).id,
|
||||
},
|
||||
}]
|
||||
},
|
||||
};
|
||||
await this.cascadeUpdate('oper', createOper, context, {
|
||||
dontCollect: true,
|
||||
dontCreateOper: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
return result!;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ export function getRelevantIds<ED extends EntityDict, T extends keyof ED>(filter
|
|||
|
||||
// 因为要准确判定id,如果有其它的过滤条件,可能会使实际处理的行数少于id指向的行数,只能返回空数组
|
||||
const attrs = Object.keys(filter);
|
||||
if (union(attrs, ['id', '$and', '$or']).length > 3) {
|
||||
if (intersection(attrs, ['id', '$and', '$or']).length > 3) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export interface Context<ED extends EntityDict>{
|
|||
toString(): Promise<string>;
|
||||
getScene(): string | undefined;
|
||||
setScene(scene?: string): void;
|
||||
getCurrentUserId(): Promise<string | undefined>;
|
||||
getCurrentUserId(allowUnloggedIn?: boolean): Promise<string | undefined>;
|
||||
getHeader(key: string): string | string[] | undefined;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue