Browse Source

qa,uat附件分区

laiguoran 3 years ago
parent
commit
b87ade3aa3

+ 2 - 2
app/controller/advance_controller.js

@@ -425,7 +425,7 @@ module.exports = app => {
                     const fileInfo = path.parse(stream.filename);
                     const filepath = `app/public/upload/${this.ctx.tender.id.toString()}/yfk/fujian_${create_time + idx.toString() + fileInfo.ext}`;
                     // await ctx.helper.saveStreamFile(stream, path.resolve(this.app.baseDir, 'app', filepath));
-                    await ctx.app.fujianOss.put(filepath, stream);
+                    await ctx.app.fujianOss.put(ctx.app.config.fujianOssFolder + filepath, stream);
                     files.push({ filepath, name: stream.filename, ext: fileInfo.ext });
                     ++idx;
                     stream && (await sendToWormhole(stream));
@@ -474,7 +474,7 @@ module.exports = app => {
                 if (fileInfo || Object.keys(fileInfo).length) {
                     // 先删除文件
                     // await fs.unlinkSync(path.resolve(this.app.baseDir, './app', fileInfo.filepath));
-                    await ctx.app.fujianOss.delete(fileInfo.filepath);
+                    await ctx.app.fujianOss.delete(ctx.app.config.fujianOssFolder + fileInfo.filepath);
                     // 再删除数据库
                     await ctx.service.advanceFile.delete(id);
                 } else {

+ 2 - 2
app/controller/change_controller.js

@@ -1099,7 +1099,7 @@ module.exports = app => {
                     // const filepath = `app/public/upload/change/fujian_${create_time + index.toString() + fileInfo.ext}`;
                     const filepath = `app/public/upload/${parts.field.tid}/change/fujian_${create_time + index.toString() + fileInfo.ext}`;
                     // await ctx.helper.saveStreamFile(stream, path.resolve(this.app.baseDir, filepath));
-                    await ctx.app.fujianOss.put(filepath, stream);
+                    await ctx.app.fujianOss.put(ctx.app.config.fujianOssFolder + filepath, stream);
                     await sendToWormhole(stream);
                     // 保存数据到att表
                     const fileData = {
@@ -1263,7 +1263,7 @@ module.exports = app => {
                 if (fileInfo !== undefined && fileInfo !== '') {
                     // 先删除文件
                     // await fs.unlinkSync(path.join(this.app.baseDir, fileInfo.filepath));
-                    await ctx.app.fujianOss.delete(fileInfo.filepath);
+                    await ctx.app.fujianOss.delete(ctx.app.config.fujianOssFolder + fileInfo.filepath);
                     // 再删除数据库
                     await ctx.service.changeAtt.deleteById(data.id);
                     responseData.data = '';

+ 3 - 3
app/controller/ledger_controller.js

@@ -825,7 +825,7 @@ module.exports = app => {
                     const create_time = Date.parse(new Date()) / 1000;
                     const filepath = `app/public/upload/${this.ctx.tender.id}/ledger/fujian_${create_time + index.toString() + fileInfo.ext}`;
                     // await ctx.helper.saveStreamFile(stream, path.resolve(this.app.baseDir, filepath));
-                    await ctx.app.fujianOss.put(filepath, stream);
+                    await ctx.app.fujianOss.put(ctx.app.config.fujianOssFolder + filepath, stream);
                     if (stream) {
                         await sendToWormhole(stream);
                     }
@@ -957,7 +957,7 @@ module.exports = app => {
                 if (fileInfo !== undefined && fileInfo !== '') {
                     // 先删除文件
                     // await fs.unlinkSync(path.join(this.app.baseDir, fileInfo.filepath));
-                    await ctx.app.fujianOss.delete(fileInfo.filepath);
+                    await ctx.app.fujianOss.delete(ctx.app.config.fujianOssFolder + fileInfo.filepath);
                     // 再删除数据库
                     await ctx.service.ledgerAtt.deleteById(data.id);
                     responseData.data = '';
@@ -1000,7 +1000,7 @@ module.exports = app => {
                     // }
                     // 保存文件
                     // await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, dirName, fileName));
-                    await ctx.app.fujianOss.put(path.join(dirName, fileName), stream);
+                    await ctx.app.fujianOss.put(ctx.app.config.fujianOssFolder + path.join(dirName, fileName), stream);
                     // 保存数据到att表
                     fileData = {
                         filesize: stream.fields.size,

+ 6 - 6
app/controller/stage_controller.js

@@ -762,7 +762,7 @@ module.exports = app => {
 
                     // 保存文件
                     // await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, dirName, fileName));
-                    await ctx.app.fujianOss.put(filepath, stream);
+                    await ctx.app.fujianOss.put(ctx.app.config.fujianOssFolder + filepath, stream);
                     await sendToWormhole(stream);
 
                     // 插入到stage_pay对应的附件列表中
@@ -1456,7 +1456,7 @@ module.exports = app => {
                     const create_time = Date.parse(new Date()) / 1000;
                     const filepath = `app/public/upload/${this.ctx.tender.id}/stage/fujian_${create_time + index.toString() + fileInfo.ext}`;
                     // await ctx.helper.saveStreamFile(stream, path.resolve(this.app.baseDir, filepath));
-                    await ctx.app.fujianOss.put(filepath, stream);
+                    await ctx.app.fujianOss.put(ctx.app.config.fujianOssFolder + filepath, stream);
                     // console.log(await fs.existsSync(path.resolve(this.app.baseDir, 'app', filepath)));
                     // const fileInfo = path.parse(stream.filename);
                     // const fileName = 'stage' + create_time + '_' + index + fileInfo.ext;
@@ -1600,7 +1600,7 @@ module.exports = app => {
                 if (fileInfo !== undefined && fileInfo !== '') {
                     // 先删除文件
                     // await fs.unlinkSync(path.join(this.app.baseDir, fileInfo.filepath));
-                    await ctx.app.fujianOss.delete(fileInfo.filepath);
+                    await ctx.app.fujianOss.delete(ctx.app.config.fujianOssFolder + fileInfo.filepath);
                     // 再删除数据库
                     await ctx.service.stageAtt.deleteById(data.id);
                     responseData.data = '';
@@ -1646,7 +1646,7 @@ module.exports = app => {
 
                     // 保存文件
                     // await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, dirName, fileName));
-                    await ctx.app.fujianOss.put(path.join(dirName, fileName), stream);
+                    await ctx.app.fujianOss.put(ctx.app.config.fujianOssFolder + path.join(dirName, fileName), stream);
                     // 保存数据到att表
                     fileData = {
                         filesize: stream.fields.size,
@@ -1771,7 +1771,7 @@ module.exports = app => {
                     // }
                     // 保存文件
                     // await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, dirName, fileName));
-                    await ctx.app.fujianOss.put(filepath, stream);
+                    await ctx.app.fujianOss.put(ctx.app.config.fujianOssFolder + filepath, stream);
                     await sendToWormhole(stream);
                     // 插入到stage_pay对应的附件列表中
                     const attData = {
@@ -1851,7 +1851,7 @@ module.exports = app => {
                 const data = JSON.parse(ctx.request.body.data);
                 const fileInfo = await ctx.service.payAtt.getDataById(data.id);
                 if (!fileInfo) throw '不存在该文件';
-                await ctx.app.fujianOss.delete(fileInfo.filepath);
+                await ctx.app.fujianOss.delete(ctx.app.config.fujianOssFolder + fileInfo.filepath);
                 const result = await ctx.service.payAtt.delFiles(data.id);
                 // if (fs.existsSync(path.join(ctx.app.baseDir, fileInfo.filepath))) {
                 //     await fs.unlinkSync(path.join(ctx.app.baseDir, fileInfo.filepath));

+ 2 - 2
app/controller/wap_controller.js

@@ -594,7 +594,7 @@ module.exports = app => {
                     const create_time = Date.parse(now_time) / 1000;
                     const filepath = `app/public/upload/${sfInfo.tid}/stage/shoufang/fujian_${create_time + index.toString() + fileInfo.ext}`;
                     // await ctx.helper.saveStreamFile(stream, path.resolve(this.app.baseDir, filepath));
-                    await ctx.app.fujianOss.put(filepath, stream);
+                    await ctx.app.fujianOss.put(ctx.app.config.fujianOssFolder + filepath, stream);
                     // console.log(await fs.existsSync(path.resolve(this.app.baseDir, 'app', filepath)));
                     // const fileInfo = path.parse(stream.filename);
                     // const fileName = 'stage' + create_time + '_' + index + fileInfo.ext;
@@ -663,7 +663,7 @@ module.exports = app => {
                 if (fileInfo !== undefined && fileInfo !== '') {
                     // 先删除文件
                     // await fs.unlinkSync(path.join(this.app.baseDir, fileInfo.filepath));
-                    await ctx.app.fujianOss.delete(fileInfo.filepath);
+                    await ctx.app.fujianOss.delete(ctx.app.config.fujianOssFolder + fileInfo.filepath);
                     // 再删除数据库
                     await ctx.service.stageShoufangAtt.deleteById(data.id);
                     responseData.data = '';

+ 2 - 2
app/extend/helper.js

@@ -1218,7 +1218,7 @@ module.exports = {
                 if (att.filepath && fs.existsSync(path.join(this.app.baseDir, att.filepath))) {
                     await fs.unlinkSync(path.join(this.app.baseDir, att.filepath));
                 } else if (att.filepath) {
-                    await this.ctx.app.fujianOss.delete(att.filepath);
+                    await this.ctx.app.fujianOss.delete(this.ctx.app.config.fujianOssFolder + att.filepath);
                 }
             }
         }
@@ -1424,7 +1424,7 @@ module.exports = {
         if (!_.includes(path, 'app/')) {
             path = 'app/' + path;
         }
-        const result = await this.ctx.app.fujianOss.get(path);
+        const result = await this.ctx.app.fujianOss.get(this.ctx.app.config.fujianOssFolder + path);
         if (result.res.status !== 200) {
             throw '该文件不存在';
         }

+ 1 - 1
app/service/stage_detail_att.js

@@ -133,7 +133,7 @@ module.exports = app => {
             // if (fs.existsSync(path.join(this.ctx.app.baseDir, att.filepath))) {
             //     await fs.unlinkSync(path.join(this.ctx.app.baseDir, att.filepath));
             // }
-            await this.ctx.app.fujianOss.delete(att.filepath);
+            await this.ctx.app.fujianOss.delete(ctx.app.config.fujianOssFolder + att.filepath);
 
 
             await this._complete4Output(detailAtt);

+ 2 - 2
app/service/stage_shoufang.js

@@ -42,7 +42,7 @@ module.exports = app => {
                 const qr_png = await qr.image(text || '', { type: 'png', size: size || 5, margin: margin || 1 });
                 const qrcodePath = 'app/public/upload/' + this.ctx.tender.id + '/stage/shoufang/qrcode/' + result.insertId + '.png';
                 // await this.ctx.helper.saveStreamFile(qr_png, path.resolve(this.app.baseDir, 'app/' + qrcodePath));
-                await this.ctx.app.fujianOss.put(qrcodePath, qr_png);
+                await this.ctx.app.fujianOss.put(ctx.app.config.fujianOssFolder + qrcodePath, qr_png);
                 await transaction.update(this.tableName, { id: result.insertId, qrcode: qrcodePath });
                 await transaction.commit();
                 return result;
@@ -72,7 +72,7 @@ module.exports = app => {
                 // if (fs.existsSync(path.join(this.app.baseDir, 'app/' + sfInfo.qrcode))) {
                 //     await fs.unlinkSync(path.join(this.app.baseDir, 'app/' + sfInfo.qrcode));
                 // }
-                await this.ctx.app.fujianOss.delete(sfInfo.qrcode);
+                await this.ctx.app.fujianOss.delete(ctx.app.config.fujianOssFolder + sfInfo.qrcode);
                 await transaction.delete(this.ctx.service.stageShoufangAtt.tableName, { sfid });
                 await transaction.delete(this.tableName, { id: sfid });
                 await transaction.commit();

+ 2 - 1
config/config.default.js

@@ -219,7 +219,8 @@ module.exports = appInfo => {
         },
     };
 
-    config.fujianOssPath = 'https://jiliang-saas.smartcost.com.cn/';
+    config.fujianOssPath = 'https://jiliang-saas-oss.smartcost.com.cn/';
+    config.fujianOssFolder = '';
 
     config.syncUrl = 'https://sync.jl.smartcost.com.cn/';
 

+ 2 - 1
config/config.local.js

@@ -108,7 +108,8 @@ module.exports = appInfo => {
         },
     };
 
-    config.fujianOssPath = 'https://jiliang-qa.smartcost.com.cn/';
+    config.fujianOssPath = 'https://jiliang-qa-oss.smartcost.com.cn/qa/';
+    config.fujianOssFolder = 'qa/';
 
     // 自带接口系统地址
     config.syncUrl = 'http://127.0.0.1:7169/';

+ 2 - 1
config/config.qa.js

@@ -70,7 +70,8 @@ module.exports = appInfo => {
         },
     };
 
-    config.fujianOssPath = 'https://jiliang-qa.smartcost.com.cn/';
+    config.fujianOssPath = 'https://jiliang-qa-oss.smartcost.com.cn/qa/';
+    config.fujianOssFolder = 'qa/';
 
     // 自带接口系统地址
     config.syncUrl = 'http://jlqa.smartcost.com.cn:7169/';

+ 2 - 1
config/config.remoteqa.js

@@ -101,7 +101,8 @@ module.exports = appInfo => {
         },
     };
 
-    config.fujianOssPath = 'https://jiliang-qa.smartcost.com.cn/';
+    config.fujianOssPath = 'https://jiliang-qa-oss.smartcost.com.cn/qa/';
+    config.fujianOssFolder = 'qa/';
 
     config.is_debug = true;
 

+ 2 - 1
config/config.remoteuat.js

@@ -71,7 +71,8 @@ module.exports = appInfo => {
         },
     };
 
-    config.fujianOssPath = 'https://jiliang-qa.smartcost.com.cn/';
+    config.fujianOssPath = 'https://jiliang-qa-oss.smartcost.com.cn/uat/';
+    config.fujianOssFolder = 'uat/';
 
     return config;
 };

+ 2 - 1
config/config.uat.js

@@ -76,7 +76,8 @@ module.exports = appInfo => {
         },
     };
 
-    config.fujianOssPath = 'https://jiliang-qa.smartcost.com.cn/';
+    config.fujianOssPath = 'https://jiliang-qa-oss.smartcost.com.cn/uat/';
+    config.fujianOssFolder = 'uat/';
 
     config.syncUrl = 'http://sync.jluat.smartcost.com.cn/';