From c14c0a9cba8d45705b3814dd59c6344785abfdb7 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Thu, 28 Jul 2022 11:09:05 +0800 Subject: [PATCH] =?UTF-8?q?refactor(xpack):=20=E6=9D=83=E9=99=90=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E4=BA=A4=E4=BA=92=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataease/plugins/server/XAuthServer.java | 20 ++++++++++++++++++- frontend/src/lang/en.js | 3 ++- frontend/src/lang/tw.js | 3 ++- frontend/src/lang/zh.js | 3 ++- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/dataease/plugins/server/XAuthServer.java b/backend/src/main/java/io/dataease/plugins/server/XAuthServer.java index 9b1b32e2ef..331d6b1c58 100644 --- a/backend/src/main/java/io/dataease/plugins/server/XAuthServer.java +++ b/backend/src/main/java/io/dataease/plugins/server/XAuthServer.java @@ -9,19 +9,25 @@ import io.dataease.controller.handler.annotation.I18n; import io.dataease.dto.SysLogDTO; import io.dataease.listener.util.CacheUtils; import io.dataease.plugins.common.dto.DatasourceBaseType; +import io.dataease.plugins.common.dto.datasource.DataSourceType; import io.dataease.plugins.config.SpringContextUtil; import io.dataease.plugins.xpack.auth.dto.request.XpackBaseTreeRequest; import io.dataease.plugins.xpack.auth.dto.request.XpackSysAuthRequest; import io.dataease.plugins.xpack.auth.dto.response.XpackSysAuthDetail; import io.dataease.plugins.xpack.auth.dto.response.XpackSysAuthDetailDTO; import io.dataease.plugins.xpack.auth.dto.response.XpackVAuthModelDTO; +import io.dataease.service.datasource.DatasourceService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.web.bind.annotation.*; import io.dataease.plugins.xpack.auth.service.AuthXpackService; import springfox.documentation.annotations.ApiIgnore; + +import javax.annotation.Resource; import java.util.*; +import java.util.stream.Collectors; + @ApiIgnore @RequestMapping("/plugin/auth") @RestController @@ -29,6 +35,9 @@ public class XAuthServer { private static final Set cacheTypes = new HashSet<>(); + @Resource + private DatasourceService datasourceService; + @RequiresPermissions("auth:read") @PostMapping("/authModels") @I18n @@ -149,7 +158,16 @@ public class XAuthServer { @GetMapping("/getDatasourceTypes") public List getDatasourceTypes(){ + Collection activeType = datasourceService.types(); + Map activeTypeMap = activeType.stream().collect(Collectors.toMap(DataSourceType::getType, DataSourceType::getName)); + activeTypeMap.put("all","所有数据源"); AuthXpackService sysAuthService = SpringContextUtil.getBean(AuthXpackService.class); - return sysAuthService.getDatasourceTypes(); + List presentTypes = sysAuthService.getDatasourceTypes(); + presentTypes.stream().forEach(datasourceBaseType -> { + if(activeTypeMap.get(datasourceBaseType.getType())!=null){ + datasourceBaseType.setName(activeTypeMap.get(datasourceBaseType.getType())); + } + }); + return presentTypes; } } diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js index b4aaafe832..96bdeb3e6b 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -1880,7 +1880,8 @@ export default { }, auth: { - no_item_selected: 'Please select resources on the left', + no_item_selected: 'Please select organization、user or role on the left', + no_resource_selected: 'Please select resource on the left', search_pre: 'Search by ', search_suf: ' name', separate_auth: 'Separate Authorization', diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index 59e0f75302..73efb34234 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -1889,7 +1889,8 @@ export default { }, auth: { - no_item_selected: '请在左侧选择资源', + no_item_selected: '请在左侧选择组织、角色或用户', + no_resource_selected: '请在左侧选择资源', search_pre: '通过', search_suf: '名称来搜索', separate_auth: '单独授权', diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index 1ff2688228..ec097f9a7c 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -1898,7 +1898,8 @@ export default { }, auth: { - no_item_selected: '请在左侧选择资源', + no_item_selected: '请在左侧选择组织、角色或用户', + no_resource_selected: '请在左侧选择资源', search_pre: '通过', search_suf: '名称来搜索', separate_auth: '单独授权',