34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
"use strict";
|
||
Object.defineProperty(exports, "__esModule", { value: true });
|
||
const tslib_1 = require("tslib");
|
||
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
||
const assert_1 = tslib_1.__importDefault(require("assert"));
|
||
const triggers = [
|
||
{
|
||
name: '当添加system时,生成相关的account',
|
||
entity: 'system',
|
||
action: 'create',
|
||
when: 'after',
|
||
fn: async ({ operation }, context, option) => {
|
||
const { data } = operation;
|
||
(0, assert_1.default)(!(data instanceof Array));
|
||
const { id } = data;
|
||
await context.operate('account', {
|
||
id: await (0, uuid_1.generateNewIdAsync)(),
|
||
action: 'create',
|
||
data: {
|
||
id: await (0, uuid_1.generateNewIdAsync)(),
|
||
entity: 'system',
|
||
entityId: id,
|
||
ofSystemId: id,
|
||
total: 0,
|
||
avail: 0,
|
||
refundable: 0,
|
||
}
|
||
}, {});
|
||
return 1;
|
||
},
|
||
},
|
||
];
|
||
exports.default = triggers;
|