Resolved Conflicts

This commit is contained in:
piyuskag
2024-10-25 15:29:28 +05:30
parent 43ca16dd6d
commit 9515750540
28 changed files with 1611 additions and 400 deletions

View File

@@ -0,0 +1,49 @@
package net.gepafin.tendermanagement.dao;
import net.gepafin.tendermanagement.entities.S3ConfigEntity;
import net.gepafin.tendermanagement.enums.DocOtherSourceTypeEnum;
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
import net.gepafin.tendermanagement.repositories.S3ConfigRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class S3PathConfig {
@Autowired
S3ConfigRepository s3ConfigRepository;
public String generateDocumentPath(DocumentSourceTypeEnum type, Long callId, Long applicationId) {
S3ConfigEntity config = getDocumentPath(type);
return config.getParentFolder() + "/" + buildS3Path(config.getPath(), callId, applicationId);
}
public String generateDocumentPathForOther(DocOtherSourceTypeEnum type, Long callId, Long applicationId) {
S3ConfigEntity config = getDocumentPathForOther(type);
return config.getParentFolder() + "/" + buildS3Path(config.getPath(), callId, applicationId);
}
private String buildS3Path(String pathTemplate, Long callId, Long applicationId) {
return pathTemplate.replace("{call_id}", callId != null && callId != 0L ? "call_" + callId : "").replace("{application_id}", applicationId != null && applicationId != 0L ? "application_" + applicationId : "");
}
public String generateDocumentPathForDelegationAndSignedDocument(DocOtherSourceTypeEnum type) {
S3ConfigEntity config = getDocumentPathForOther(type);
return config.getParentFolder() + "/" + config.getPath();
}
private S3ConfigEntity getDocumentPath(DocumentSourceTypeEnum type) {
return s3ConfigRepository.getPathByType(type.name()).orElseThrow(() -> new IllegalArgumentException("No path configuration found for type: " + type));
}
private S3ConfigEntity getDocumentPathForOther(DocOtherSourceTypeEnum type) {
return s3ConfigRepository.getPathByType(type.name()).orElseThrow(() -> new IllegalArgumentException("No path configuration found for type: " + type));
}
public String getBucketNameForOtherType(DocOtherSourceTypeEnum type){
return s3ConfigRepository.getBucketNameByType(type);
}
public String getBucketNameForCallAppType(DocumentSourceTypeEnum type){
return s3ConfigRepository.getBucketNameByType(type);
}
}