StringUtils.java 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package com.hz.employmentsite.util;
  2. import org.springframework.stereotype.Component;
  3. import java.util.List;
  4. import java.util.stream.Collectors;
  5. @Component
  6. public class StringUtils {
  7. public boolean IsNullOrEmpty(String value) {
  8. return value == null || value.length() == 0;
  9. }
  10. public <T> String ListToInSql(List<T> list) {
  11. if (list == null || list.size() <= 0)
  12. return "";
  13. String sql = String.join("','", list.stream().map(it -> it.toString()).collect(Collectors.toList()));
  14. return "'" + sql + "'";
  15. }
  16. /**
  17. * 重要信息脱密
  18. *
  19. * @param data 数据
  20. * @param ciphertext 加密密文
  21. * @param startLength 开始位置
  22. * @param endLength 结束位置
  23. * @return 脱敏后的文本数据
  24. */
  25. public String desensitizeData(String data, String ciphertext, int startLength, int endLength) {
  26. if (IsNullOrEmpty(data)) {
  27. return "";
  28. }
  29. return data.substring(0, startLength) + ciphertext + data.substring(data.length() - endLength);
  30. }
  31. }