46 lines
1.6 KiB
JavaScript
46 lines
1.6 KiB
JavaScript
'use strict';
|
|
const Service = require('egg').Service;
|
|
const _ = require("lodash");
|
|
|
|
const validateUtil = require('@jianghujs/jianghu/app/common/validateUtil');
|
|
const idGenerateUtil = require("@jianghujs/jianghu/app/common/idGenerateUtil");
|
|
const { BizError, errorInfoEnum } = require("../constant/error");
|
|
|
|
|
|
class TaskService extends Service {
|
|
async appendFileAfterHook() {
|
|
const { jianghuKnex } = this.app;
|
|
const { taskFormInput, taskId } = this.ctx.request.body.appData.actionData;
|
|
const fileInput = JSON.parse(taskFormInput).filter(item => item.type == 'file')
|
|
|
|
if (fileInput.length > 0) {
|
|
const insertData = []
|
|
const idSequence = await idGenerateUtil.idPlus({
|
|
knex: jianghuKnex,
|
|
startValue: 1000,
|
|
tableName: 'jianghujs_workflow.file',
|
|
columnName: 'idSequence',
|
|
plusValue: 1
|
|
});
|
|
|
|
fileInput.forEach(async element => {
|
|
element.answer.forEach(async file => {
|
|
const { filename, downloadPath, binarySize } = file
|
|
insertData.push({
|
|
fileId: "F" + (idSequence),
|
|
idSequence: idSequence,
|
|
fileBizId: taskId,
|
|
filename,
|
|
downloadPath,
|
|
binarySize
|
|
})
|
|
idSequence++
|
|
});
|
|
});
|
|
if (insertData.length > 0) await jianghuKnex('file', this.ctx).insert(insertData);
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = TaskService;
|