终端运维管理优化

This commit is contained in:
zhuxinyu
2023-04-21 13:47:56 +08:00
parent 36afca9f96
commit 85e362adc6
4 changed files with 31 additions and 13 deletions

View File

@@ -24,9 +24,9 @@ import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
@@ -173,6 +173,7 @@ public class EventTemplateServiceImpl extends ServiceImpl<EventTemplateMapper, E
public List<EventReportDictVO> selectReleation(String id) {
List<EventReportDictVO> list = new ArrayList<>();
List<String> configs = templateRelMapper.selectReleation(id);
configs = configs.stream().filter(t -> !isContainChinese(t)).collect(Collectors.toList());
configs.forEach(config -> {
EventReportDictVO eventReportDictVO = new EventReportDictVO();
eventReportDictVO.setName(config);
@@ -182,6 +183,22 @@ public class EventTemplateServiceImpl extends ServiceImpl<EventTemplateMapper, E
return list;
}
/**
* 字符串是否包含中文
*
* @param str 待校验字符串
* @return true 包含中文字符 false 不包含中文字符
*/
public static boolean isContainChinese(String str) {
// if (StringUtils.isEmpty(str)) {
// throw new EmptyException("sms context is empty!");
// }
Pattern p = Pattern.compile("[\u4E00-\u9FA5|\\|\\|\\。|\\|\\|\\《|\\》|\\“|\\”|\\|\\|\\|\\【|\\】]");
Matcher m = p.matcher(str);
return m.find();
}
/**
* 名称重复校验
*/