2025-09-22 17:06:47 +08:00
|
|
|
|
package com.ruoyi.cms.util;
|
|
|
|
|
|
|
2025-12-03 19:42:47 +08:00
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
2025-09-22 17:06:47 +08:00
|
|
|
|
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(内部工作者)*/
|
2025-11-21 17:02:12 +08:00
|
|
|
|
public static final Long COMPANY_ADMIN_ROLE_KEY = 1102L;
|
2025-10-23 14:38:20 +08:00
|
|
|
|
|
2025-12-06 13:31:46 +08:00
|
|
|
|
/************************移动端角色开始***************************/
|
2025-10-25 11:54:18 +08:00
|
|
|
|
/**
|
2025-12-06 13:31:46 +08:00
|
|
|
|
* 移动端-企业用户
|
2025-10-25 11:54:18 +08:00
|
|
|
|
*/
|
|
|
|
|
|
public static final String IS_COMPANY_USER = "0";
|
2025-12-06 13:31:46 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 移动端-求职者
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static final String IS_JOB_REQUEST_USER = "1";
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 移动端-网格员
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static final String IS_GRID_USER = "2";
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 移动端-内部工作者
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static final String IS_INTERNAL_USER = "3";
|
|
|
|
|
|
/************************移动端角色结束***************************/
|
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
|
|
|
|
/**
|
|
|
|
|
|
* 岗位互联网
|
|
|
|
|
|
*/
|
2025-12-19 17:58:31 +08:00
|
|
|
|
public static final String BASE_WW_GW="https://www.xjksly.cn/kashi/job-portal/detail/";
|
2025-11-18 18:43:06 +08:00
|
|
|
|
|
2025-11-25 13:27:10 +08:00
|
|
|
|
/**
|
|
|
|
|
|
*录用
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static final String HIRE_LY="0";
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
*录用-系统
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static final String HIRE_SOURCE_SYSTEM="0";
|
|
|
|
|
|
/**
|
|
|
|
|
|
*录用-招聘会
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static final String HIRE_SOURCE_ZPH="1";
|
2025-12-03 12:46:31 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 标记
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static final boolean PATH_TEST_ENV = true;
|
2025-12-03 12:01:43 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 测试环境附件地址
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static final String PATH_DEV = "http://ks.zhaopinzao8dian.com/file/";
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 正式环境环境地址
|
|
|
|
|
|
*/
|
2025-12-03 19:42:47 +08:00
|
|
|
|
public static final String PATH_PROXY_37 = "http://10.98.80.37/file/";
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 互联网
|
|
|
|
|
|
*/
|
2025-12-19 17:58:31 +08:00
|
|
|
|
public static final String PATH_PROXY_50="https://www.xjksly.cn/file/";
|
2025-12-03 19:42:47 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 经办端
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static final String PATH_PROXY_146="http://10.98.80.146/file/";
|
2025-12-03 12:01:43 +08:00
|
|
|
|
|
2025-11-25 14:40:43 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 身份证规则
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static final String SFZ_VALID_REGEX="^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$";
|
|
|
|
|
|
|
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-12-03 12:46:31 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取附件地址
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2025-12-03 19:42:47 +08:00
|
|
|
|
public static String getFilePath(HttpServletRequest request){
|
|
|
|
|
|
String proxyServer = getProxyServer(request);
|
|
|
|
|
|
if ("proxy-50".equals(proxyServer)) {
|
|
|
|
|
|
return PATH_PROXY_50;
|
|
|
|
|
|
} else if ("proxy-146".equals(proxyServer)) {
|
|
|
|
|
|
return PATH_PROXY_146;
|
|
|
|
|
|
}
|
2025-12-04 11:03:41 +08:00
|
|
|
|
return !PATH_TEST_ENV ? PATH_PROXY_37 : PATH_DEV;
|
2025-12-03 19:42:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 原方法-不传request
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2025-12-03 12:46:31 +08:00
|
|
|
|
public static String getFilePath(){
|
2025-12-04 11:03:41 +08:00
|
|
|
|
return !PATH_TEST_ENV ? PATH_PROXY_37 : PATH_DEV;
|
2025-12-03 19:42:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取nginx地址
|
|
|
|
|
|
* @param request
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
private static String getProxyServer(HttpServletRequest request) {
|
|
|
|
|
|
if (request == null) {
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
return request.getHeader("X-Proxy-Server");
|
2025-12-03 12:46:31 +08:00
|
|
|
|
}
|
2025-09-22 17:06:47 +08:00
|
|
|
|
}
|