FileProperties.java 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright 2019-2020 Zheng Jie
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package me.zhengjie.config;
  17. import lombok.Data;
  18. import me.zhengjie.utils.ElAdminConstant;
  19. import org.springframework.boot.context.properties.ConfigurationProperties;
  20. import org.springframework.context.annotation.Configuration;
  21. /**
  22. * @author Zheng Jie
  23. */
  24. @Data
  25. @Configuration
  26. @ConfigurationProperties(prefix = "file")
  27. public class FileProperties {
  28. /** 文件大小限制 */
  29. private Long maxSize;
  30. /** 头像大小限制 */
  31. private Long avatarMaxSize;
  32. private ElPath mac;
  33. private ElPath linux;
  34. private ElPath windows;
  35. public ElPath getPath(){
  36. String os = System.getProperty("os.name");
  37. if(os.toLowerCase().startsWith(ElAdminConstant.WIN)) {
  38. return windows;
  39. } else if(os.toLowerCase().startsWith(ElAdminConstant.MAC)){
  40. return mac;
  41. }
  42. return linux;
  43. }
  44. @Data
  45. public static class ElPath{
  46. private String path;
  47. private String avatar;
  48. private String gzPath;
  49. }
  50. }