| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 | 
							- 'use strict';
 
- /**
 
-  *
 
-  *
 
-  * @author Mai
 
-  * @date
 
-  * @version
 
-  */
 
- module.exports = app => {
 
-     class PayAtt extends app.BaseService {
 
-         /**
 
-          * 构造函数
 
-          *
 
-          * @param {Object} ctx - egg全局变量
 
-          * @return {void}
 
-          */
 
-         constructor(ctx) {
 
-             super(ctx);
 
-             this.tableName = 'pay_attachment';
 
-         }
 
-         async getStageData(condition) {
 
-             const files = await this.getAllDataByCondition({
 
-                 where: condition,
 
-                 orders: [['id', 'desc']]
 
-             });
 
-             for (const f of files) {
 
-                 delete f.filepath;
 
-             }
 
-             return files;
 
-         }
 
-         async addFiles(files) {
 
-             await this.db.insert(this.tableName, files);
 
-             return await this.getStageData({ sid: files[0].sid, pid: files[0].pid });
 
-         }
 
-         async delFiles(fileId) {
 
-             const fileInfo = await this.getDataById(fileId);
 
-             if (!fileInfo) throw '不存在该文件';
 
-             if (fileInfo.uid !== this.ctx.session.sessionUser.accountId) throw '您无权删除该文件';
 
-             await this.db.delete(this.tableName, { id: fileId });
 
-             return await this.getStageData({ sid: fileInfo.sid, pid: fileInfo.pid });
 
-         }
 
-     }
 
-     return PayAtt;
 
- };
 
 
  |