1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package com.hz.employmentsite.util;
- import org.springframework.stereotype.Component;
- import java.util.List;
- import java.util.stream.Collectors;
- @Component
- public class StringUtils {
- public boolean IsNullOrEmpty(String value) {
- return value == null || value.length() == 0;
- }
- public <T> String ListToInSql(List<T> list) {
- if (list == null || list.size() <= 0)
- return "";
- String sql = String.join("','", list.stream().map(it -> it.toString()).collect(Collectors.toList()));
- return "'" + sql + "'";
- }
- /**
- * 重要信息脱密
- *
- * @param data 数据
- * @param ciphertext 加密密文
- * @param startLength 开始位置
- * @param endLength 结束位置
- * @return 脱敏后的文本数据
- */
- public String desensitizeData(String data, String ciphertext, int startLength, int endLength) {
- if (IsNullOrEmpty(data)) {
- return "";
- }
- return data.substring(0, startLength) + ciphertext + data.substring(data.length() - endLength);
- }
- }
|