2.企业联系人管理-添加表(company_contact)补充对应后台代码 3.岗位管理-添加信用代码、薪酬查询条件 4.用户管理-添加身份证显示(脱敏)、是否录用 5.岗位管理-添加字段岗位类型(疆内、疆外)
74 lines
2.5 KiB
Java
74 lines
2.5 KiB
Java
package com.ruoyi.cms.util;
|
||
|
||
import com.ruoyi.cms.domain.query.ESJobSearch;
|
||
|
||
import java.util.ArrayList;
|
||
import java.util.Arrays;
|
||
import java.util.List;
|
||
import java.util.Objects;
|
||
import java.util.stream.Collectors;
|
||
|
||
public class StringUtil {
|
||
public static Boolean isEmptyOrNull(String s){
|
||
if(Objects.isNull(s)){return true;}
|
||
return s.isEmpty();
|
||
}
|
||
/**
|
||
* 将逗号分隔的数字字符串转换为List<Integer>
|
||
*/
|
||
public static List<Integer> convertStringToIntegerList(String input) {
|
||
if (isEmptyOrNull(input)) {
|
||
return new ArrayList<>();
|
||
}
|
||
|
||
return Arrays.stream(input.split(",")) // 按逗号分割字符串
|
||
.map(String::trim) // 去除每个部分的前后空格
|
||
.map(Integer::parseInt) // 将字符串转换为Integer
|
||
.collect(Collectors.toList()); // 收集为List
|
||
}
|
||
/**
|
||
* 将逗号分隔的数字字符串转换为List<Integer>
|
||
*/
|
||
public static List<Long> convertStringToLongList(String input) {
|
||
List<Integer> longs = convertStringToIntegerList(input);
|
||
return longs.stream().map(Long::valueOf).collect(Collectors.toList());
|
||
}
|
||
/**
|
||
* 找到List<Integer>中的最大值
|
||
*/
|
||
public static Integer findMaxValue(String input) {
|
||
List<Integer> numbers = convertStringToIntegerList(input);
|
||
if (numbers == null || numbers.isEmpty()) {
|
||
return null;
|
||
}
|
||
|
||
return numbers.stream()
|
||
.mapToInt(Integer::intValue) // 将Integer转换为int
|
||
.max() // 找到最大值
|
||
.orElseThrow(() -> new RuntimeException("列表为空,无法找到最大值")); // 如果列表为空,抛出异常
|
||
}
|
||
|
||
|
||
public static List<String> convertStringToStringList(String input) {
|
||
if (isEmptyOrNull(input)) {
|
||
return new ArrayList<>();
|
||
}
|
||
|
||
return Arrays.stream(input.split(",")) // 按逗号分割字符串
|
||
.map(String::trim) // 去除每个部分的前后空格
|
||
.collect(Collectors.toList()); // 收集为List
|
||
}
|
||
|
||
/**
|
||
* 脱敏逻辑:前4位 + ***+ 后4位
|
||
* @param idCard
|
||
* @return
|
||
*/
|
||
public static String desensitizeIdCard(String idCard) {
|
||
if (idCard == null || idCard.length() != 18) {
|
||
return idCard; // 非标准身份证号不脱敏(或按规则处理)
|
||
}
|
||
return idCard.substring(0, 4) + "***" + idCard.substring(14);
|
||
}
|
||
}
|