import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid'; const triggers = [ { name: '当生成userSystem时,生成在这个system下的帐号', entity: 'userSystem', action: 'create', when: 'before', fn: async ({ operation }, context, option) => { const { data } = operation; const { userId, systemId } = data; await context.operate('account', { id: await generateNewIdAsync(), action: 'create', data: { id: await generateNewIdAsync(), entity: 'user', entityId: userId, ofSystemId: systemId, total: 0, avail: 0, refundable: 0, }, }, {}); return 1; }, }, ]; export default triggers;