Conflicts resolved
This commit is contained in:
@@ -236,10 +236,12 @@ public class CallDao {
|
|||||||
Translator.toLocale(GepafinConstant.AMOUNT_GREATER_THAN_ZERO_MSG));
|
Translator.toLocale(GepafinConstant.AMOUNT_GREATER_THAN_ZERO_MSG));
|
||||||
}
|
}
|
||||||
if (createCallRequest.getStartDate().toLocalDate().isBefore(LocalDate.now())
|
if (createCallRequest.getStartDate().toLocalDate().isBefore(LocalDate.now())
|
||||||
|| createCallRequest.getEndDate().toLocalDate().isBefore(LocalDate.now())) {
|
|| createCallRequest.getEndDate().toLocalDate().isBefore(LocalDate.now()) || createCallRequest
|
||||||
|
.getStartDate().toLocalDate().isAfter(createCallRequest.getEndDate().toLocalDate())) {
|
||||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
Translator.toLocale(GepafinConstant.INVALID_DATE_MSG));
|
Translator.toLocale(GepafinConstant.INVALID_DATE_MSG));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreateCallResponseBean convertToCallResponseBean(CallEntity callEntity) {
|
public CreateCallResponseBean convertToCallResponseBean(CallEntity callEntity) {
|
||||||
@@ -379,7 +381,7 @@ public class CallDao {
|
|||||||
|
|
||||||
public CallEntity getCallById(Long callId) {
|
public CallEntity getCallById(Long callId) {
|
||||||
return callRepository.findById(callId).orElseThrow(() -> new CustomValidationException(Status.VALIDATION_ERROR,
|
return callRepository.findById(callId).orElseThrow(() -> new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
Translator.toLocale(GepafinConstant.NAME_NOT_EMPTY_MSG)));
|
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreateCallResponseBean createCallStep2(CreateCallRequestStep2 createCallRequest, Long userId) {
|
public CreateCallResponseBean createCallStep2(CreateCallRequestStep2 createCallRequest, Long userId) {
|
||||||
@@ -409,8 +411,31 @@ public class CallDao {
|
|||||||
return createCallResponseBean;
|
return createCallResponseBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void isValidDateRange(UpdateCallRequestStep1 updateCallRequest, CallEntity callEntity) {
|
||||||
|
LocalDate startDate = updateCallRequest.getStartDate() != null ? updateCallRequest.getStartDate().toLocalDate()
|
||||||
|
: null;
|
||||||
|
LocalDate endDate = updateCallRequest.getEndDate() != null ? updateCallRequest.getEndDate().toLocalDate()
|
||||||
|
: null;
|
||||||
|
Boolean isValid = true;
|
||||||
|
if (startDate != null && endDate != null && startDate.isAfter(endDate)) {
|
||||||
|
isValid = false;
|
||||||
|
} else if (startDate != null && callEntity.getEndDate() != null
|
||||||
|
&& startDate.isAfter(callEntity.getEndDate().toLocalDate())) {
|
||||||
|
isValid = false;
|
||||||
|
} else if (endDate != null && callEntity.getStartDate() != null
|
||||||
|
&& callEntity.getStartDate().toLocalDate().isAfter(endDate)) {
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Boolean.FALSE.equals(isValid)) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.INVALID_DATE_MSG));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public CreateCallResponseBean updateCallStep1(Long callId, UpdateCallRequestStep1 updateCallRequest, Long userId) {
|
public CreateCallResponseBean updateCallStep1(Long callId, UpdateCallRequestStep1 updateCallRequest, Long userId) {
|
||||||
CallEntity callEntity = getCallById(callId);
|
CallEntity callEntity = getCallById(callId);
|
||||||
|
isValidDateRange(updateCallRequest, callEntity);
|
||||||
setIfUpdated(callEntity::getName, callEntity::setName, updateCallRequest.getName());
|
setIfUpdated(callEntity::getName, callEntity::setName, updateCallRequest.getName());
|
||||||
setIfUpdated(callEntity::getDescriptionShort, callEntity::setDescriptionShort,
|
setIfUpdated(callEntity::getDescriptionShort, callEntity::setDescriptionShort,
|
||||||
updateCallRequest.getDescriptionShort());
|
updateCallRequest.getDescriptionShort());
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ call.invalid.date=Invalid start or end date.
|
|||||||
call.update.successfully=Call updated successfully.
|
call.update.successfully=Call updated successfully.
|
||||||
call.fetch.success=Call details fetched successfully.
|
call.fetch.success=Call details fetched successfully.
|
||||||
|
|
||||||
|
call.not.found=Call not found.
|
||||||
|
|
||||||
# Login-related messages
|
# Login-related messages
|
||||||
login.successfully=Login successfully.
|
login.successfully=Login successfully.
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ document.id.not.found=ID documento non trovato.
|
|||||||
call.invalid.date=Data di inizio o fine non valida.
|
call.invalid.date=Data di inizio o fine non valida.
|
||||||
call.update.successfully=Chiamata aggiornata con successo.
|
call.update.successfully=Chiamata aggiornata con successo.
|
||||||
call.fetch.success=Dettagli della chiamata recuperati con successo.
|
call.fetch.success=Dettagli della chiamata recuperati con successo.
|
||||||
|
call.not.found=Chiamata non trovata.
|
||||||
|
|
||||||
# Login-related messages
|
# Login-related messages
|
||||||
login.successfully=Accesso effettuato con successo.
|
login.successfully=Accesso effettuato con successo.
|
||||||
|
|||||||
Reference in New Issue
Block a user