All GCC vendors and employee details for IT department management
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
3.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. package com.gcc_manpower.config;
  2. import org.springframework.beans.factory.annotation.Value;
  3. import org.springframework.context.annotation.Configuration;
  4. import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
  5. import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  6. import java.nio.file.Paths;
  7. @Configuration
  8. public class WebConfig implements WebMvcConfigurer {
  9. @Value("${upload.path:gcc_manpower_uploads}")
  10. private String uploadPathConfig;
  11. @Value("${document.upload.path:gccservicedocuments}")
  12. private String documentUploadPathConfig;
  13. @Value("${payment.tracker.upload.path:gccpaymenttrackerfiles}")
  14. private String paymentTrackerUploadPathConfig;
  15. @Value("${toner.upload.path:gcctonermanagementfiles}")
  16. private String tonerUploadPathConfig;
  17. @Value("${adjustment.upload.path:gccadjustmentmanagementfiles}")
  18. private String adjustmentUploadPathConfig;
  19. @Override
  20. public void addResourceHandlers(ResourceHandlerRegistry registry) {
  21. // Resolve absolute path (supports both relative and absolute paths)
  22. String uploadPath = Paths.get(uploadPathConfig).toAbsolutePath().toUri().toString();
  23. // Map URL path /gcc_manpower_uploads/** to the configured folder path
  24. registry.addResourceHandler("/gcc_manpower_uploads/**")
  25. .addResourceLocations(uploadPath);
  26. // Map URL path /gccservicedocuments/files/** to the configured document folder
  27. // path
  28. String docUploadPath = Paths.get(documentUploadPathConfig).toAbsolutePath().toUri().toString();
  29. registry.addResourceHandler("/gccservicedocuments/files/**")
  30. .addResourceLocations(docUploadPath);
  31. // Map URL path /gccpaymenttrackerfiles/** to the configured payment tracker
  32. // folder
  33. String trackerUploadPath = Paths.get(paymentTrackerUploadPathConfig).toAbsolutePath().toUri()
  34. .toString();
  35. registry.addResourceHandler("/gccpaymenttrackerfiles/**")
  36. .addResourceLocations(trackerUploadPath);
  37. // Map URL path /gcctonermanagementfiles/** to the configured toner folder
  38. String tonerUploadPath = Paths.get(tonerUploadPathConfig).toAbsolutePath().toUri()
  39. .toString();
  40. registry.addResourceHandler("/gcctonermanagementfiles/**")
  41. .addResourceLocations(tonerUploadPath);
  42. // Map URL path /gccadjustmentmanagementfiles/** to the configured adjustment folder
  43. String adjustmentUploadPath = Paths.get(adjustmentUploadPathConfig).toAbsolutePath().toUri()
  44. .toString();
  45. registry.addResourceHandler("/gccadjustmentmanagementfiles/**")
  46. .addResourceLocations(adjustmentUploadPath);
  47. // Map URL path /uploads/** to the physical uploads folder in the project root
  48. String rootUploadPath = Paths.get("uploads").toAbsolutePath().toUri().toString();
  49. registry.addResourceHandler("/uploads/**")
  50. .addResourceLocations(rootUploadPath);
  51. }
  52. }