Done ticket GEPAFINBE-167

This commit is contained in:
rajesh
2025-02-25 11:57:30 +05:30
parent 555a5d777a
commit fac0c3e2ec
35 changed files with 1573 additions and 13 deletions

View File

@@ -1,6 +1,8 @@
package net.gepafin.tendermanagement.dao;
import net.gepafin.tendermanagement.entities.S3ConfigEntity;
import net.gepafin.tendermanagement.enums.CompanyDocSourceTypeEnum;
import net.gepafin.tendermanagement.enums.CompanyDocumentTypeEnum;
import net.gepafin.tendermanagement.enums.DocOtherSourceTypeEnum;
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
import net.gepafin.tendermanagement.repositories.S3ConfigRepository;
@@ -49,4 +51,29 @@ public class S3PathConfig {
public String getBucketNameForCallAppType(DocumentSourceTypeEnum type){
return s3ConfigRepository.getBucketNameByType(type);
}
public String generateCompanyDocumentPath(CompanyDocumentTypeEnum type, Long companyId) {
S3ConfigEntity config = getCompanyDocumentPath(type);
return config.getParentFolder() + "/" + buildCompanyDocumentS3Path(config.getPath(), companyId);
}
private String buildCompanyDocumentS3Path(String pathTemplate, Long companyId) {
return pathTemplate
.replace("{company_id}", companyId != null && companyId != 0L ? "company_" + companyId : "");
}
private S3ConfigEntity getCompanyDocumentPath(CompanyDocumentTypeEnum type) {
return s3ConfigRepository.getPathByType(type.name()).orElseThrow(() -> new IllegalArgumentException("No path configuration found for type: " + type));
}
private S3ConfigEntity getCompanyDocumentPathForOther(CompanyDocSourceTypeEnum type) {
return s3ConfigRepository.getPathByType(type.name()).orElseThrow(() -> new IllegalArgumentException("No path configuration found for type: " + type));
}
public String generateCompanyDocumentPathForOther(CompanyDocSourceTypeEnum type, Long companyId) {
S3ConfigEntity config = getCompanyDocumentPathForOther(type);
return config.getParentFolder() + "/" + buildCompanyDocumentS3Path(config.getPath(),companyId);
}
}