java后端
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

73 рядки
1.9 KiB

  1. package com.ruoyi.geo.constants;
  2. import com.ruoyi.common.config.RuoYiConfig;
  3. import com.ruoyi.common.utils.StringUtils;
  4. public final class GeoSysDir
  5. {
  6. // 导入日志路径
  7. public static final String LOG = "/log";
  8. // 导入zip临时解压路径
  9. public static final String ZIP_EXTRACT_TEMP = "/unzip";
  10. public static String GetDir(String path)
  11. {
  12. if(StringUtils.isEmpty(path))
  13. path = "";
  14. else if(!path.startsWith("/"))
  15. path = "/" + path;
  16. String str = "";
  17. if(!path.startsWith(RuoYiConfig.getProfile()))
  18. str += RuoYiConfig.getProfile();
  19. str += path;
  20. return str;
  21. }
  22. public static String CacheDir(String dir)
  23. {
  24. if(null == dir)
  25. dir = "";
  26. return GetDir("/cache" + dir);
  27. }
  28. public static String ImportDir(String dir)
  29. {
  30. if(null == dir)
  31. dir = "";
  32. return GetDir("/import" + dir);
  33. }
  34. public static String ExportDir(String dir)
  35. {
  36. if(null == dir)
  37. dir = "";
  38. return GetDir("/export" + dir);
  39. }
  40. public static String Desensitized(String path)
  41. {
  42. if(StringUtils.isEmpty(path))
  43. return path;
  44. String fpath = path.replaceAll("\\\\", "/");
  45. String fprofile = RuoYiConfig.getProfile().replaceAll("\\\\", "/");
  46. if(!fpath.startsWith(fprofile))
  47. return path;
  48. return "<profile directory>" + path.substring(RuoYiConfig.getProfile().length());
  49. }
  50. public static String DesensitizedNormalized(String path)
  51. {
  52. if(StringUtils.isEmpty(path))
  53. return path;
  54. String fpath = path.replaceAll("\\\\", "/");
  55. String fprofile = RuoYiConfig.getProfile().replaceAll("\\\\", "/");
  56. if(!fpath.startsWith(fprofile))
  57. return path;
  58. return "<profile directory>" + fpath.substring(fprofile.length());
  59. }
  60. private GeoSysDir() {}
  61. }