Done ticket GEPAFINBE-167
This commit is contained in:
@@ -423,6 +423,21 @@ public class GepafinConstant {
|
||||
|
||||
public static final String FORMULA_AMOUNT_NOT_MATCHED="formula.amount.not.matches.requested.amount";
|
||||
public static final String CRITERIA_TABLE_COLUMNS="criteria_table_columns";
|
||||
|
||||
public static final String COMPANY_DOCUMENT_NOT_FOUND = "company.document.not.found";
|
||||
public static final String COMPANY_DOCUMENT_UPDATED_SUCCESSFULLY = "company.document.updated.successfully";
|
||||
public static final String COMPANY_DOCUMENT_COPIED_SUCCESSFULLY = "company.document.copied.successfully";
|
||||
public static final String COMPANY_DOCUMENT_FETCHED_SUCCESSFULLY = "company.document.fetched.successfully";
|
||||
|
||||
public static final String DOCUMENT_CATEGORY_CREATE_SUCCESS = "document.category.success";
|
||||
public static final String DOCUMENT_CATEGORY_GET_SUCCESS = "document.category.get.success";
|
||||
public static final String DOCUMENT_CATEGORY_NOT_FOUND = "document.category.not.found";
|
||||
public static final String DOCUMENT_CATEGORY_DELETE_SUCCESS = "document.category.delete.success";
|
||||
public static final String DOCUMENT_CATEGORY_UPDATE_SUCCESS = "document.category.update.success";
|
||||
public static final String ERROR_MOVING_FILE_TO_DELETED_FOLDER = "error.moving.file.to.deleted.folder";
|
||||
|
||||
public static final String CATEGORY_CANNOT_BE_DELETED = "category.cannot.be.deleted";
|
||||
public static final String INVALID_EXPIRATION_DATE = "invalid.expiration.date";
|
||||
}
|
||||
|
||||
|
||||
|
||||
113
src/main/java/net/gepafin/tendermanagement/dao/CategoryDao.java
Normal file
113
src/main/java/net/gepafin/tendermanagement/dao/CategoryDao.java
Normal file
@@ -0,0 +1,113 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.CategoryEntity;
|
||||
import net.gepafin.tendermanagement.entities.CompanyDocumentEntity;
|
||||
import net.gepafin.tendermanagement.entities.FaqEntity;
|
||||
import net.gepafin.tendermanagement.entities.HubEntity;
|
||||
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.CategoryRequest;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.model.response.CategoryResponse;
|
||||
import net.gepafin.tendermanagement.repositories.CategoryRepository;
|
||||
import net.gepafin.tendermanagement.repositories.CompanyDocumentRepository;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
|
||||
@Component
|
||||
public class CategoryDao {
|
||||
|
||||
@Autowired
|
||||
private CategoryRepository categoryRepository;
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
private CompanyDocumentRepository companyDocumentRepository;
|
||||
|
||||
public CategoryResponse createDocumentCategory(HttpServletRequest request, CategoryRequest categoryRequest){
|
||||
|
||||
CategoryEntity entity = createCategoryEntity(new CategoryEntity(),categoryRequest);
|
||||
categoryRepository.save(entity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Create Company Document Category" operation. **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(entity).build());
|
||||
|
||||
return convertToResponseBean(entity);
|
||||
}
|
||||
|
||||
public CategoryEntity createCategoryEntity(CategoryEntity entity,CategoryRequest companyDocumentCategoryRequest){
|
||||
entity.setCategoryName(companyDocumentCategoryRequest.getCategoryName());
|
||||
entity.setDescription(companyDocumentCategoryRequest.getDescription());
|
||||
entity.setIsDeleted(false);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public CategoryResponse convertToResponseBean(CategoryEntity entity){
|
||||
CategoryResponse response = new CategoryResponse();
|
||||
response.setId(entity.getId());
|
||||
response.setCategoryName(entity.getCategoryName());
|
||||
response.setDescription(entity.getDescription());
|
||||
response.setCreatedDate(entity.getCreatedDate());
|
||||
response.setUpdatedDate(entity.getUpdatedDate());
|
||||
return response;
|
||||
}
|
||||
|
||||
public CategoryResponse getDocumentCategoryById(HttpServletRequest request, Long id){
|
||||
return convertToResponseBean(validateCategory(id));
|
||||
}
|
||||
|
||||
public CategoryEntity validateCategory(Long id) {
|
||||
return categoryRepository.findById(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.DOCUMENT_CATEGORY_NOT_FOUND)));
|
||||
}
|
||||
|
||||
public void deleteCategory(HttpServletRequest request,Long id) {
|
||||
CategoryEntity entity = validateCategory(id);
|
||||
|
||||
List<CompanyDocumentEntity> companyDocumentEntities = companyDocumentRepository.findByCategoryEntityId(id);
|
||||
if (!companyDocumentEntities.isEmpty()){
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.CATEGORY_CANNOT_BE_DELETED));
|
||||
}
|
||||
CategoryEntity oldCategoryEntity = Utils.getClonedEntityForData(entity);
|
||||
entity.setIsDeleted(true);
|
||||
categoryRepository.save(entity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "soft delete category" operation **/
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.SOFT_DELETE).oldData(oldCategoryEntity).newData(entity).build());
|
||||
}
|
||||
|
||||
public CategoryResponse updateCategory(HttpServletRequest request,Long id , CategoryRequest categoryRequest){
|
||||
CategoryEntity entity = validateCategory(id);
|
||||
CategoryEntity oldCategoryEntity = Utils.getClonedEntityForData(entity);
|
||||
CategoryEntity newCategoryEntity = updateCategoryEntity(entity, categoryRequest);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Update Category" operation. **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldCategoryEntity).newData(newCategoryEntity).build());
|
||||
return convertToResponseBean(entity);
|
||||
}
|
||||
|
||||
public CategoryEntity updateCategoryEntity(CategoryEntity entity , CategoryRequest categoryRequest){
|
||||
setIfUpdated(entity::getCategoryName, entity::setCategoryName, categoryRequest.getCategoryName());
|
||||
setIfUpdated(entity::getDescription, entity::setDescription, categoryRequest.getDescription());
|
||||
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,337 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import com.amazonaws.services.s3.AmazonS3Client;
|
||||
import com.amazonaws.services.s3.model.CopyObjectRequest;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.*;
|
||||
import net.gepafin.tendermanagement.model.request.CompanyDocumentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.model.response.CategoryResponse;
|
||||
import net.gepafin.tendermanagement.model.response.CompanyDocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.UploadFileOnAmazonS3Response;
|
||||
import net.gepafin.tendermanagement.repositories.CompanyDocumentRepository;
|
||||
import net.gepafin.tendermanagement.repositories.DocumentRepository;
|
||||
import net.gepafin.tendermanagement.service.AmazonS3Service;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import net.gepafin.tendermanagement.service.CategoryService;
|
||||
import net.gepafin.tendermanagement.service.CompanyService;
|
||||
import net.gepafin.tendermanagement.service.impl.AmazonS3ServiceImpl;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CompanyDocumentDao {
|
||||
|
||||
@Autowired
|
||||
private S3PathConfig s3ConfigBean;
|
||||
|
||||
@Autowired
|
||||
private AmazonS3Service amazonS3Service;
|
||||
|
||||
@Autowired
|
||||
private CompanyDocumentRepository companyDocumentRepository;
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
private CategoryDao categoryDao;
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
@Value("${aws.s3.bucket.name}")
|
||||
private String bucketName;
|
||||
|
||||
@Autowired
|
||||
private AmazonS3Client s3Client;
|
||||
|
||||
@Autowired
|
||||
private DocumentRepository documentRepository;
|
||||
|
||||
@Autowired
|
||||
private CallDao callDao;
|
||||
|
||||
@Autowired
|
||||
private ApplicationService applicationService;
|
||||
|
||||
@Autowired
|
||||
private AmazonS3ServiceImpl amazonS3ServiceImpl;
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
public List<CompanyDocumentResponseBean> uploadFileForCompany(HttpServletRequest request, Long userId, List<MultipartFile> files, Long companyId, Long categoryId, CompanyDocumentTypeEnum companyDocumentSourceTypeEnum, LocalDateTime expirationDate){
|
||||
CategoryEntity categoryEntity = categoryDao.validateCategory(categoryId);
|
||||
validator.validateUserWithCompany(request,companyId);
|
||||
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(userId,companyId);
|
||||
|
||||
LocalDateTime currentDate = LocalDateTime.now();
|
||||
if (expirationDate.isBefore(currentDate)) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.INVALID_EXPIRATION_DATE));
|
||||
}
|
||||
List<CompanyDocumentEntity> companyDocumentEntities = new ArrayList<>();
|
||||
for (MultipartFile file : files){
|
||||
UploadFileOnAmazonS3Response uploadFileOnAmazonS3Response = uploadFileOnAmazonS3(file, companyDocumentSourceTypeEnum, companyId);
|
||||
if (uploadFileOnAmazonS3Response != null) {
|
||||
CompanyDocumentEntity companyDocumentEntity = new CompanyDocumentEntity();
|
||||
companyDocumentEntity.setFileName(uploadFileOnAmazonS3Response.getFileName());
|
||||
companyDocumentEntity.setCompanyId(companyId);
|
||||
companyDocumentEntity.setType(companyDocumentSourceTypeEnum.getValue());
|
||||
companyDocumentEntity.setFilePath(uploadFileOnAmazonS3Response.getFilePath());
|
||||
companyDocumentEntity.setIsDeleted(false);
|
||||
companyDocumentEntity.setUploadedBy(userId);
|
||||
if (expirationDate.isBefore(currentDate.plusDays(7))) {
|
||||
companyDocumentEntity.setStatus(CompanyDocumentStatusEnum.DUE.getValue());
|
||||
} else {
|
||||
companyDocumentEntity.setStatus(CompanyDocumentStatusEnum.VALID.getValue());
|
||||
}
|
||||
|
||||
companyDocumentEntity.setCategoryEntity(categoryEntity);
|
||||
companyDocumentEntity.setUserWithCompany(userWithCompanyEntity);
|
||||
companyDocumentEntity.setExpirationDate(expirationDate);
|
||||
companyDocumentEntities.add(companyDocumentEntity);
|
||||
}
|
||||
}
|
||||
companyDocumentRepository.saveAll(companyDocumentEntities);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Upload company document" operation. **/
|
||||
|
||||
companyDocumentEntities.forEach(entity -> loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(entity).build()));
|
||||
|
||||
return companyDocumentEntities.stream()
|
||||
.map(this::convertToCompanyDocumentResponseBean)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
private UploadFileOnAmazonS3Response uploadFileOnAmazonS3(MultipartFile file, CompanyDocumentTypeEnum type, Long companyId) {
|
||||
try {
|
||||
String s3Path = generateS3PathForCompany(type,companyId);
|
||||
log.info("Generated S3 path {}", s3Path);
|
||||
return amazonS3Service.uploadFileOnAmazonS3(s3Path, file);
|
||||
} catch (Exception e) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.UPLOAD_ERROR_S3));
|
||||
}
|
||||
}
|
||||
|
||||
public String generateS3PathForCompany(CompanyDocumentTypeEnum typeOfDocument, Long companyId) {
|
||||
try {
|
||||
return s3ConfigBean.generateCompanyDocumentPath(typeOfDocument, companyId);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.S3_PATH_GENERATION_ERROR_MSG));
|
||||
}
|
||||
}
|
||||
|
||||
public CompanyDocumentEntity validateCompanyDocument(Long id) {
|
||||
return companyDocumentRepository.findByIdAndNotDeleted(id).orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.COMPANY_DOCUMENT_NOT_FOUND)));
|
||||
}
|
||||
|
||||
public CompanyDocumentResponseBean convertToCompanyDocumentResponseBean(CompanyDocumentEntity entity) {
|
||||
CompanyDocumentResponseBean responseBean = new CompanyDocumentResponseBean();
|
||||
CategoryEntity categoryEntity = entity.getCategoryEntity();
|
||||
CategoryResponse responseCategory = categoryDao.convertToResponseBean(categoryEntity);
|
||||
responseBean.setId(entity.getId());
|
||||
responseBean.setName(entity.getFileName());
|
||||
responseBean.setType(CompanyDocumentTypeEnum.valueOf(entity.getType()));
|
||||
responseBean.setFilePath(entity.getFilePath());
|
||||
responseBean.setCompanyId(entity.getCompanyId());
|
||||
responseBean.setExpirationDate(entity.getExpirationDate());
|
||||
responseBean.setStatus(entity.getStatus());
|
||||
responseBean.setUploadedBy(entity.getUploadedBy());
|
||||
responseBean.setCategory(responseCategory);
|
||||
responseBean.setUserWithCompanyId(entity.getUserWithCompany().getId());
|
||||
responseBean.setCreatedDate(entity.getCreatedDate());
|
||||
responseBean.setUpdatedDate(entity.getUpdatedDate());
|
||||
return responseBean;
|
||||
}
|
||||
|
||||
public CompanyDocumentResponseBean updateCompanyDocument(HttpServletRequest request,Long companyDocumentId, CompanyDocumentRequest companyDocumentRequest){
|
||||
|
||||
CompanyDocumentEntity companyDocumentEntity = validateCompanyDocument(companyDocumentId);
|
||||
validator.validateUserWithCompany(request,companyDocumentEntity.getCompanyId());
|
||||
CompanyDocumentEntity oldCompanyDocumentData = Utils.getClonedEntityForData(companyDocumentEntity);
|
||||
LocalDateTime currentDate = LocalDateTime.now();
|
||||
if (companyDocumentRequest.getExpirationDate() != null) {
|
||||
if (companyDocumentRequest.getExpirationDate().isBefore(currentDate)) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.INVALID_EXPIRATION_DATE));
|
||||
}
|
||||
companyDocumentEntity.setExpirationDate(companyDocumentRequest.getExpirationDate());
|
||||
if (companyDocumentRequest.getExpirationDate().isBefore(currentDate.plusDays(7))) {
|
||||
companyDocumentEntity.setStatus(CompanyDocumentStatusEnum.DUE.getValue());
|
||||
} else {
|
||||
companyDocumentEntity.setStatus(CompanyDocumentStatusEnum.VALID.getValue());
|
||||
}
|
||||
}
|
||||
if (companyDocumentRequest.getCategoryId() != null && companyDocumentRequest.getCategoryId() >0) {
|
||||
CategoryEntity categoryEntity = categoryDao.validateCategory(companyDocumentRequest.getCategoryId());
|
||||
setIfUpdated(companyDocumentEntity::getCategoryEntity, companyDocumentEntity::setCategoryEntity, categoryEntity);
|
||||
}
|
||||
companyDocumentRepository.save(companyDocumentEntity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "updating company document" operation. **/
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldCompanyDocumentData).newData(companyDocumentEntity).build());
|
||||
|
||||
return convertToCompanyDocumentResponseBean(companyDocumentEntity);
|
||||
}
|
||||
|
||||
public CompanyDocumentResponseBean getCompanyDocument(UserEntity user ,Long companyDocumentId) {
|
||||
CompanyDocumentEntity companyDocumentEntity = validateCompanyDocument(companyDocumentId);
|
||||
validator.validateUserWithCompany(request,companyDocumentEntity.getCompanyId());
|
||||
return convertToCompanyDocumentResponseBean(companyDocumentEntity);
|
||||
}
|
||||
|
||||
public void deleteCompanyFile(Long companyDocumentId){
|
||||
CompanyDocumentEntity companyDocumentEntity = validateCompanyDocument(companyDocumentId);
|
||||
deleteCompanyFileFromS3(companyDocumentEntity);
|
||||
}
|
||||
|
||||
public void deleteCompanyFileFromS3(CompanyDocumentEntity companyDocumentEntity){
|
||||
|
||||
try {
|
||||
CompanyDocumentEntity oldCompanyDocumentEntity = Utils.getClonedEntityForData(companyDocumentEntity);
|
||||
validator.validateUserWithCompany(request,companyDocumentEntity.getCompanyId());
|
||||
String oldCompanyDocumentPath = companyDocumentEntity.getFilePath();
|
||||
String newS3Path = s3ConfigBean.generateCompanyDocumentPathForOther(CompanyDocSourceTypeEnum.valueOf("DELETED_" + companyDocumentEntity.getType().toUpperCase()), companyDocumentEntity.getCompanyId());
|
||||
UploadFileOnAmazonS3Response response = amazonS3Service.moveFile(companyDocumentEntity.getFileName(), oldCompanyDocumentPath, newS3Path);
|
||||
companyDocumentEntity.setFileName(response.getFileName());
|
||||
companyDocumentEntity.setFilePath(response.getFilePath());
|
||||
companyDocumentEntity.setIsDeleted(true);
|
||||
companyDocumentRepository.save(companyDocumentEntity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Soft delete document" operation. **/
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.SOFT_DELETE).oldData(oldCompanyDocumentEntity).newData(companyDocumentEntity).build());
|
||||
log.info("File for company document ID {} successfully moved to deleted folder.", companyDocumentEntity.getId());
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("Error moving file for company document ID {} to deleted folder: {}", companyDocumentEntity.getId(), e.getMessage());
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.ERROR_MOVING_FILE_TO_DELETED_FOLDER));
|
||||
}
|
||||
}
|
||||
|
||||
public UserActionContextEnum getUserActionContextEnum(CompanyDocumentTypeEnum type){
|
||||
UserActionContextEnum userActionContext = null;
|
||||
if (type.equals(CompanyDocumentTypeEnum.COMPANY_DOCUMENT)){
|
||||
userActionContext = UserActionContextEnum.UPLOAD_COMPANY_DOCUMENT;
|
||||
}
|
||||
else if(type.equals(CompanyDocumentTypeEnum.PERSONAL_DOCUMENT)){
|
||||
userActionContext = UserActionContextEnum.UPLOAD_COMPANY_PERSONAL_DOCUMENT;
|
||||
}
|
||||
return userActionContext;
|
||||
}
|
||||
|
||||
public DocumentResponseBean validateAndDuplicateCompanyDocument(HttpServletRequest request , Long userId ,Long companyDocumentId , Long applicationId , DocumentTypeEnum documentTypeEnum){
|
||||
ApplicationEntity applicationEntity = applicationService.validateApplication(applicationId);
|
||||
CompanyDocumentEntity companyDocumentEntity = validateCompanyDocument(companyDocumentId);
|
||||
validator.validateUserWithCompany(request,companyDocumentEntity.getCompanyId());
|
||||
|
||||
String oldS3Path = companyDocumentEntity.getFilePath();
|
||||
String newS3Path = s3ConfigBean.generateDocumentPath(DocumentSourceTypeEnum.APPLICATION,applicationEntity.getCall().getId(),applicationId,0L);
|
||||
|
||||
log.info("Original Paths - oldPath: {}, newPath: {}", oldS3Path, newS3Path);
|
||||
|
||||
oldS3Path = amazonS3ServiceImpl.decodeS3Key(amazonS3ServiceImpl.cleanOldPath(oldS3Path));
|
||||
newS3Path = amazonS3ServiceImpl.cleanNewPath(oldS3Path, newS3Path);
|
||||
log.info("Moving file from {} to {} in bucket {}", oldS3Path, newS3Path, bucketName);
|
||||
|
||||
CopyObjectRequest copyRequest = new CopyObjectRequest(bucketName, oldS3Path, bucketName, newS3Path);
|
||||
s3Client.copyObject(copyRequest);
|
||||
log.info("File copied successfully from {} to {}", oldS3Path, newS3Path);
|
||||
|
||||
DocumentEntity entity = new DocumentEntity();
|
||||
entity.setFilePath(newS3Path);
|
||||
entity.setFileName(companyDocumentEntity.getFileName());
|
||||
entity.setSource(DocumentSourceTypeEnum.APPLICATION.getValue());
|
||||
entity.setType(documentTypeEnum.getValue());
|
||||
entity.setSourceId(applicationId);
|
||||
entity.setUploadedBy(userId);
|
||||
|
||||
documentRepository.save(entity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "inserting data" operation. **/
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(entity).build());
|
||||
|
||||
DocumentResponseBean responseBean = callDao.convertToDocumentResponseBean(entity);
|
||||
return responseBean;
|
||||
}
|
||||
|
||||
public List<CompanyDocumentResponseBean> getAllCompanyDocument(UserEntity user , Long companyId, CompanyDocumentTypeEnum typeEnum){
|
||||
validator.validateUserWithCompany(request, companyId);
|
||||
companyService.validateCompany(companyId);
|
||||
|
||||
Specification<CompanyDocumentEntity> spec = filterCompanyDocuments(companyId, user.getId(), typeEnum);
|
||||
|
||||
List<CompanyDocumentEntity> companyDocumentEntities = companyDocumentRepository.findAll(spec);
|
||||
return companyDocumentEntities.stream()
|
||||
.map(this::convertToCompanyDocumentResponseBean)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
private Specification<CompanyDocumentEntity> filterCompanyDocuments(Long companyId, Long userId, CompanyDocumentTypeEnum typeEnum) {
|
||||
return (root, query, builder) -> {
|
||||
Predicate predicate = builder.equal(root.get("companyId"), companyId);
|
||||
|
||||
if (typeEnum != null) {
|
||||
if (typeEnum == CompanyDocumentTypeEnum.COMPANY_DOCUMENT) {
|
||||
// Case 1: Fetch only COMPANY_DOCUMENT type documents for the given company
|
||||
predicate = builder.and(predicate, builder.equal(root.get("type"), CompanyDocumentTypeEnum.COMPANY_DOCUMENT.getValue()));
|
||||
|
||||
} else if (typeEnum == CompanyDocumentTypeEnum.PERSONAL_DOCUMENT) {
|
||||
// Case 2: Fetch only PERSONAL_DOCUMENT type documents for the logged-in user
|
||||
predicate = builder.and(
|
||||
predicate,
|
||||
builder.equal(root.get("type"), CompanyDocumentTypeEnum.PERSONAL_DOCUMENT.getValue()),
|
||||
builder.equal(root.get("userWithCompany").get("userId"), userId)
|
||||
);
|
||||
}
|
||||
}
|
||||
// Case 3: If typeEnum is null, fetch all documents for the company and personal documents for the user
|
||||
Predicate companyPredicate = builder.equal(root.get("companyId"), companyId);
|
||||
Predicate personalPredicate = builder.and(
|
||||
builder.equal(root.get("type"), CompanyDocumentTypeEnum.PERSONAL_DOCUMENT.getValue()),
|
||||
builder.equal(root.get("userWithCompany").get("userId"), userId)
|
||||
);
|
||||
predicate = builder.and(predicate, builder.or(companyPredicate, personalPredicate));
|
||||
|
||||
return predicate;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -316,7 +316,7 @@ public class DocumentDao {
|
||||
log.info("File for document ID {} successfully moved to deleted folder.", documentEntity.getId());
|
||||
} catch (Exception e) {
|
||||
log.error("Error moving file for document ID {} to deleted folder: {}", documentEntity.getId(), e.getMessage());
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, "Error occurred while moving file to deleted folder.");
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.ERROR_MOVING_FILE_TO_DELETED_FOLDER));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,7 @@ import jakarta.persistence.criteria.Root;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||
import net.gepafin.tendermanagement.entities.NotificationEntity;
|
||||
import net.gepafin.tendermanagement.entities.NotificationTypeEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.NotificationEnum;
|
||||
import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
||||
@@ -27,6 +22,7 @@ import net.gepafin.tendermanagement.repositories.NotificationTypeRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserWithCompanyRepository;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import net.gepafin.tendermanagement.service.CompanyService;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
@@ -80,6 +76,9 @@ public class NotificationDao {
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
public NotificationResponse sendNotification(NotificationReq notificationReq) {
|
||||
|
||||
// Ensure userId is properly set in notificationReq if not already
|
||||
@@ -414,4 +413,17 @@ public class NotificationDao {
|
||||
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.USER_ID), userId));
|
||||
return predicates;
|
||||
}
|
||||
|
||||
public void sendNotificationToBeneficiaryForDocumentExpiration(CompanyDocumentEntity companyDocumentEntity, NotificationTypeEnum notificationTypeEnum) {
|
||||
|
||||
CompanyEntity companyEntity = companyService.validateCompany(companyDocumentEntity.getCompanyId());
|
||||
Map<String, String> placeHolders = new HashMap<>();
|
||||
placeHolders.put("{{file_name}}", companyDocumentEntity.getFileName());
|
||||
placeHolders.put("{{company_name}}", companyEntity.getCompanyName());
|
||||
placeHolders.put("{{expiration_date}}", companyDocumentEntity.getExpirationDate().toString());
|
||||
NotificationReq notificationReq = createNotificationReq(notificationTypeEnum.getValue(), placeHolders, companyDocumentEntity.getUserWithCompany().getUserId(), companyDocumentEntity.getUserWithCompany(),
|
||||
listOf(companyDocumentEntity.getCompanyId()));
|
||||
sendNotification(notificationReq);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Data;
|
||||
|
||||
@Entity
|
||||
@Table(name = "category")
|
||||
@Data
|
||||
public class CategoryEntity extends BaseEntity {
|
||||
|
||||
@Column(name = "CATEGORY_NAME")
|
||||
private String categoryName;
|
||||
|
||||
@Column(name = "DESCRIPTION")
|
||||
private String description;
|
||||
|
||||
@Column(name ="IS_DELETED")
|
||||
private Boolean isDeleted = false;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Table(name = "COMPANY_DOCUMENT")
|
||||
@Data
|
||||
public class CompanyDocumentEntity extends BaseEntity {
|
||||
|
||||
@Column(name = "FILE_NAME")
|
||||
private String fileName;
|
||||
|
||||
@Column(name = "FILE_PATH")
|
||||
private String filePath;
|
||||
|
||||
@Column(name="TYPE")
|
||||
private String type;
|
||||
|
||||
@Column(name="COMPANY_ID")
|
||||
private Long companyId;
|
||||
|
||||
@Column(name ="IS_DELETED")
|
||||
private Boolean isDeleted = false;
|
||||
|
||||
@Column(name="UPLOADED_BY")
|
||||
private Long uploadedBy;
|
||||
|
||||
@Column(name = "EXPIRATION_DATE")
|
||||
private LocalDateTime expirationDate;
|
||||
|
||||
@Column(name ="STATUS")
|
||||
private String status;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "USER_WITH_COMPANY_ID")
|
||||
private UserWithCompanyEntity userWithCompany;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "CATEGORY_ID")
|
||||
private CategoryEntity categoryEntity;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.gepafin.tendermanagement.enums;
|
||||
|
||||
|
||||
public enum CompanyDocSourceTypeEnum {
|
||||
|
||||
DELETED_PERSONAL_DOCUMENT("DELETED_PERSONAL_DOCUMENT"),
|
||||
DELETED_COMPANY_DOCUMENT("DELETED_COMPANY_DOCUMENT");
|
||||
|
||||
|
||||
private String value;
|
||||
|
||||
CompanyDocSourceTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.gepafin.tendermanagement.enums;
|
||||
|
||||
public enum CompanyDocumentStatusEnum {
|
||||
VALID("VALID"),
|
||||
DUE("DUE"),
|
||||
EXPIRED("EXPIRED");
|
||||
|
||||
private String value;
|
||||
|
||||
CompanyDocumentStatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.gepafin.tendermanagement.enums;
|
||||
|
||||
public enum CompanyDocumentTypeEnum {
|
||||
COMPANY_DOCUMENT("COMPANY_DOCUMENT"),
|
||||
PERSONAL_DOCUMENT("PERSONAL_DOCUMENT");
|
||||
|
||||
private String value;
|
||||
|
||||
CompanyDocumentTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
public enum ExpirationTypeEnum {
|
||||
|
||||
AMENDMENT("AMENDMENT"),
|
||||
EVALUATION("EVALUATION");
|
||||
EVALUATION("EVALUATION"),
|
||||
COMPANY_DOCUMENT("COMPANY_DOCUMENT");
|
||||
|
||||
private String value;
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ public enum NotificationTypeEnum {
|
||||
EVALUATION_CREATION("EVALUATION_CREATION"),
|
||||
EVALUATION_EXPIRED("EVALUATION_EXPIRED"),
|
||||
AMENDMENT_EXPIRATION_REMINDER("AMENDMENT_EXPIRATION_REMINDER"),
|
||||
EVALUATION_EXPIRATION_REMINDER("EVALUATION_EXPIRATION_REMINDER");
|
||||
EVALUATION_EXPIRATION_REMINDER("EVALUATION_EXPIRATION_REMINDER"),
|
||||
COMPANY_DOCUMENT_EXPIRATION_REMINDER("COMPANY_DOCUMENT_EXPIRATION_REMINDER");
|
||||
|
||||
private final String value;
|
||||
|
||||
|
||||
@@ -192,7 +192,21 @@ public enum UserActionContextEnum {
|
||||
|
||||
|
||||
GET_USER_ACTION("GET_USER_ACTION"),
|
||||
GET_ACTION_CONTEXT_LABELS("GET_ACTION_CONTEXT_LABELS");
|
||||
GET_ACTION_CONTEXT_LABELS("GET_ACTION_CONTEXT_LABELS"),
|
||||
|
||||
GET_COMPANY_DOCUMENT("GET_COMPANY_DOCUMENT"),
|
||||
DELETE_COMPANY_DOCUMENT("DELETE_COMPANY_DOCUMENT"),
|
||||
UPLOAD_COMPANY_DOCUMENT("UPLOAD_COMPANY_DOCUMENT"),
|
||||
UPLOAD_COMPANY_PERSONAL_DOCUMENT("UPLOAD_COMPANY_PERSONAL_DOCUMENT"),
|
||||
GET_ALL_COMPANY_DOCUMENT("GET_ALL_COMPANY_DOCUMENT"),
|
||||
UPDATE_COMPANY_DOCUMENT("UPDATE_COMPANY_DOCUMENT"),
|
||||
DUPLICATE_COMPANY_DOCUMENT("DUPLICATE_COMPANY_DOCUMENT"),
|
||||
|
||||
CREATE_DOCUMENT_CATEGORY("CREATE_DOCUMENT_CATEGORY"),
|
||||
GET_DOCUMENT_CATEGORY("GET_DOCUMENT_CATEGORY"),
|
||||
DELETE_DOCUMENT_CATEGORY("DELETE_DOCUMENT_CATEGORY"),
|
||||
UPDATE_DOCUMENT_CATEGORY("UPDATE_DOCUMENT_CATEGORY"),
|
||||
COMPANY_DOCUMENT_EXPIRATION_SCHEDULER("COMPANY_DOCUMENT_EXPIRATION_SCHEDULER");
|
||||
|
||||
private final String value;
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CategoryRequest {
|
||||
private String categoryName;
|
||||
private String description;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
@Data
|
||||
public class CompanyDocumentRequest {
|
||||
private Long categoryId;
|
||||
private LocalDateTime expirationDate;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.model.BaseBean;
|
||||
|
||||
@Data
|
||||
public class CategoryResponse extends BaseBean {
|
||||
private String categoryName;
|
||||
private String description;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.CompanyDocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.BaseBean;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class CompanyDocumentResponseBean extends BaseBean {
|
||||
|
||||
private String name;
|
||||
|
||||
private String filePath;
|
||||
|
||||
private CompanyDocumentTypeEnum type;
|
||||
|
||||
private Long companyId;
|
||||
|
||||
private String status;
|
||||
|
||||
private LocalDateTime expirationDate;
|
||||
|
||||
private Long uploadedBy;
|
||||
|
||||
private Long userWithCompanyId;
|
||||
|
||||
private CategoryResponse category;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.CategoryEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CategoryRepository extends JpaRepository<CategoryEntity,Long> {
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import feign.Param;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
|
||||
import net.gepafin.tendermanagement.entities.CompanyDocumentEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface CompanyDocumentRepository extends JpaRepository<CompanyDocumentEntity,Long>, JpaSpecificationExecutor<CompanyDocumentEntity> {
|
||||
|
||||
@Query("SELECT c FROM CompanyDocumentEntity c WHERE c.id = :id AND c.isDeleted = false")
|
||||
Optional<CompanyDocumentEntity> findByIdAndNotDeleted(@Param("id") Long id);
|
||||
|
||||
@Query("SELECT d FROM CompanyDocumentEntity d " +
|
||||
"WHERE d.isDeleted = false " +
|
||||
"AND d.expirationDate BETWEEN :startTime AND :endTime")
|
||||
List<CompanyDocumentEntity> findExpiringBetween(LocalDateTime startTime, LocalDateTime endTime);
|
||||
|
||||
@Query("SELECT c FROM CompanyDocumentEntity c " +
|
||||
"WHERE c.isDeleted = false " +
|
||||
"AND c.expirationDate < :now")
|
||||
List<CompanyDocumentEntity> findByExpirationDateBeforeAndIsDeletedFalse(LocalDateTime now);
|
||||
|
||||
@Query("SELECT c FROM CompanyDocumentEntity c " +
|
||||
"WHERE c.companyId = :companyId " +
|
||||
"AND c.isDeleted = false")
|
||||
List<CompanyDocumentEntity> findByCompanyId(Long companyId);
|
||||
|
||||
List<CompanyDocumentEntity> findByCategoryEntityId(Long categoryId);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package net.gepafin.tendermanagement.scheduler;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.dao.NotificationDao;
|
||||
import net.gepafin.tendermanagement.entities.CompanyDocumentEntity;
|
||||
import net.gepafin.tendermanagement.entities.ExpirationConfigEntity;
|
||||
import net.gepafin.tendermanagement.enums.*;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.repositories.CompanyDocumentRepository;
|
||||
import net.gepafin.tendermanagement.repositories.ExpirationConfigRepository;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class CompanyDocumentExpirationScheduler {
|
||||
|
||||
@Autowired
|
||||
private CompanyDocumentRepository companyDocumentRepository;
|
||||
|
||||
@Autowired
|
||||
private NotificationDao notificationDao;
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
private ExpirationConfigRepository expirationConfigRepository;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ExpirationScheduler.class);
|
||||
|
||||
@Scheduled(cron = "0 0 4 * * ?")
|
||||
public void processDocumentExpiration(){
|
||||
log.info("Starting the Document Expiration scheduler...");
|
||||
|
||||
try {
|
||||
Utils.setHttpServletRequestForScheduler();
|
||||
|
||||
// Logging user action for the scheduler operation
|
||||
loggingUtil.logUserActionWithoutToken(
|
||||
UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.SCHEDULER)
|
||||
.actionContext(UserActionContextEnum.COMPANY_DOCUMENT_EXPIRATION_SCHEDULER).build());
|
||||
|
||||
|
||||
log.info("Starting processing expiration notifications for document");
|
||||
processExpirationReminder(ExpirationTypeEnum.COMPANY_DOCUMENT);
|
||||
updateExpiredDocuments();
|
||||
|
||||
log.info("Expiration scheduler completed successfully.");
|
||||
}
|
||||
catch (Exception e){
|
||||
log.error("An error occurred during the Notification Expiration Scheduler of Document: {}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void processExpirationReminder(ExpirationTypeEnum typeEnum){
|
||||
List<ExpirationConfigEntity> configEntities = expirationConfigRepository.findByTypeAndIsDeletedFalse(typeEnum.getValue());
|
||||
|
||||
for (ExpirationConfigEntity config : configEntities){
|
||||
Long daysBefore = config.getIntervalDays();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime startDate = now.plusDays(daysBefore).withHour(0).withMinute(0).withSecond(0).withNano(2);
|
||||
LocalDateTime endDate = startDate.plusDays(1).minusNanos(2);
|
||||
|
||||
processDocumentExpiration(startDate, endDate, daysBefore);
|
||||
}
|
||||
}
|
||||
|
||||
private void processDocumentExpiration(LocalDateTime startDate, LocalDateTime endDate, Long daysBefore){
|
||||
List<CompanyDocumentEntity> expiringDocuments = companyDocumentRepository.findExpiringBetween(startDate, endDate);
|
||||
|
||||
for (CompanyDocumentEntity document : expiringDocuments) {
|
||||
notificationDao.sendNotificationToBeneficiaryForDocumentExpiration(document, NotificationTypeEnum.COMPANY_DOCUMENT_EXPIRATION_REMINDER);
|
||||
updateDocumentStatus(document, CompanyDocumentStatusEnum.DUE.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updateDocumentStatus(CompanyDocumentEntity companyDocument,String status) {
|
||||
CompanyDocumentEntity oldCompanyDocumentEntity = Utils.getClonedEntityForData(companyDocument);
|
||||
companyDocument.setStatus(status);
|
||||
companyDocumentRepository.save(companyDocument);
|
||||
|
||||
// Logging version history for the update operation
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request)
|
||||
.actionType(VersionActionTypeEnum.UPDATE).oldData(oldCompanyDocumentEntity)
|
||||
.newData(companyDocument).build());
|
||||
|
||||
log.info("Updated document status for document: {}", companyDocument.getFileName());
|
||||
}
|
||||
|
||||
|
||||
private void updateExpiredDocuments() {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
List<CompanyDocumentEntity> expiredDocuments = companyDocumentRepository.findByExpirationDateBeforeAndIsDeletedFalse(now);
|
||||
|
||||
for (CompanyDocumentEntity document : expiredDocuments) {
|
||||
updateDocumentStatus(document, CompanyDocumentStatusEnum.EXPIRED.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.gepafin.tendermanagement.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.model.request.CategoryRequest;
|
||||
import net.gepafin.tendermanagement.model.response.CategoryResponse;
|
||||
|
||||
public interface CategoryService {
|
||||
|
||||
CategoryResponse createDocumentCategory(HttpServletRequest request, CategoryRequest categoryRequest);
|
||||
CategoryResponse getDocumentCategoryById(HttpServletRequest request,Long id);
|
||||
void deleteCategory(HttpServletRequest request,Long id);
|
||||
CategoryResponse updateCategory(HttpServletRequest request, Long id, CategoryRequest categoryRequest);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package net.gepafin.tendermanagement.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.enums.CompanyDocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.CompanyDocumentRequest;
|
||||
import net.gepafin.tendermanagement.model.response.CompanyDocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public interface CompanyDocumentService {
|
||||
List<CompanyDocumentResponseBean> uploadFileForCompany(HttpServletRequest request, List<MultipartFile> files, Long companyId, Long categoryId, CompanyDocumentTypeEnum documentSourceTypeEnum, LocalDateTime expirationDate);
|
||||
|
||||
CompanyDocumentResponseBean updateCompanyDocument(HttpServletRequest httpServletRequest, Long companyDocumentId, CompanyDocumentRequest companyDocumentRequest);
|
||||
|
||||
CompanyDocumentResponseBean getCompanyDocument(HttpServletRequest request, Long companyDocumentId);
|
||||
|
||||
void deleteCompanyFile(HttpServletRequest request,Long companyDocumentId);
|
||||
|
||||
DocumentResponseBean validateAndDuplicateCompanyDocument(HttpServletRequest request, Long companyDocumentId, Long applicationId, DocumentTypeEnum typeEnum);
|
||||
|
||||
List<CompanyDocumentResponseBean> getAllCompanyDocument(HttpServletRequest request ,Long companyId , CompanyDocumentTypeEnum typeEnum);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -153,7 +153,7 @@ public class AmazonS3ServiceImpl implements AmazonS3Service {
|
||||
}
|
||||
}
|
||||
|
||||
private String decodeS3Key(String key) {
|
||||
public String decodeS3Key(String key) {
|
||||
return URLDecoder.decode(key, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@@ -186,11 +186,11 @@ public class AmazonS3ServiceImpl implements AmazonS3Service {
|
||||
}
|
||||
}
|
||||
|
||||
private String cleanNewPath(String oldPath, String newPath) {
|
||||
public String cleanNewPath(String oldPath, String newPath) {
|
||||
return newPath + "/" + oldPath.substring(oldPath.lastIndexOf("/") + 1);
|
||||
}
|
||||
|
||||
private String cleanOldPath(String oldPath) {
|
||||
public String cleanOldPath(String oldPath) {
|
||||
return oldPath.replace(s3Url, "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.dao.CategoryDao;
|
||||
import net.gepafin.tendermanagement.model.request.CategoryRequest;
|
||||
import net.gepafin.tendermanagement.model.response.CategoryResponse;
|
||||
import net.gepafin.tendermanagement.service.CategoryService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class CategoryServiceImpl implements CategoryService {
|
||||
|
||||
@Autowired
|
||||
CategoryDao categoryDao;
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CategoryResponse createDocumentCategory(HttpServletRequest request, CategoryRequest categoryRequest) {
|
||||
validator.validateUser(request);
|
||||
return categoryDao.createDocumentCategory(request,categoryRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public CategoryResponse getDocumentCategoryById(HttpServletRequest request, Long id) {
|
||||
validator.validateUser(request);
|
||||
return categoryDao.getDocumentCategoryById(request,id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteCategory(HttpServletRequest request, Long id) {
|
||||
validator.validateUser(request);
|
||||
categoryDao.deleteCategory(request,id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CategoryResponse updateCategory(HttpServletRequest request, Long id, CategoryRequest categoryRequest) {
|
||||
validator.validateUser(request);
|
||||
return categoryDao.updateCategory(request,id,categoryRequest);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.dao.CompanyDocumentDao;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.CompanyDocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.CompanyDocumentRequest;
|
||||
import net.gepafin.tendermanagement.model.response.CompanyDocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.service.CompanyDocumentService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class CompanyDocumentServiceImpl implements CompanyDocumentService {
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Autowired
|
||||
private CompanyDocumentDao companyDocumentDao;
|
||||
|
||||
@Override
|
||||
public List<CompanyDocumentResponseBean> uploadFileForCompany(HttpServletRequest request, List<MultipartFile> files, Long companyId, Long categoryId , CompanyDocumentTypeEnum documentSourceTypeEnum, LocalDateTime expirationDate) {
|
||||
Map<String, Object> userInfo = validator.getUserInfoFromToken(request);
|
||||
Long userId = validator.getUserId(userInfo);
|
||||
return companyDocumentDao.uploadFileForCompany(request,userId,files,companyId,categoryId,documentSourceTypeEnum,expirationDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyDocumentResponseBean updateCompanyDocument(HttpServletRequest request, Long companyDocumentId, CompanyDocumentRequest companyDocumentRequest) {
|
||||
validator.validateUser(request);
|
||||
return companyDocumentDao.updateCompanyDocument(request,companyDocumentId, companyDocumentRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyDocumentResponseBean getCompanyDocument(HttpServletRequest request, Long companyDocumentId) {
|
||||
UserEntity user = validator.validateUser(request);
|
||||
return companyDocumentDao.getCompanyDocument(user , companyDocumentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCompanyFile(HttpServletRequest request,Long companyDocumentId) {
|
||||
validator.validateUser(request);
|
||||
companyDocumentDao.deleteCompanyFile(companyDocumentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentResponseBean validateAndDuplicateCompanyDocument(HttpServletRequest request, Long companyDocumentId, Long applicationId, DocumentTypeEnum typeEnum) {
|
||||
UserEntity user = validator.validateUser(request);
|
||||
return companyDocumentDao.validateAndDuplicateCompanyDocument(request, user.getId(), companyDocumentId,applicationId,typeEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompanyDocumentResponseBean> getAllCompanyDocument(HttpServletRequest request, Long companyId, CompanyDocumentTypeEnum typeEnum) {
|
||||
UserEntity user = validator.validateUser(request);
|
||||
return companyDocumentDao.getAllCompanyDocument(user,companyId,typeEnum);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.model.request.CategoryRequest;
|
||||
import net.gepafin.tendermanagement.model.request.HubReq;
|
||||
import net.gepafin.tendermanagement.model.response.CategoryResponse;
|
||||
import net.gepafin.tendermanagement.model.response.HubResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Validated
|
||||
public interface CategoryApi {
|
||||
|
||||
@Operation(summary = "Api to create document category", responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@PostMapping(value = "", produces = "application/json")
|
||||
ResponseEntity<Response<CategoryResponse>> createDocumentCategory(HttpServletRequest request,
|
||||
@Parameter(description = "Company Document Category request object", required = true)
|
||||
@Valid @RequestBody CategoryRequest categoryRequest);
|
||||
|
||||
|
||||
@Operation(summary = "Api to get document category by id", responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@GetMapping(value = "/{id}", produces = "application/json")
|
||||
ResponseEntity<Response<CategoryResponse>> getDocumentCategoryById(HttpServletRequest request,
|
||||
@Parameter(description = "The category id", required = true)
|
||||
@PathVariable("id") Long id);
|
||||
|
||||
|
||||
@Operation(summary = "Api to delete a document category", responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@DeleteMapping(value = "/{id}")
|
||||
ResponseEntity<Response<Void>> deleteCategory(HttpServletRequest request,
|
||||
@Parameter(description = "The category id", required = true)
|
||||
@PathVariable("id") Long id);
|
||||
|
||||
|
||||
@Operation(summary = "API to update a document category", responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@PutMapping(value = "/{id}", produces = "application/json")
|
||||
ResponseEntity<Response<CategoryResponse>> updateCategory(HttpServletRequest request,
|
||||
@Parameter(description = "The category id", required = true)
|
||||
@PathVariable("id") Long id,
|
||||
@Parameter(description = "Category request object", required = true)
|
||||
@Valid @RequestBody CategoryRequest categoryRequest);
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.enums.CompanyDocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.CompanyDocumentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.FormRequest;
|
||||
import net.gepafin.tendermanagement.model.response.CompanyDocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Validated
|
||||
public interface CompanyDocumentApi {
|
||||
@Operation(summary = "Api to upload a file for company",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))})
|
||||
@PostMapping(value = "/company/{companyId}/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
default ResponseEntity<Response<List<CompanyDocumentResponseBean>>> uploadFileForCompany(HttpServletRequest httpServletRequest,
|
||||
@Parameter(description = "Company Id", required = true) @PathVariable("companyId") Long companyId,
|
||||
@Parameter(description = "The Category id", required = true) @RequestParam(value = "categoryId", required = false) Long categoryId,
|
||||
@RequestParam("documentType") CompanyDocumentTypeEnum documentTypeEnum,
|
||||
@RequestParam("expirationDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime expirationDate,
|
||||
@RequestParam("file") List<MultipartFile> files) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Operation(summary = "Api to update company document",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))})
|
||||
@PutMapping(value = "/{id}",produces = "application/json")
|
||||
default ResponseEntity<Response<CompanyDocumentResponseBean>> updateCompanyDocument(HttpServletRequest httpServletRequest, @Parameter(description = "Company Document Id", required = true) @PathVariable("id") Long companyDocumentId,@Valid @RequestBody CompanyDocumentRequest companyDocumentRequest) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Operation(summary = "API to get company document by id",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Response<CompanyDocumentResponseBean>> getCompanyDocumentById(HttpServletRequest request,
|
||||
@Parameter(description = "Company Document Id", required = true)
|
||||
@PathVariable("id") Long id);
|
||||
|
||||
@Operation(summary = "API to delete a file by company document id",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "File deleted successfully"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@DeleteMapping(value = "")
|
||||
default ResponseEntity<Response<Void>> deleteCompanyFile(HttpServletRequest httpServletRequest,
|
||||
@RequestParam( "id") Long id) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "Api to copy a company document",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))})
|
||||
@PutMapping(value = "/{id}/document/upload", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
default ResponseEntity<Response<DocumentResponseBean>> validateAndDuplicateCompanyDocument (HttpServletRequest httpServletRequest, @Parameter(description = "Company Document Id", required = true) @PathVariable("id") Long companyDocumentId,
|
||||
@Parameter(description = "Application Id", required = true) @RequestParam Long applicationId,
|
||||
@RequestParam("documentType") DocumentTypeEnum documentTypeEnum) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Operation(summary = "API to get all company documents",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@GetMapping(value = "/company/{companyId}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Response<List<CompanyDocumentResponseBean>>> getAllCompanyDocuments(HttpServletRequest request,
|
||||
@Parameter(description = "Company Id", required = true)
|
||||
@PathVariable("companyId") Long companyId , @RequestParam(value = "documentType", required = false) CompanyDocumentTypeEnum documentTypeEnum);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
||||
import net.gepafin.tendermanagement.model.request.CategoryRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
||||
import net.gepafin.tendermanagement.model.response.CategoryResponse;
|
||||
import net.gepafin.tendermanagement.model.response.HubResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.CategoryService;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.web.rest.api.CategoryApi;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("${openapi.gepafin.base-path:/v1/category}")
|
||||
public class CategoryApiController implements CategoryApi {
|
||||
|
||||
@Autowired
|
||||
LoggingUtil loggingUtil;
|
||||
|
||||
@Autowired
|
||||
CategoryService categoryService;
|
||||
|
||||
public ResponseEntity<Response<CategoryResponse>> createDocumentCategory(HttpServletRequest request, @Valid CategoryRequest categoryRequest){
|
||||
|
||||
/** This code is responsible for creating user action logs for the "Create Document category" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.INSERT)
|
||||
.actionContext(UserActionContextEnum.CREATE_DOCUMENT_CATEGORY).build());
|
||||
|
||||
CategoryResponse categoryResponse = categoryService.createDocumentCategory(request,categoryRequest);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<>(categoryResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.DOCUMENT_CATEGORY_CREATE_SUCCESS)));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<CategoryResponse>> getDocumentCategoryById(HttpServletRequest request, Long id) {
|
||||
|
||||
/** This code is responsible for creating user action logs for the "get document category by id" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
||||
.actionContext(UserActionContextEnum.GET_DOCUMENT_CATEGORY).build());
|
||||
|
||||
CategoryResponse categoryResponse = categoryService.getDocumentCategoryById(request,id);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(categoryResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.DOCUMENT_CATEGORY_GET_SUCCESS)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<Void>> deleteCategory(HttpServletRequest request, Long id) {
|
||||
|
||||
/** This code is responsible for creating user action logs for the "Delete category" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.DELETE).actionContext(UserActionContextEnum.DELETE_DOCUMENT_CATEGORY).build());
|
||||
|
||||
categoryService.deleteCategory(request,id);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.DOCUMENT_CATEGORY_DELETE_SUCCESS)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<CategoryResponse>> updateCategory(HttpServletRequest request, Long id, CategoryRequest categoryRequest) {
|
||||
|
||||
/** This code is responsible for "Updating Category details" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.UPDATE)
|
||||
.actionContext(UserActionContextEnum.UPDATE_DOCUMENT_CATEGORY).build());
|
||||
|
||||
CategoryResponse categoryResponse = categoryService.updateCategory(request,id, categoryRequest);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(categoryResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.DOCUMENT_CATEGORY_UPDATE_SUCCESS)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.dao.CompanyDocumentDao;
|
||||
import net.gepafin.tendermanagement.enums.*;
|
||||
import net.gepafin.tendermanagement.model.request.CompanyDocumentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
||||
import net.gepafin.tendermanagement.model.response.CompanyDocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.CompanyDocumentService;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.web.rest.api.CompanyDocumentApi;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("${openapi.gepafin.base-path:/v1/companyDocument}")
|
||||
@Slf4j
|
||||
public class CompanyDocumentApiControlller implements CompanyDocumentApi {
|
||||
|
||||
@Autowired
|
||||
private CompanyDocumentService companyDocumentService;
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
|
||||
@Autowired
|
||||
private CompanyDocumentDao companyDocumentDao;
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<List<CompanyDocumentResponseBean>>> uploadFileForCompany(HttpServletRequest request, Long companyId, Long categoryId, CompanyDocumentTypeEnum companyDocumentSourceTypeEnum, LocalDateTime expirationDate,
|
||||
List<MultipartFile> files) {
|
||||
try {
|
||||
UserActionContextEnum userActionContext = companyDocumentDao.getUserActionContextEnum(companyDocumentSourceTypeEnum);
|
||||
|
||||
/** This code is responsible for creating user action logs for the "upload document for company" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.UPLOAD).actionContext(userActionContext).build());
|
||||
|
||||
List<CompanyDocumentResponseBean> responseBeans = companyDocumentService.uploadFileForCompany(request,files, companyId, categoryId ,companyDocumentSourceTypeEnum,expirationDate);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<List<CompanyDocumentResponseBean>>(responseBeans, Status.SUCCESS, Translator.toLocale(GepafinConstant.FILES_UPLOADED_MSG)));
|
||||
} catch (CustomValidationException ex) {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<CompanyDocumentResponseBean>> updateCompanyDocument(HttpServletRequest httpServletRequest, Long companyDocumentId, CompanyDocumentRequest companyDocumentRequest) {
|
||||
|
||||
/** This code is responsible for creating user action logs for the "update company document" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(httpServletRequest).actionType(UserActionLogsEnum.UPDATE).actionContext(UserActionContextEnum.UPDATE_COMPANY_DOCUMENT).build());
|
||||
|
||||
CompanyDocumentResponseBean responseBeans = companyDocumentService.updateCompanyDocument(httpServletRequest, companyDocumentId, companyDocumentRequest);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<CompanyDocumentResponseBean>(responseBeans, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMPANY_DOCUMENT_UPDATED_SUCCESSFULLY)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<CompanyDocumentResponseBean>> getCompanyDocumentById(HttpServletRequest request, Long id) {
|
||||
/** This code is responsible for creating user action logs for the "Get Company Document" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW).actionContext(UserActionContextEnum.GET_COMPANY_DOCUMENT).build());
|
||||
|
||||
CompanyDocumentResponseBean companyDocumentResponseBean = companyDocumentService.getCompanyDocument(request, id);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<CompanyDocumentResponseBean>(companyDocumentResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMPANY_DOCUMENT_FETCHED_SUCCESSFULLY)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<Void>> deleteCompanyFile(HttpServletRequest request, Long companyDocumentId) {
|
||||
|
||||
/** This code is responsible for creating user action logs for the "delete company document" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.DELETE).actionContext(UserActionContextEnum.DELETE_COMPANY_DOCUMENT).build());
|
||||
|
||||
companyDocumentService.deleteCompanyFile(request,companyDocumentId);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<Void>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.FILE_DELETED_SUCCESSFULLY_MSG)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<DocumentResponseBean>> validateAndDuplicateCompanyDocument(HttpServletRequest httpServletRequest, Long companyDocumentId , Long applicationId,DocumentTypeEnum typeEnum) {
|
||||
|
||||
/** This code is responsible for creating user action logs for the "duplicate company document" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(httpServletRequest).actionType(UserActionLogsEnum.UPDATE).actionContext(UserActionContextEnum.DUPLICATE_COMPANY_DOCUMENT).build());
|
||||
|
||||
DocumentResponseBean responseBeans = companyDocumentService.validateAndDuplicateCompanyDocument(httpServletRequest, companyDocumentId,applicationId,typeEnum);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<DocumentResponseBean>(responseBeans, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMPANY_DOCUMENT_COPIED_SUCCESSFULLY)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<List<CompanyDocumentResponseBean>>> getAllCompanyDocuments(HttpServletRequest request, Long companyId, CompanyDocumentTypeEnum typeEnum) {
|
||||
log.info("Get All Company Document");
|
||||
|
||||
/** This code is responsible for creating user action logs for the "get all Company Document" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
||||
.actionContext(UserActionContextEnum.GET_ALL_COMPANY_DOCUMENT).build());
|
||||
|
||||
List<CompanyDocumentResponseBean> companyDocumentResponseBeans = companyDocumentService.getAllCompanyDocument(request,companyId,typeEnum);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(companyDocumentResponseBeans, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMPANY_DOCUMENT_FETCHED_SUCCESSFULLY)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -2418,4 +2418,102 @@
|
||||
<modifyDataType tableName="call" columnName="product_id" newDataType="INTEGER"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="24-02-2025_RK_192024" author="Rajesh Khore">
|
||||
<createTable tableName="category">
|
||||
<column name="id" type="INTEGER" autoIncrement="true">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="CATEGORY_NAME" type="VARCHAR(255)"/>
|
||||
<column name="DESCRIPTION" type="TEXT"/>
|
||||
<column name="IS_DELETED" type="BOOLEAN" defaultValue="false"/>
|
||||
<column name="created_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||
<constraints nullable="true"/>
|
||||
</column>
|
||||
</createTable>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="24-02-2025_RK_190220" author="Rajesh Khore">
|
||||
<createTable tableName="company_document">
|
||||
<column name="id" type="INTEGER" autoIncrement="true">
|
||||
<constraints primaryKey="true" primaryKeyName="company_document_pkey" nullable="false"/>
|
||||
</column>
|
||||
<column name="file_name" type="VARCHAR(255)"/>
|
||||
<column name="file_path" type="TEXT"/>
|
||||
<column name="type" type="VARCHAR(255)"/>
|
||||
<column name="is_deleted" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="uploaded_by" type="INTEGER"/>
|
||||
<column name="expiration_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="status" type="VARCHAR(255)"/>
|
||||
<column name="created_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||
<constraints nullable="true"/>
|
||||
</column>
|
||||
<column name="USER_WITH_COMPANY_ID" type="INTEGER">
|
||||
<constraints foreignKeyName="fk_USER_WITH_COMPANY_COMPANY_DOCUMENT" references="user_with_company(id)" nullable="false"/>
|
||||
</column>
|
||||
<column name="COMPANY_ID" type="INTEGER">
|
||||
<constraints nullable="true" foreignKeyName="fk_COMPANY_COMPANY_DOCUMENT" references="company(id)"/>
|
||||
</column>
|
||||
<column name="CATEGORY_ID" type="INTEGER">
|
||||
<constraints nullable="true" foreignKeyName="fk_CATEGORY_COMPANY_DOCUMENT" references="category(id)"/>
|
||||
</column>
|
||||
</createTable>
|
||||
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="24-02-2025_RK_020220" author="Rajesh Khore">
|
||||
<insert tableName="s3_path_configuration">
|
||||
<column name="type" value="COMPANY_DOCUMENT"/>
|
||||
<column name="path" value="company/{company_id}"/>
|
||||
<column name="bucket_name" value="mementoresources"/>
|
||||
<column name="created_date" value="2025-02-20 03:00:00"/>
|
||||
<column name="updated_date" value="2025-02-20 03:00:00"/>
|
||||
<column name="parent_folder" value="gepafin/local"/>
|
||||
</insert>
|
||||
|
||||
<insert tableName="s3_path_configuration">
|
||||
<column name="type" value="DELETED_PERSONAL_DOCUMENT"/>
|
||||
<column name="path" value="company/{company_id}/deleted"/>
|
||||
<column name="bucket_name" value="mementoresources"/>
|
||||
<column name="created_date" value="2025-02-20 03:00:00"/>
|
||||
<column name="updated_date" value="2025-02-20 03:00:00"/>
|
||||
<column name="parent_folder" value="gepafin/local"/>
|
||||
</insert>
|
||||
|
||||
<insert tableName="s3_path_configuration">
|
||||
<column name="type" value="PERSONAL_DOCUMENT"/>
|
||||
<column name="path" value="company/{company_id}"/>
|
||||
<column name="bucket_name" value="mementoresources"/>
|
||||
<column name="created_date" value="2025-02-20 03:00:00"/>
|
||||
<column name="updated_date" value="2025-02-20 03:00:00"/>
|
||||
<column name="parent_folder" value="gepafin/local"/>
|
||||
</insert>
|
||||
|
||||
<insert tableName="s3_path_configuration">
|
||||
<column name="type" value="DELETED_COMPANY_DOCUMENT"/>
|
||||
<column name="path" value="company/{company_id}/deleted"/>
|
||||
<column name="bucket_name" value="mementoresources"/>
|
||||
<column name="created_date" value="2025-02-20 03:00:00"/>
|
||||
<column name="updated_date" value="2025-02-20 03:00:00"/>
|
||||
<column name="parent_folder" value="gepafin/local"/>
|
||||
</insert>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="24-02-2025_RK_125215" author="Rajesh Khore">
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/updated_expiration_scheduler_data_24_02_2025.sql"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="24-02-2025_RK_125145" author="Rajesh Khore">
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/updated_json_template_for_notification_24_02_2025.sql"/>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
INSERT INTO expiration_config (interval_days, type, created_date, updated_date)
|
||||
VALUES
|
||||
(7, 'COMPANY_DOCUMENT', '2025-02-24T11:00:51', '2025-02-24T11:00:51');
|
||||
@@ -0,0 +1,2 @@
|
||||
INSERT INTO notification_type (notification_name,title, json_template,created_date,updated_date,is_deleted) VALUES
|
||||
('COMPANY_DOCUMENT_EXPIRATION_REMINDER','Il documento sta per scadere','Il documento "{{file_name}}" per lazienda "{{company_name}}" scadrà il {{expiration_date}}. Assicurati di rinnovarlo o sostituirlo prima della scadenza.','2025-02-24T10:16:26.472Z','2025-02-24T10:16:26.472Z','false');
|
||||
@@ -371,4 +371,17 @@ validation.required.requested.amount=The Requested Amount configuration should b
|
||||
company.id.not.null=Company ID cannot be null.
|
||||
formula.amount.not.matches.requested.amount= The {0} does not matches to calculated amount.
|
||||
|
||||
document.category.update.success = Document Category updated successfully.
|
||||
document.category.delete.success = Document Category deleted successfully.
|
||||
document.category.get.success = Document Category fetched successfully.
|
||||
document.category.success = Document Category created successfully.
|
||||
document.category.not.found = Document Category not found.
|
||||
error.moving.file.to.deleted.folder = Error occurred while moving company file to deleted folder.
|
||||
|
||||
company.document.fetched.successfully = Company Document fetched successfully.
|
||||
company.document.updated.successfully = Company Document Updated successfully.
|
||||
category.cannot.be.deleted = Category cannot be deleted as it is associated with company documents.
|
||||
company.document.copied.successfully = Company Document Copied successfully.
|
||||
invalid.expiration.date = Invalid Expiration Date
|
||||
|
||||
|
||||
|
||||
@@ -362,4 +362,17 @@ validation.required.requested.amount=La configurazione dell'importo richiesto
|
||||
company.id.not.null=L'ID dell'azienda non pu? essere nullo.
|
||||
formula.amount.not.matches.requested.amount=Il {0} non corrisponde all'importo calcolato.
|
||||
|
||||
document.category.update.success = Categoria documento aggiornata correttamente.
|
||||
document.category.delete.success = Categoria documento eliminata correttamente.
|
||||
document.category.not.found = Categoria documento non trovata.
|
||||
document.category.get.success = Categoria del documento recuperata correttamente.
|
||||
document.category.success =Categoria documento creata correttamente.
|
||||
company.document.copied.successfully = Documento aziendale copiato correttamente.
|
||||
error.moving.file.to.deleted.folder = Si è verificato un errore durante lo spostamento del file aziendale nella cartella eliminata.ss
|
||||
|
||||
company.document.fetched.successfully = Documento aziendale recuperato con successo.
|
||||
company.document.updated.successfully = Documento aziendale aggiornato con successo.
|
||||
category.cannot.be.deleted = La categoria non può essere eliminata perché è associata a documenti aziendali.
|
||||
invalid.expiration.date = Data di scadenza non valida
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user