Explorar o código

1. 更新配置
2. 台账一轮审核完成后,备份台账数据

MaiXinRong %!s(int64=7) %!d(string=hai) anos
pai
achega
76bca7a816
Modificáronse 3 ficheiros con 54 adicións e 1 borrados
  1. 20 0
      app/service/ledger_audit.js
  2. 33 0
      config/config.default.js
  3. 1 1
      config/menu.js

+ 20 - 0
app/service/ledger_audit.js

@@ -192,6 +192,22 @@ module.exports = app => {
         }
 
         /**
+         * 拷贝一份台账备份(每一次审批结束时)
+         * @param {Number} tenderId - 标段Id
+         * @param transaction - 事务
+         * @param {Number} times - 次数
+         * @returns {Promise<void>}
+         * @private
+         */
+        async _copyHisytoryLedger(tenderId, transaction, times = 1) {
+            const sql = 'Insert Into ?? ' +
+                'Select *, ? As times From ?? ' +
+                'Where ?? = ?';
+            const sqlParam = [this.tableName + '_copy', times, this.ctx.service.ledger.tableName, 'tender_id', tenderId];
+            return await transaction.query(sql, sqlParam);
+        }
+
+        /**
          * 审批
          * @param {Number} tenderId - 标段id
          * @param {auditConst.status.checked|auditConst.status.checkNo} checkType - 审批结果
@@ -221,6 +237,8 @@ module.exports = app => {
                     } else {
                         // 同步标段信息
                         await transaction.update(this.ctx.service.tender.tableName, {id: tenderId, ledger_status: checkType});
+                        // 拷贝备份台账数据
+                        await this._copyHisytoryLedger(tenderId, times);
                     }
                 } else {
                     // 同步标段信息
@@ -235,6 +253,8 @@ module.exports = app => {
                         a.status = auditConst.status.uncheck;
                     }
                     await transaction.insert(this.tableName, auditors);
+                    // 拷贝备份台账数据
+                    await this._copyHisytoryLedger(tenderId, times);
                 }
 
                 await transaction.commit();

+ 33 - 0
config/config.default.js

@@ -4,6 +4,39 @@ const path = require('path');
 module.exports = appInfo => {
     const config = {};
 
+    // 数据库配置
+    config.mysql = {
+        client: {
+            // host
+            host: '127.0.0.1',
+            // 端口号
+            port: '3306',
+            // 用户名
+            user: 'root',
+            // 密码
+            password: 'root',
+            // 数据库名
+            database: 'calculation',
+        },
+        // 是否加载到 app 上,默认开启
+        app: true,
+        // 是否加载到 agent 上,默认关闭
+        agent: false,
+    };
+    // 表名前缀
+    config.tablePrefix = 'zh_';
+
+    // redis设置
+    config.redis = {
+        client: {
+            host: '127.0.0.1',
+            port: '6379',
+            password: 'test',
+            db: '0',
+        },
+        agent: true,
+    };
+
     // should change to your own
     config.keys = appInfo.name + '_1503910434503_882';
 

+ 1 - 1
config/menu.js

@@ -53,7 +53,7 @@ const menu = {
                 url: '/ledger/explode',
             },
             change: {
-                name: '台账变更',
+                name: '台账修订',
                 url: '/ledger/change',
             },
             index: {