From 08d9c80b96a3afb54d60206a36c2922ade57c018 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Wed, 22 Dec 2021 16:19:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BD=E9=99=85=E5=8C=96):=20=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=BF=94=E5=9B=9E=E4=BF=A1=E6=81=AF=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --user=郭雨琦 接口返回信息国际化 --- .../service/EnvironmentGroupService.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/io/metersphere/service/EnvironmentGroupService.java b/backend/src/main/java/io/metersphere/service/EnvironmentGroupService.java index 28e064ff2f..efa5d97b5c 100644 --- a/backend/src/main/java/io/metersphere/service/EnvironmentGroupService.java +++ b/backend/src/main/java/io/metersphere/service/EnvironmentGroupService.java @@ -19,14 +19,12 @@ import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionUtils; import org.springframework.beans.BeanUtils; +import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; import java.util.stream.Collectors; /** @@ -159,9 +157,16 @@ public class EnvironmentGroupService { } private void checkEnvironmentGroup(EnvironmentGroupRequest request) { + Locale locale = LocaleContextHolder.getLocale(); String name = request.getName(); if (StringUtils.isBlank(name)) { - MSException.throwException("environment group name is null."); + if(Locale.US.toString().equalsIgnoreCase(locale.toString())){ + MSException.throwException("environment group name is null."); + }else if(Locale.TRADITIONAL_CHINESE.toString().equalsIgnoreCase(locale.toString())){ + MSException.throwException("環境組名稱不存在。"); + }else{ + MSException.throwException("环境组名称不存在。"); + } } EnvironmentGroupExample environmentGroupExample = new EnvironmentGroupExample(); @@ -173,7 +178,13 @@ public class EnvironmentGroupService { } if (environmentGroupMapper.countByExample(environmentGroupExample) > 0) { - MSException.throwException("环境组名称 " + request.getName() + " 已存在!"); + if(Locale.US.toString().equalsIgnoreCase(locale.toString())){ + MSException.throwException("Environment group name " + request.getName() + " already exists!"); + }else if(Locale.TRADITIONAL_CHINESE.toString().equalsIgnoreCase(locale.toString())){ + MSException.throwException("環境組名稱 " + request.getName() + " 已存在!"); + }else{ + MSException.throwException("环境组名称 " + request.getName() + " 已存在!"); + } } }