RuoYiConfig.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package com.zhongzheng.common.config;
  2. import lombok.Data;
  3. import lombok.Getter;
  4. import lombok.NoArgsConstructor;
  5. import lombok.experimental.Accessors;
  6. import org.springframework.boot.context.properties.ConfigurationProperties;
  7. import org.springframework.stereotype.Component;
  8. /**
  9. * 读取项目相关配置
  10. *
  11. * @author zhongzheng
  12. */
  13. @Data
  14. @NoArgsConstructor
  15. @Accessors(chain = true)
  16. @Component
  17. @ConfigurationProperties(prefix = "zhongzheng")
  18. public class RuoYiConfig
  19. {
  20. /** 项目名称 */
  21. private String name;
  22. /** 版本 */
  23. private String version;
  24. /** 版权年份 */
  25. private String copyrightYear;
  26. /** 实例演示开关 */
  27. private boolean demoEnabled;
  28. /** 上传路径 */
  29. @Getter
  30. private static String profile;
  31. /** 获取地址开关 */
  32. @Getter
  33. private static boolean addressEnabled;
  34. public void setProfile(String profile)
  35. {
  36. RuoYiConfig.profile = profile;
  37. }
  38. public void setAddressEnabled(boolean addressEnabled)
  39. {
  40. RuoYiConfig.addressEnabled = addressEnabled;
  41. }
  42. /**
  43. * 获取头像上传路径
  44. */
  45. public static String getAvatarPath()
  46. {
  47. return getProfile() + "/avatar";
  48. }
  49. /**
  50. * 获取下载路径
  51. */
  52. public static String getDownloadPath()
  53. {
  54. return getProfile() + "/download/";
  55. }
  56. /**
  57. * 获取上传路径
  58. */
  59. public static String getUploadPath()
  60. {
  61. return getProfile() + "/upload";
  62. }
  63. }