适配了domain的相关变化
This commit is contained in:
parent
dfd7a8f18a
commit
bd62c3ce23
|
|
@ -7,8 +7,6 @@ const path_1 = require("path");
|
|||
const node_schedule_1 = require("node-schedule");
|
||||
const actionDef_1 = require("oak-domain/lib/store/actionDef");
|
||||
const lodash_1 = require("oak-domain/lib/utils/lodash");
|
||||
const checkers_1 = require("oak-domain/lib/checkers");
|
||||
const triggers_1 = require("oak-domain/lib/triggers");
|
||||
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
const types_1 = require("oak-domain/lib/types");
|
||||
const DbStore_1 = require("./DbStore");
|
||||
|
|
@ -86,20 +84,16 @@ class AppLoader extends types_1.AppLoader {
|
|||
const checkers = this.requireSth('lib/checkers/index');
|
||||
const authDict = this.requireSth('lib/auth/index');
|
||||
const { ActionDefDict } = require(`${this.path}/lib/oak-app-domain/ActionDefDict`);
|
||||
const { triggers: adTriggers, checkers: adCheckers } = (0, actionDef_1.analyzeActionDefDict)(this.dbStore.getSchema(), ActionDefDict);
|
||||
const { triggers: adTriggers, checkers: adCheckers } = (0, actionDef_1.makeIntrinsicCTWs)(this.dbStore.getSchema(), ActionDefDict);
|
||||
triggers.forEach((trigger) => this.dbStore.registerTrigger(trigger));
|
||||
adTriggers.forEach((trigger) => this.dbStore.registerTrigger(trigger));
|
||||
checkers.forEach((checker) => this.dbStore.registerChecker(checker));
|
||||
adCheckers.forEach((checker) => this.dbStore.registerChecker(checker));
|
||||
const dynamicCheckers = (0, checkers_1.createDynamicCheckers)(this.dbStore.getSchema());
|
||||
dynamicCheckers.forEach((checker) => this.dbStore.registerChecker(checker));
|
||||
const dynamicTriggers = (0, triggers_1.createDynamicTriggers)(this.dbStore.getSchema());
|
||||
dynamicTriggers.forEach((trigger) => this.dbStore.registerTrigger(trigger));
|
||||
}
|
||||
startWatchers() {
|
||||
const watchers = this.requireSth('lib/watchers/index');
|
||||
const { ActionDefDict } = require(`${this.path}/lib/oak-app-domain/ActionDefDict`);
|
||||
const { watchers: adWatchers } = (0, actionDef_1.analyzeActionDefDict)(this.dbStore.getSchema(), ActionDefDict);
|
||||
const { watchers: adWatchers } = (0, actionDef_1.makeIntrinsicCTWs)(this.dbStore.getSchema(), ActionDefDict);
|
||||
const totalWatchers = watchers.concat(adWatchers);
|
||||
let count = 0;
|
||||
const doWatchers = async () => {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ class DbStore extends oak_db_1.MysqlStore {
|
|||
if (!option.blockTrigger) {
|
||||
await this.executor.preOperation(entity, operation, context, option);
|
||||
}
|
||||
await this.relationAuth.checkRelationAsync(entity, operation, context);
|
||||
const result = await super.cascadeUpdateAsync(entity, operation, context, option);
|
||||
if (!option.blockTrigger) {
|
||||
await this.executor.postOperation(entity, operation, context, option);
|
||||
|
|
@ -30,6 +29,7 @@ class DbStore extends oak_db_1.MysqlStore {
|
|||
await context.begin();
|
||||
}
|
||||
try {
|
||||
await this.relationAuth.checkRelationAsync(entity, operation, context);
|
||||
result = await super.operate(entity, operation, context, option);
|
||||
}
|
||||
catch (err) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { existsSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { scheduleJob } from 'node-schedule';
|
||||
import { analyzeActionDefDict } from "oak-domain/lib/store/actionDef";
|
||||
import { makeIntrinsicCTWs } from "oak-domain/lib/store/actionDef";
|
||||
import { intersection } from 'oak-domain/lib/utils/lodash';
|
||||
import { createDynamicCheckers } from 'oak-domain/lib/checkers';
|
||||
import { createDynamicTriggers } from 'oak-domain/lib/triggers';
|
||||
|
|
@ -106,7 +106,7 @@ export class AppLoader<ED extends EntityDict & BaseEntityDict, Cxt extends Async
|
|||
const authDict = this.requireSth('lib/auth/index');
|
||||
const { ActionDefDict } = require(`${this.path}/lib/oak-app-domain/ActionDefDict`);
|
||||
|
||||
const { triggers: adTriggers, checkers: adCheckers } = analyzeActionDefDict(this.dbStore.getSchema(), ActionDefDict);
|
||||
const { triggers: adTriggers, checkers: adCheckers } = makeIntrinsicCTWs(this.dbStore.getSchema(), ActionDefDict);
|
||||
triggers.forEach(
|
||||
(trigger: Trigger<ED, keyof ED, Cxt>) => this.dbStore.registerTrigger(trigger)
|
||||
);
|
||||
|
|
@ -118,24 +118,14 @@ export class AppLoader<ED extends EntityDict & BaseEntityDict, Cxt extends Async
|
|||
);
|
||||
adCheckers.forEach(
|
||||
(checker) => this.dbStore.registerChecker(checker)
|
||||
);
|
||||
|
||||
const dynamicCheckers = createDynamicCheckers(this.dbStore.getSchema());
|
||||
dynamicCheckers.forEach(
|
||||
(checker) => this.dbStore.registerChecker(checker)
|
||||
);
|
||||
|
||||
const dynamicTriggers = createDynamicTriggers(this.dbStore.getSchema());
|
||||
dynamicTriggers.forEach(
|
||||
(trigger) => this.dbStore.registerTrigger(trigger)
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
startWatchers() {
|
||||
const watchers = this.requireSth('lib/watchers/index');
|
||||
const { ActionDefDict } = require(`${this.path}/lib/oak-app-domain/ActionDefDict`);
|
||||
|
||||
const { watchers: adWatchers } = analyzeActionDefDict(this.dbStore.getSchema(), ActionDefDict);
|
||||
const { watchers: adWatchers } = makeIntrinsicCTWs(this.dbStore.getSchema(), ActionDefDict);
|
||||
const totalWatchers = (<Watcher<ED, keyof ED, Cxt>[]>watchers).concat(adWatchers);
|
||||
|
||||
let count = 0;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ export class DbStore<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncCo
|
|||
if (!option.blockTrigger) {
|
||||
await this.executor.preOperation(entity, operation, context, option);
|
||||
}
|
||||
await this.relationAuth.checkRelationAsync(entity, operation, context);
|
||||
const result = await super.cascadeUpdateAsync(entity, operation, context, option);
|
||||
if (!option.blockTrigger) {
|
||||
await this.executor.postOperation(entity, operation, context, option);
|
||||
|
|
@ -48,6 +47,7 @@ export class DbStore<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncCo
|
|||
await context.begin();
|
||||
}
|
||||
try {
|
||||
await this.relationAuth.checkRelationAsync(entity, operation, context);
|
||||
result = await super.operate(entity, operation, context, option);
|
||||
}
|
||||
catch (err) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue