问题: - 导入成功条数显示为负数 - 原因:成功数量计算使用 validRecords.size() - failures.size() - 但没有使用实际的数据库操作返回值 修复: - saveBatchWithUpsert 和 saveBatch 方法现在返回 int - 累加实际的数据库影响行数 - 使用 actualSuccessCount 变量跟踪真实成功数量 影响范围: - CcdiIntermediaryPersonImportServiceImpl - CcdiIntermediaryEntityImportServiceImpl
84 lines
2.1 KiB
JavaScript
84 lines
2.1 KiB
JavaScript
/**
|
|
* Archiver Vending
|
|
*
|
|
* @ignore
|
|
* @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
|
|
* @copyright (c) 2012-2014 Chris Talkington, contributors.
|
|
*/
|
|
var Archiver = require('./lib/core');
|
|
|
|
var formats = {};
|
|
|
|
/**
|
|
* Dispenses a new Archiver instance.
|
|
*
|
|
* @constructor
|
|
* @param {String} format The archive format to use.
|
|
* @param {Object} options See [Archiver]{@link Archiver}
|
|
* @return {Archiver}
|
|
*/
|
|
var vending = function(format, options) {
|
|
return vending.create(format, options);
|
|
};
|
|
|
|
/**
|
|
* Creates a new Archiver instance.
|
|
*
|
|
* @param {String} format The archive format to use.
|
|
* @param {Object} options See [Archiver]{@link Archiver}
|
|
* @return {Archiver}
|
|
*/
|
|
vending.create = function(format, options) {
|
|
if (formats[format]) {
|
|
var instance = new Archiver(format, options);
|
|
instance.setFormat(format);
|
|
instance.setModule(new formats[format](options));
|
|
|
|
return instance;
|
|
} else {
|
|
throw new Error('create(' + format + '): format not registered');
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Registers a format for use with archiver.
|
|
*
|
|
* @param {String} format The name of the format.
|
|
* @param {Function} module The function for archiver to interact with.
|
|
* @return void
|
|
*/
|
|
vending.registerFormat = function(format, module) {
|
|
if (formats[format]) {
|
|
throw new Error('register(' + format + '): format already registered');
|
|
}
|
|
|
|
if (typeof module !== 'function') {
|
|
throw new Error('register(' + format + '): format module invalid');
|
|
}
|
|
|
|
if (typeof module.prototype.append !== 'function' || typeof module.prototype.finalize !== 'function') {
|
|
throw new Error('register(' + format + '): format module missing methods');
|
|
}
|
|
|
|
formats[format] = module;
|
|
};
|
|
|
|
/**
|
|
* Check if the format is already registered.
|
|
*
|
|
* @param {String} format the name of the format.
|
|
* @return boolean
|
|
*/
|
|
vending.isRegisteredFormat = function (format) {
|
|
if (formats[format]) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
};
|
|
|
|
vending.registerFormat('zip', require('./lib/plugins/zip'));
|
|
vending.registerFormat('tar', require('./lib/plugins/tar'));
|
|
vending.registerFormat('json', require('./lib/plugins/json'));
|
|
|
|
module.exports = vending; |