2025-09-22 17:06:47 +08:00
|
|
|
|
package com.ruoyi.cms.util;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
public class StringUtil {
|
2025-10-23 14:38:20 +08:00
|
|
|
|
|
2025-11-15 14:04:05 +08:00
|
|
|
|
/*1101(求职者)、1102(招聘者)、1103(网格员)、1104(内部工作者)*/
|
|
|
|
|
|
public static final Long COMPANY_ADMIN_ROLE_KEY = 1002L;
|
2025-10-23 14:38:20 +08:00
|
|
|
|
|
2025-10-25 11:54:18 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 企业用户
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static final String IS_COMPANY_USER = "0";
|
|
|
|
|
|
|
2025-10-27 11:59:10 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* pc端-求职者
|
|
|
|
|
|
*/
|
2025-11-15 14:04:05 +08:00
|
|
|
|
public static final String SYS_QZZ = "1101";
|
2025-10-27 11:59:10 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* pc端-企业
|
|
|
|
|
|
*/
|
2025-11-15 14:04:05 +08:00
|
|
|
|
public static final String SYS_QY = "1102";
|
2025-10-27 11:59:10 +08:00
|
|
|
|
|
2025-11-17 18:08:26 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 互联网用户头
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static final String USER_KEY="hlw_";
|
|
|
|
|
|
|
2025-11-18 18:43:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 岗位互联网
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static final String BASE_WW_GW="http://http://222.80.110.161:11111/kashi/job-portal/detail/";
|
|
|
|
|
|
|
2025-09-22 17:06:47 +08:00
|
|
|
|
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("列表为空,无法找到最大值")); // 如果列表为空,抛出异常
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-23 10:54:46 +08:00
|
|
|
|
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
|
|
|
|
|
|
}
|
2025-09-30 18:32:20 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 脱敏逻辑:前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);
|
|
|
|
|
|
}
|
2025-09-22 17:06:47 +08:00
|
|
|
|
}
|