Conflicts resolved
This commit is contained in:
@@ -236,10 +236,12 @@ public class CallDao {
|
||||
Translator.toLocale(GepafinConstant.AMOUNT_GREATER_THAN_ZERO_MSG));
|
||||
}
|
||||
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,
|
||||
Translator.toLocale(GepafinConstant.INVALID_DATE_MSG));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public CreateCallResponseBean convertToCallResponseBean(CallEntity callEntity) {
|
||||
@@ -379,7 +381,7 @@ public class CallDao {
|
||||
|
||||
public CallEntity getCallById(Long callId) {
|
||||
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) {
|
||||
@@ -409,8 +411,31 @@ public class CallDao {
|
||||
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) {
|
||||
CallEntity callEntity = getCallById(callId);
|
||||
isValidDateRange(updateCallRequest, callEntity);
|
||||
setIfUpdated(callEntity::getName, callEntity::setName, updateCallRequest.getName());
|
||||
setIfUpdated(callEntity::getDescriptionShort, callEntity::setDescriptionShort,
|
||||
updateCallRequest.getDescriptionShort());
|
||||
|
||||
Reference in New Issue
Block a user