From 8a31d895035b0035393184beb246528c4be24a71 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Mon, 19 Oct 2020 12:18:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E8=AF=84=E5=AE=A1=EF=BC=8C=E8=AF=84=E5=AE=A1?= =?UTF-8?q?=E4=BA=BA=E6=98=BE=E7=A4=BAnull?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/service/TestReviewTestCaseService.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/backend/src/main/java/io/metersphere/track/service/TestReviewTestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestReviewTestCaseService.java index 3c0270b8c3..89362dca7e 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestReviewTestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestReviewTestCaseService.java @@ -15,10 +15,12 @@ import io.metersphere.track.dto.TestReviewCaseDTO; import io.metersphere.track.request.testplancase.TestReviewCaseBatchRequest; import io.metersphere.track.request.testreview.DeleteRelevanceRequest; import io.metersphere.track.request.testreview.QueryCaseReviewRequest; +import org.apache.commons.lang3.StringUtils; 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.stream.Collectors; @@ -64,17 +66,17 @@ public class TestReviewTestCaseService { return testCaseReviewUsers.stream().map(TestCaseReviewUsers::getUserId).collect(Collectors.toList()); } - private String getReviewName(List userIds, Map userMap) { - StringBuilder stringBuilder = new StringBuilder(); - String name = ""; - + private String getReviewName(List userIds, Map userMap) { + List userNames = new ArrayList<>(); if (userIds.size() > 0) { for (String id : userIds) { - stringBuilder.append(userMap.get(id)).append("、"); + String n = userMap.get(id); + if (StringUtils.isNotBlank(n)) { + userNames.add(n); + } } - name = stringBuilder.toString().substring(0, stringBuilder.length() - 1); } - return name; + return StringUtils.join(userNames, "、"); } public int deleteTestCase(DeleteRelevanceRequest request) {