gaoshuaixing 3 years ago
parent
commit
fd2d22c239

+ 3 - 47
app/controller/example.js

@@ -78,6 +78,9 @@ class ExampleController extends BaseController {
     self.sendData(data);
   }
 
+  /**
+   * json数据库操作
+   */   
   async dbOperation() {
     const self = this;
     const { ctx, service } = this;
@@ -108,53 +111,6 @@ class ExampleController extends BaseController {
     self.sendSuccess(data);
   }
 
-  async addTestData() {
-    const self = this;
-    const { service } = this;
-    const data = {};
-
-    const userInfo = {
-      name: 'jame',
-      age: 18,
-      gender: 'man'
-    }
-    await service.storage.addTestData(userInfo);
-
-    self.sendSuccess(data);
-  }
-
-  async delTestData() {
-    const self = this;
-    const { service } = this;
-    const data = {};
-    const name = 'jame';
-    await service.storage.delTestData(name);
-
-    self.sendSuccess(data);
-  }
-
-  async updateTestData() {
-    const self = this;
-    const { service } = this;
-    const data = {};
-    const name = 'jame';
-    const age = 20;
-    await service.storage.updateTestData(name, age);
-
-    self.sendSuccess(data);
-  }
-
-  async getTestData() {
-    const self = this;
-    const { service } = this;
-    const data = {};
-    const name = 'jame';
-    const user = await service.storage.getTestData(name);
-    data.user = user;
-
-    self.sendSuccess(data);
-  }
-
   async autoLaunchEnable() {
     const { service } = this;
 

+ 0 - 8
app/router/example.js

@@ -8,14 +8,6 @@ module.exports = app => {
 
   // upload file
   router.post('/api/example/uploadFile', controller.example.uploadFile);
-  // add test data
-  router.post('/api/example/addTestData', controller.example.addTestData);
-  // delete test data
-  router.post('/api/example/delTestData', controller.example.delTestData);
-  // update test data
-  router.post('/api/example/updateTestData', controller.example.updateTestData);
-  // get test data
-  router.post('/api/example/getTestData', controller.example.getTestData);
   // open launch
   router.post('/api/example/autoLaunchEnable', controller.example.autoLaunchEnable);
   // close launch 

+ 4 - 4
app/service/storage.js

@@ -6,10 +6,10 @@ const _ = require('lodash');
 
 class StorageService extends Service {
 
-  constructor () {
-    super();
-    this.systemDB = Storage.JsonDB.connection('system');
-    this.demoDB = Storage.JsonDB.connection('demo');  
+  constructor (ctx) {
+    super(ctx);
+    this.systemDB = Storage.JsonDB.connection('system').db;
+    this.demoDB = Storage.JsonDB.connection('demo').db;  
     this.systemDBKey = {
       cache: 'cache'
     };

+ 1 - 1
frontend/src/views/base/db/Index.vue

@@ -14,7 +14,7 @@
           • 可使用lodash语法
         </a-col>
         <a-col :span="8">
-          • 数据文件db.json在日志同级目录
+          
         </a-col>
       </a-row>
     </div>

+ 1 - 1
frontend/src/views/base/socket/Index.vue

@@ -43,7 +43,7 @@
   </div>
 </template>
 <script>
-import { requestEggApi, ipcApiRoute } from '@/api/main'
+import { ipcApiRoute } from '@/api/main'
 export default {
   data() {
     return {