From 2f29bfd0849d488ff1997c769b8d6301cd8ceb50 Mon Sep 17 00:00:00 2001 From: maslow Date: Thu, 14 Oct 2021 14:44:31 +0800 Subject: [PATCH] feat(dbm): impl db schema; impl create db; --- packages/system-client/src/api/collec.js | 39 +++- packages/system-client/src/utils/request.js | 4 +- .../src/views/database/collections.vue | 166 +++++++++++++++--- .../system-server/src/router/dbm/create.ts | 44 +++++ packages/system-server/src/router/dbm/get.ts | 10 +- .../system-server/src/router/dbm/index.ts | 13 +- .../system-server/src/router/dbm/proxy.ts | 11 +- .../system-server/src/router/dbm/update.ts | 62 +++++++ 8 files changed, 305 insertions(+), 44 deletions(-) create mode 100644 packages/system-server/src/router/dbm/create.ts create mode 100644 packages/system-server/src/router/dbm/update.ts diff --git a/packages/system-client/src/api/collec.js b/packages/system-client/src/api/collec.js index dbe824a0ac..038ec014d9 100644 --- a/packages/system-client/src/api/collec.js +++ b/packages/system-client/src/api/collec.js @@ -5,9 +5,6 @@ import { Cloud } from 'laf-client-sdk' /** * Get collection list - * @param {*} query - * @param {*} page - * @param {*} pageSize */ export function getCollections() { const appid = store.state.app.appid @@ -17,6 +14,42 @@ export function getCollections() { }) } +/** + * Create collection + * @param {string} collectionName + */ +export function createCollection(collectionName) { + const appid = store.state.app.appid + return request({ + url: `/apps/${appid}/dbm/collections`, + method: 'post', + data: { + collectionName + } + }) +} + +/** + * Update collection + * @param {string} collectionName + * @param {object} validatorSchema + * @param {string} validatorLevel + */ +export function updateCollection(collectionName, validatorSchema, validatorLevel = 'strict') { + const appid = store.state.app.appid + return request({ + url: `/apps/${appid}/dbm/collections`, + method: 'put', + data: { + collectionName, + options: { + validatorSchema, + validatorLevel + } + } + }) +} + /** * 获取集合的索引信息 */ diff --git a/packages/system-client/src/utils/request.js b/packages/system-client/src/utils/request.js index 3402ecdbc9..2d0bda05fc 100644 --- a/packages/system-client/src/utils/request.js +++ b/packages/system-client/src/utils/request.js @@ -2,7 +2,7 @@ import axios from 'axios' import { MessageBox } from 'element-ui' import store from '@/store' import { getToken } from '@/utils/auth' -import { showError, showInfo } from './show' +import { showInfo } from './show' // create an axios instance const service = axios.create({ @@ -66,7 +66,7 @@ service.interceptors.response.use( return Promise.reject(error) } - showError(error.message) + // showError(error.message) return Promise.reject(error) } ) diff --git a/packages/system-client/src/views/database/collections.vue b/packages/system-client/src/views/database/collections.vue index 5aac071fee..0fd5e46406 100644 --- a/packages/system-client/src/views/database/collections.vue +++ b/packages/system-client/src/views/database/collections.vue @@ -4,15 +4,18 @@
搜索 - 新建集合 + 新建集合 索引管理 - 集合结构 + 集合结构 添加记录
- + -
选择集合
+
+ 选择集合 + +
@@ -47,7 +50,6 @@ title="索引管理" size="50%" :visible.sync="showIndexesList" - :direction="direction" >
@@ -74,12 +76,25 @@
+ + + + 保存 + + + + + + 保存 @@ -89,7 +104,26 @@ - + + + + + + + +
+ + 取消 + + 确认 +
+
+ + @@ -120,9 +154,10 @@