Browse Source

指标库 no.2 up

laiguoran 7 năm trước cách đây
mục cha
commit
db8184b5fd
3 tập tin đã thay đổi với 18 bổ sung2 xóa
  1. 14 1
      app/base/base_service.js
  2. 1 0
      app/router.js
  3. 3 1
      package.json

+ 14 - 1
app/base/base_service.js

@@ -9,7 +9,8 @@
  */
 
 const Service = require('egg').Service;
-
+// sql拼装器
+const SqlBuilder = require('../lib/sql_builder');
 class BaseService extends Service {
     /**
      * 构造函数
@@ -20,6 +21,7 @@ class BaseService extends Service {
     constructor(ctx) {
         super(ctx);
         this.db = this.app.mysql;
+        this.sqlBuilder = null;
     }
 
     /**
@@ -42,6 +44,17 @@ class BaseService extends Service {
     }
 
     /**
+     * 初始化sqlBuilder
+     *
+     * @return {void}
+     */
+    initSqlBuilder() {
+        if (this.sqlBuilder === null) {
+            this.sqlBuilder = new SqlBuilder();
+        }
+    }
+
+    /**
      * 根据id查找数据
      *
      * @param {Number} id - 数据库中的id

+ 1 - 0
app/router.js

@@ -16,6 +16,7 @@ module.exports = app => {
 
     // 指标库
     app.get('/lib', sessionAuth, 'libController.index');
+    app.post('/lib/upload', sessionAuth, 'libController.upload');
 
     // 指标模板
     app.get('/template', sessionAuth, 'templateController.index');

+ 3 - 1
package.json

@@ -4,6 +4,7 @@
   "description": "SmartCost Index System",
   "private": true,
   "dependencies": {
+    "await-stream-ready": "^1.0.1",
     "egg": "^2.2.1",
     "egg-mysql": "^3.0.0",
     "egg-redis": "^2.0.0",
@@ -31,11 +32,12 @@
     "start": "egg-scripts start --daemon --title=egg-server-index_sys",
     "stop": "egg-scripts stop --title=egg-server-index_sys",
     "dev": "egg-bin dev --port 7003",
-    "dev-qa": "set EGG_SERVER_ENV=qa && egg-bin dev --port 7003",
+    "dev-qa": "set EGG_SERVER_ENV=qa&&egg-bin dev --port 7003",
     "dev-local": "set EGG_SERVER_ENV=local && egg-bin dev --port 7003",
     "debug": "egg-bin debug",
     "test": "npm run lint -- --fix && npm run test-local",
     "test-local": "egg-bin test",
+    "test-qa": "set EGG_SERVER_ENV=qa&&egg-bin test",
     "cov": "egg-bin cov",
     "lint": "eslint .",
     "ci": "npm run lint && npm run cov",