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; } }