From 8057c0f18fc8ac800f1f956a515dcd4bfa189a81 Mon Sep 17 00:00:00 2001 From: PL <774412461@qq.com> Date: Tue, 29 Oct 2024 16:04:54 +0800 Subject: [PATCH] =?UTF-8?q?update:=E4=BC=98=E5=8C=96=E8=AF=84=E8=AF=AD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E9=99=90=E5=88=B6=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ChatMessageServiceImpl.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java b/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java index c755803..92083e7 100644 --- a/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java +++ b/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java @@ -542,15 +542,23 @@ public class ChatMessageServiceImpl implements ChatMessageService { throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "评语类型异常"); } - String limitChat = "。限制条件如下:1.%s字左右;2.直接返回评价的内容;3.评价开头不要提示语;4.评价开头不允许出现特殊字符。"; + String limitChat = "。限制条件如下:1.%s字左右;2.直接返回评价的内容;3.评价开头不要提示语;4.评价开头不允许出现特殊字符;"; int size = chatCommentsDto.getSize() > 0 ? chatCommentsDto.getSize() : 200; builder.append(String.format(limitChat, size)); //用户自定义限制条件 - if (chatCommentsDto.getLimitTexts() != null) { - int serialNumber = 5; - for (String str : chatCommentsDto.getLimitTexts()) { - builder.append(serialNumber).append(".").append(limitChat).append(";"); + if (chatCommentsDto.getLimitTexts() != null && !chatCommentsDto.getLimitTexts().isEmpty()) { + int serialNumber = 5; //用户自定义限制条件数量标识 + List limitTexts = chatCommentsDto.getLimitTexts(); //获取自定义限制条件内容 + int length = limitTexts.size(); //数组大小 + for (int i = 0; i < length; i++) { + String str = limitTexts.get(i); + builder.append(serialNumber).append(".").append(str); + if (i < length - 1) { + builder.append(";"); + }else { + builder.append("。"); + } serialNumber += 1; } }