|
@@ -624,17 +624,19 @@ module.exports = app => {
|
|
|
autoFields: true,
|
|
|
});
|
|
|
const files = [];
|
|
|
- const create_time = Date.parse(new Date()) / 1000;
|
|
|
+ let idx = 0;
|
|
|
while ((stream = await parts()) != null) {
|
|
|
if (!stream.filename) {
|
|
|
// 如果没有传入直接返回
|
|
|
return;
|
|
|
}
|
|
|
+ const create_time = Date.parse(new Date()) / 1000;
|
|
|
const fileInfo = path.parse(stream.filename);
|
|
|
// const filepath = path.join('public/upload', this.ctx.tender.id.toString(), 'tc', 'fujian_' + create_time + fileInfo.ext);
|
|
|
- const filepath = `public/upload/${this.ctx.tender.id.toString()}/tc/fujian_${create_time + fileInfo.ext}`;
|
|
|
+ const filepath = `public/upload/${this.ctx.tender.id.toString()}/tc/fujian_${create_time + idx + fileInfo.ext}`;
|
|
|
await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, 'app', filepath));
|
|
|
files.push({ filepath, name: stream.filename });
|
|
|
+ idx++;
|
|
|
}
|
|
|
const upload_time = this.ctx.helper.dateTran(new Date());
|
|
|
const payload = files.map(file => {
|
|
@@ -698,7 +700,7 @@ module.exports = app => {
|
|
|
const fileInfo = await ctx.service.materialFile.getMaterialFileById(id);
|
|
|
if (fileInfo) {
|
|
|
// 先删除文件
|
|
|
- await fs.unlinkSync(path.join(this.app.baseDir, './app', fileInfo.filepath));
|
|
|
+ await fs.unlinkSync(path.resolve(this.app.baseDir, './app', fileInfo.filepath));
|
|
|
// 再删除数据库
|
|
|
await ctx.service.materialFile.delete(id);
|
|
|
} else {
|