This commit is contained in:
gaoshuaixing
2022-02-21 18:12:44 +08:00
parent fcf2833b53
commit fd2d22c239
5 changed files with 9 additions and 61 deletions

View File

@@ -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;

View File

@@ -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

View File

@@ -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'
};

View File

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

View File

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