From 9c21fea0cefd58ae8cd2bc98b06ba12ad98be8cb Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Thu, 27 Jan 2022 14:14:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=BB=E9=A2=98=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E6=8F=90=E7=A4=BA=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/plugins/server/ThemeServer.java | 10 +++++++++- .../src/main/resources/i18n/messages_en_US.properties | 4 +++- .../src/main/resources/i18n/messages_zh_CN.properties | 2 ++ .../src/main/resources/i18n/messages_zh_TW.properties | 2 ++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/io/dataease/plugins/server/ThemeServer.java b/backend/src/main/java/io/dataease/plugins/server/ThemeServer.java index 99dc4c5fec..5e1ee1769d 100644 --- a/backend/src/main/java/io/dataease/plugins/server/ThemeServer.java +++ b/backend/src/main/java/io/dataease/plugins/server/ThemeServer.java @@ -2,6 +2,7 @@ package io.dataease.plugins.server; import java.util.List; +import org.apache.commons.lang3.ObjectUtils; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -11,6 +12,7 @@ import org.springframework.web.multipart.MultipartFile; import io.dataease.commons.exception.DEException; import io.dataease.commons.utils.LogUtil; +import io.dataease.i18n.Translator; import io.dataease.plugins.config.SpringContextUtil; import io.dataease.plugins.xpack.theme.dto.ThemeDto; import io.dataease.plugins.xpack.theme.dto.ThemeItem; @@ -42,7 +44,13 @@ public class ThemeServer { themeXpackService.save(request, bodyFile); } catch (Exception e) { LogUtil.error(e.getMessage(), e); - DEException.throwException(e); + if (ObjectUtils.isNotEmpty(e.getMessage()) && e.getMessage().indexOf("theme_name_repeat") != -1) { + DEException.throwException(Translator.get("theme_name_repeat")); + } else if (ObjectUtils.isNotEmpty(e.getMessage()) && e.getMessage().indexOf("theme_name_empty") != -1) { + DEException.throwException(Translator.get("theme_name_empty")); + } else { + DEException.throwException(e); + } } } diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index a4d73c1fec..8b8f3705cf 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -116,4 +116,6 @@ i18n_rp_exist=Row permission of the same type already exists i18n_field_name_repeat=Field name can't repeat i18n_calc_field_error=Field expression error i18n_cp_exist=Column permission of the same type already exists -connection_failed=Connection Failed \ No newline at end of file +connection_failed=Connection Failed +theme_name_repeat=name of theme has been existed +theme_name_empty=name can not be empty \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 2179e63f7b..e52791f02a 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -116,3 +116,5 @@ i18n_field_name_repeat=字段名不能重复 i18n_calc_field_error=字段表达式语法错误 i18n_cp_exist=已有同类型的列权限存在 connection_failed=连接失败 +theme_name_repeat=名称已存在 +theme_name_empty=名称不能为空 diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 49b17f5dde..c3f6464aaa 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -117,3 +117,5 @@ i18n_field_name_repeat=字段名不能重復 i18n_calc_field_error=字段表達式語法錯誤 i18n_cp_exist=已有同類型的列權限存在 connection_failed=連接失敗 +theme_name_repeat=名稱已存在 +theme_name_empty=名稱不能為空