From 700a19b86ae7870004d462ed72976dcf5cc0b17f Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Tue, 10 May 2022 10:43:39 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/dataease/controller/sys/SysUserController.java | 10 ++++++---- .../src/main/resources/i18n/messages_en_US.properties | 6 +++++- .../src/main/resources/i18n/messages_zh_CN.properties | 4 ++++ .../src/main/resources/i18n/messages_zh_TW.properties | 6 +++++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/io/dataease/controller/sys/SysUserController.java b/backend/src/main/java/io/dataease/controller/sys/SysUserController.java index 5cd12f259c..711a574880 100644 --- a/backend/src/main/java/io/dataease/controller/sys/SysUserController.java +++ b/backend/src/main/java/io/dataease/controller/sys/SysUserController.java @@ -4,6 +4,8 @@ import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.xiaoymin.knife4j.annotations.ApiSupport; import io.dataease.auth.api.dto.CurrentUserDto; +import io.dataease.exception.DataEaseException; +import io.dataease.i18n.Translator; import io.dataease.plugins.common.base.domain.SysRole; import io.dataease.commons.utils.AuthUtils; import io.dataease.commons.utils.PageUtils; @@ -122,17 +124,17 @@ public class SysUserController { Long userId = AuthUtils.getUser().getUserId(); // 防止修改他人信息, 防止必填内容留空 if (!request.getUserId().equals(userId) || request.getEmail() == null || request.getNickName() == null) { - throw new RuntimeException("内容不合法"); + DataEaseException.throwException(Translator.get("i18n_wrong_content")); } // 再次验证,匹配格式 if (!request.getPhone().isEmpty() && !request.getPhone().matches("^1[3|4|5|7|8][0-9]{9}$")) { - throw new RuntimeException("电话格式错误"); + DataEaseException.throwException(Translator.get("i18n_wrong_tel")); } if (!request.getEmail().matches("^[a-zA-Z0-9_._-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$")) { - throw new RuntimeException("邮箱格式错误"); + DataEaseException.throwException(Translator.get("i18n_wrong_email")); } if (!(2 <= request.getNickName().length() && request.getNickName().length() <= 50)) { - throw new RuntimeException("姓名格式错误"); + DataEaseException.throwException(Translator.get("i18n_wrong_name_format")); } sysUserService.updatePersonBasicInfo(request); } diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 41e7b9c1b1..89119243dc 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -123,4 +123,8 @@ theme_name_empty=name can not be empty i18n_public_chart=【Public Chart】 i18n_class_blue=Blue Tone 插件管理=Plugins -i18n_plugin_not_allow_delete=The plugin in in use cannot be deleted \ No newline at end of file +i18n_plugin_not_allow_delete=The plugin in in use cannot be deleted +i18n_wrong_content=Wrong content +i18n_wrong_tel=Wrong tel format +i18n_wrong_email=Wrong email format +i18n_wrong_name_format=Wrong name format diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 92d7c9ab32..86b0db5e04 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -123,4 +123,8 @@ i18n_public_chart=【存量视图】 i18n_class_blue=蓝色调 插件管理=插件管理 i18n_plugin_not_allow_delete=正在使用的插件不允许删除 +i18n_wrong_content=内容不合法 +i18n_wrong_tel=电话格式错误 +i18n_wrong_email=邮箱格式错误 +i18n_wrong_name_format=姓名格式错误 diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 6257dd4ede..47bcb1d54b 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -123,4 +123,8 @@ theme_name_empty=名稱不能為空 i18n_public_chart=【存量视图】 i18n_class_blue=蓝色调 插件管理=插件管理 -i18n_plugin_not_allow_delete=正在使用的插件不允許刪除 \ No newline at end of file +i18n_plugin_not_allow_delete=正在使用的插件不允許刪除 +i18n_wrong_content=內容不合法 +i18n_wrong_tel=電話格式錯誤 +i18n_wrong_email=郵箱格式錯誤 +i18n_wrong_name_format=姓名格式錯誤