oak-pay-business/lib/triggers/system.js

34 lines
1.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"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;