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

package com.gcc_manpower.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.nio.file.Paths;
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Value("${upload.path:gcc_manpower_uploads}")
private String uploadPathConfig;
@Value("${document.upload.path:gccservicedocuments}")
private String documentUploadPathConfig;
@Value("${payment.tracker.upload.path:gccpaymenttrackerfiles}")
private String paymentTrackerUploadPathConfig;
@Value("${toner.upload.path:gcctonermanagementfiles}")
private String tonerUploadPathConfig;
@Value("${adjustment.upload.path:gccadjustmentmanagementfiles}")
private String adjustmentUploadPathConfig;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// Resolve absolute path (supports both relative and absolute paths)
String uploadPath = Paths.get(uploadPathConfig).toAbsolutePath().toUri().toString();
// Map URL path /gcc_manpower_uploads/** to the configured folder path
registry.addResourceHandler("/gcc_manpower_uploads/**")
.addResourceLocations(uploadPath);
// Map URL path /gccservicedocuments/files/** to the configured document folder
// path
String docUploadPath = Paths.get(documentUploadPathConfig).toAbsolutePath().toUri().toString();
registry.addResourceHandler("/gccservicedocuments/files/**")
.addResourceLocations(docUploadPath);
// Map URL path /gccpaymenttrackerfiles/** to the configured payment tracker
// folder
String trackerUploadPath = Paths.get(paymentTrackerUploadPathConfig).toAbsolutePath().toUri()
.toString();
registry.addResourceHandler("/gccpaymenttrackerfiles/**")
.addResourceLocations(trackerUploadPath);
// Map URL path /gcctonermanagementfiles/** to the configured toner folder
String tonerUploadPath = Paths.get(tonerUploadPathConfig).toAbsolutePath().toUri()
.toString();
registry.addResourceHandler("/gcctonermanagementfiles/**")
.addResourceLocations(tonerUploadPath);
// Map URL path /gccadjustmentmanagementfiles/** to the configured adjustment folder
String adjustmentUploadPath = Paths.get(adjustmentUploadPathConfig).toAbsolutePath().toUri()
.toString();
registry.addResourceHandler("/gccadjustmentmanagementfiles/**")
.addResourceLocations(adjustmentUploadPath);
// Map URL path /uploads/** to the physical uploads folder in the project root
String rootUploadPath = Paths.get("uploads").toAbsolutePath().toUri().toString();
registry.addResourceHandler("/uploads/**")
.addResourceLocations(rootUploadPath);
}
}