diff --git a/backend/src/main/java/io/dataease/controller/datasource/DatasourceController.java b/backend/src/main/java/io/dataease/controller/datasource/DatasourceController.java index d6f375fa6f..0103a5398c 100644 --- a/backend/src/main/java/io/dataease/controller/datasource/DatasourceController.java +++ b/backend/src/main/java/io/dataease/controller/datasource/DatasourceController.java @@ -52,6 +52,20 @@ public class DatasourceController { return datasourceService.addDatasource(datasource); } + @RequiresPermissions("datasource:read") + @DePermission(type = DePermissionType.DATASOURCE, value = "id", level = ResourceAuthLevel.DATASOURCE_LEVEL_MANAGE) + @ApiOperation("更新数据源") + @PostMapping("/update") + @DeLog( + operatetype = SysLogConstants.OPERATE_TYPE.MODIFY, + sourcetype = SysLogConstants.SOURCE_TYPE.DATASOURCE, + positionIndex = 0, positionKey = "type", + value = "id" + ) + public void updateDatasource(@RequestBody UpdataDsRequest dsRequest) throws Exception { + datasourceService.updateDatasource(dsRequest); + } + @RequiresPermissions("datasource:read") @ApiOperation("数据源类型") @GetMapping("/types") @@ -106,20 +120,6 @@ public class DatasourceController { return resultHolder; } - @RequiresPermissions("datasource:read") - @DePermission(type = DePermissionType.DATASOURCE, value = "id", level = ResourceAuthLevel.DATASOURCE_LEVEL_MANAGE) - @ApiOperation("更新数据源") - @PostMapping("/update") - @DeLog( - operatetype = SysLogConstants.OPERATE_TYPE.MODIFY, - sourcetype = SysLogConstants.SOURCE_TYPE.DATASOURCE, - positionIndex = 0, positionKey = "type", - value = "id" - ) - public void updateDatasource(@RequestBody UpdataDsRequest dsRequest) throws Exception { - datasourceService.updateDatasource(dsRequest); - } - @DePermission(type = DePermissionType.DATASOURCE) @ApiOperation("查询数据源下属所有表") @PostMapping("/getTables/{id}") diff --git a/backend/src/main/java/io/dataease/service/datasource/DatasourceService.java b/backend/src/main/java/io/dataease/service/datasource/DatasourceService.java index cc63df8cac..ee68b2e33e 100644 --- a/backend/src/main/java/io/dataease/service/datasource/DatasourceService.java +++ b/backend/src/main/java/io/dataease/service/datasource/DatasourceService.java @@ -263,12 +263,9 @@ public class DatasourceService { if (!types().stream().map(DataSourceType::getType).collect(Collectors.toList()).contains(updataDsRequest.getType())) { throw new Exception("Datasource type not supported."); } - System.out.println(updataDsRequest.getConfiguration()); - System.out.println(updataDsRequest.isConfigurationEncryption()); if(updataDsRequest.isConfigurationEncryption()){ updataDsRequest.setConfiguration(new String(java.util.Base64.getDecoder().decode(updataDsRequest.getConfiguration()))); } - System.out.println(updataDsRequest.getConfiguration()); checkName(updataDsRequest.getName(), updataDsRequest.getType(), updataDsRequest.getId()); Datasource datasource = new Datasource(); datasource.setName(updataDsRequest.getName()); @@ -277,15 +274,22 @@ public class DatasourceService { datasource.setCreateTime(null); datasource.setType(updataDsRequest.getType()); datasource.setUpdateTime(System.currentTimeMillis()); - Provider datasourceProvider = ProviderFactory.getProvider(updataDsRequest.getType()); datasourceProvider.checkConfiguration(datasource); - checkAndUpdateDatasourceStatus(datasource); - DatasourceExample example = new DatasourceExample(); - example.createCriteria().andIdEqualTo(updataDsRequest.getId()); - datasourceMapper.updateByExampleSelective(datasource, example); - handleConnectionPool(updataDsRequest.getId()); + if(StringUtils.isNotEmpty(updataDsRequest.getId())){ + DatasourceExample example = new DatasourceExample(); + example.createCriteria().andIdEqualTo(updataDsRequest.getId()); + datasourceMapper.updateByExampleSelective(datasource, example); + handleConnectionPool(updataDsRequest.getId()); + }else { + datasource.setId(UUID.randomUUID().toString()); + datasource.setCreateTime(System.currentTimeMillis()); + datasourceMapper.insert(datasource); + handleConnectionPool(datasource, "add"); + sysAuthService.copyAuth(datasource.getId(), SysAuthConstants.AUTH_SOURCE_TYPE_DATASOURCE); + } + } private void handleConnectionPool(String datasourceId) { diff --git a/backend/src/main/resources/db/migration/V46__1.18.sql b/backend/src/main/resources/db/migration/V46__1.18.sql index e3ae313c56..5cd400b8b4 100644 --- a/backend/src/main/resources/db/migration/V46__1.18.sql +++ b/backend/src/main/resources/db/migration/V46__1.18.sql @@ -8,3 +8,8 @@ WHERE `id` = 'system_1'; ALTER TABLE `sys_task` ADD COLUMN `status` tinyint(1) NULL DEFAULT 1 COMMENT '运行状态' AFTER `create_time`; + + +INSERT INTO `sys_menu` (`menu_id`, `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`) VALUES (1100, 1, 0, 1, '血缘关系', 'sys-relationship', 'system/relationship/index', 1002, 'sys-relationship', 'relationship', 0, 0, 0, 'relationship:read'); + +UPDATE `sys_menu` SET `menu_sort` = 1003 WHERE (`menu_id` = 101); diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 375af2fc78..1b815bb37e 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -259,4 +259,5 @@ I18N_LOG_FORMAT_PREFIX=With authority of %s\u3010%s\u3011 \u7F16\u8F91\u8BB0\u5F55=Edit record \u5220\u9664\u8BB0\u5F55=Delete record \u6C34\u5370\u7BA1\u7406=Watermark +\u8840\u7F18\u5173\u7CFB=Relationship diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index c1a7f7fb66..188ff1523f 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -259,5 +259,6 @@ I18N_LOG_FORMAT_PREFIX=\u4EE5%s\u3010%s\u3011\u6743\u9650 \u7F16\u8F91\u8BB0\u5F55=\u7F16\u8F91\u8BB0\u5F55 \u5220\u9664\u8BB0\u5F55=\u5220\u9664\u8BB0\u5F55 \u6C34\u5370\u7BA1\u7406=\u6C34\u5370\u7BA1\u7406 +\u8840\u7F18\u5173\u7CFB=\u8840\u7F18\u5173\u7CFB diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 116f5f4533..1301d7a0c0 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -255,3 +255,4 @@ I18N_LOG_FORMAT_PREFIX=\u4EE5%s\u3010%s\u3011\u6B0A\u9650 \u7F16\u8F91\u8BB0\u5F55=\u7DE8\u8F2F\u8A18\u9304 \u5220\u9664\u8BB0\u5F55=\u522A\u9664\u8A18\u9304 \u6C34\u5370\u7BA1\u7406=\u6C34\u5370\u7BA1\u7406 +\u8840\u7F18\u5173\u7CFB=\u8840\u7DE3\u95DC\u7CFB diff --git a/frontend/src/icons/svg/sys-relationship.svg b/frontend/src/icons/svg/sys-relationship.svg new file mode 100644 index 0000000000..ec0619f3c7 --- /dev/null +++ b/frontend/src/icons/svg/sys-relationship.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js index 1a9c9056d3..e4aabfde41 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -1822,6 +1822,7 @@ export default { please_input_url: 'Please enter url address', please_input_port: 'Please enter port', modify: 'Edit data Source', + copy: 'Copy datasource', validate_success: 'Verification successful', validate: 'Validate', search_by_name: 'Search by name', diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index 04ee75543b..7f01dc8897 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -1816,6 +1816,7 @@ export default { please_input_url: '請輸入URL地址', please_input_port: '請輸入端口', modify: '編輯數據源', + copy: '複製數據源', validate_success: '校驗成功', validate: '校驗', search_by_name: '根據名稱搜索', diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index aabd516a5f..d347e91bad 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -1815,6 +1815,7 @@ export default { please_input_url: '请输入URL地址', please_input_port: '请输入端口', modify: '编辑数据源', + copy: '复制数据源', validate_success: '校验成功', validate: '校验', search_by_name: '根据名称搜索', diff --git a/frontend/src/views/system/datasource/DsForm.vue b/frontend/src/views/system/datasource/DsForm.vue index 3b0bccb9d3..f325053def 100644 --- a/frontend/src/views/system/datasource/DsForm.vue +++ b/frontend/src/views/system/datasource/DsForm.vue @@ -95,6 +95,9 @@ export default { }, tips() { const { id, showModel } = this.params + if(showModel === 'copy'){ + return this.$t('datasource.copy') + } return id && showModel === 'show' && !this.canEdit ? this.$t('datasource.show_info') : this.formType === 'add' diff --git a/frontend/src/views/system/datasource/DsFormContent.vue b/frontend/src/views/system/datasource/DsFormContent.vue index aabaaae3bc..98a9e70ca1 100644 --- a/frontend/src/views/system/datasource/DsFormContent.vue +++ b/frontend/src/views/system/datasource/DsFormContent.vue @@ -716,6 +716,9 @@ export default { res.data.apiConfiguration = JSON.parse(Base64.decode(res.data.apiConfigurationStr)) } this.params = { ...res.data, showModel } + if(showModel === 'copy'){ + this.params.id = '' + } this.$emit('setParams', { ...this.params }) }).finally(() => { this.$emit('update:formLoading', false) diff --git a/frontend/src/views/system/datasource/DsTree.vue b/frontend/src/views/system/datasource/DsTree.vue index 4196212809..44f4ddc3fc 100644 --- a/frontend/src/views/system/datasource/DsTree.vue +++ b/frontend/src/views/system/datasource/DsTree.vue @@ -173,6 +173,10 @@ {{ $t('chart.edit') }} + + + {{ $t('commons.copy') }} + {{ $t('chart.delete') }} @@ -651,6 +655,9 @@ export default { case 'edit': this._handleEditer(data) break + case 'copy': + this._handleCopy(data) + break case 'delete': this._handleDelete(data) break @@ -669,6 +676,17 @@ export default { this.dialogTitle = this.$t('datasource.edit_driver') this.driverForm = { ...row } }, + _handleCopy(row){ + if (this.showView === 'Datasource') { + const param = { ...row, ...{ showModel: 'copy' }} + this.switchMain('DsForm', param, this.tData, this.dsTypes) + this.currentNodeId && sessionStorage.setItem('datasource-current-node', this.currentNodeId) + return + } + this.editDriver = true + this.dialogTitle = this.$t('commons.copy') + this.driverForm = { ...row } + }, _handleDelete(datasource) { const params = { title: diff --git a/frontend/src/views/system/relationship/index.vue b/frontend/src/views/system/relationship/index.vue new file mode 100644 index 0000000000..1cb6132949 --- /dev/null +++ b/frontend/src/views/system/relationship/index.vue @@ -0,0 +1,24 @@ + + + this is blood relationship page for shutong + {{ text }} + + +