Added audit for application and faq.
This commit is contained in:
@@ -56,20 +56,20 @@ public class FaqDao {
|
||||
LoggingUtil loggingUtil;
|
||||
|
||||
public FaqResponseBean createFaq(FaqReq faqRequest, UserEntity userEntity, Long callId, Long companyId) {
|
||||
|
||||
CallEntity callEntity = callService.validateCall(callId);
|
||||
FaqEntity entity = createOrUpdateFaqEntity(faqRequest, callEntity, userEntity,
|
||||
LookUpDataTypeEnum.FAQ);
|
||||
FaqEntity entity = createOrUpdateFaqEntity(faqRequest, callEntity, userEntity, LookUpDataTypeEnum.FAQ);
|
||||
FaqEntity oldFaqEntity = Utils.getClonedEntityForData(entity);
|
||||
if (validator.checkIsBeneficiary() && companyId == null) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.COMPANY_ID_MANDATORY));
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.COMPANY_ID_MANDATORY));
|
||||
}
|
||||
if(companyId!=null) {
|
||||
if (companyId != null) {
|
||||
companyService.validateCompany(companyId);
|
||||
entity.setCompanyId(companyId);
|
||||
}
|
||||
faqRepository.save(entity);
|
||||
if(entity.getCompanyId()!=null) {
|
||||
|
||||
if (entity.getCompanyId() != null) {
|
||||
/** This code is responsible for adding a version history log for the "Create FAQ" operation. **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldFaqEntity).newData(entity).build());
|
||||
}
|
||||
@@ -88,12 +88,15 @@ public class FaqDao {
|
||||
}
|
||||
|
||||
public void deleteFaq(Long id) {
|
||||
|
||||
FaqEntity faqEntity = validateFaq(id);
|
||||
FaqEntity oldFaqEntity = Utils.getClonedEntityForData(faqEntity);
|
||||
faqEntity.setIsDeleted(Boolean.TRUE);
|
||||
faqRepository.save(faqEntity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "soft delete faq" operation **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.SOFT_DELETE).oldData(oldFaqEntity).newData(faqEntity).build());
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.SOFT_DELETE).oldData(oldFaqEntity).newData(faqEntity).build());
|
||||
}
|
||||
|
||||
public FaqEntity validateFaq(Long id) {
|
||||
@@ -107,16 +110,14 @@ public class FaqDao {
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
public FaqEntity createOrUpdateFaqEntity(FaqReq faqReq, CallEntity callEntity, UserEntity userEntity,
|
||||
LookUpDataTypeEnum type) {
|
||||
public FaqEntity createOrUpdateFaqEntity(FaqReq faqReq, CallEntity callEntity, UserEntity userEntity, LookUpDataTypeEnum type) {
|
||||
|
||||
FaqEntity faqEntity = null;
|
||||
FaqEntity oldFaqEntity = null;
|
||||
VersionActionTypeEnum actionType = VersionActionTypeEnum.INSERT;
|
||||
if (isExistingFaq(faqReq)) {
|
||||
faqEntity = faqRepository.findByIdAndCallIdAndIsDeletedFalse(faqReq.getId(), callEntity.getId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.FAQ_NOT_FOUND)));
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.FAQ_NOT_FOUND)));
|
||||
oldFaqEntity = Utils.getClonedEntityForData(faqEntity);
|
||||
actionType = VersionActionTypeEnum.UPDATE;
|
||||
} else {
|
||||
@@ -130,8 +131,7 @@ public class FaqDao {
|
||||
faqEntity.setIsDeleted(false);
|
||||
actionType = VersionActionTypeEnum.INSERT;
|
||||
}
|
||||
if (faqReq.getResponse() != null && (faqEntity.getResponse() == null
|
||||
|| Boolean.FALSE.equals(faqReq.getResponse().equals(faqEntity.getResponse())))) {
|
||||
if (faqReq.getResponse() != null && (faqEntity.getResponse() == null || Boolean.FALSE.equals(faqReq.getResponse().equals(faqEntity.getResponse())))) {
|
||||
faqEntity.setResponseDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
}
|
||||
setIfUpdated(faqEntity::getTitle, faqEntity::setTitle, faqReq.getTitle());
|
||||
|
||||
Reference in New Issue
Block a user