Fixed form issue

This commit is contained in:
rajesh
2024-09-19 14:39:14 +05:30
parent 500a3784fd
commit 569adb92d6
2 changed files with 52 additions and 39 deletions

View File

@@ -92,17 +92,20 @@ public class FormDao {
}
public FormResponseBean updateForm(Long formId, FormRequest formRequest,Boolean forceDeleteFlow){
ContentRequestBean contentRequestBean2=null;
String choosenField=null;
FormEntity formEntity = validateForm(formId);
callDao.validateUpdate(formEntity.getCall());
FlowDataEntity flowDataEntity=flowDataRepository.findByFormIdAndCallId(formEntity.getId(),formEntity.getCall().getId());
String choosenField=flowDataEntity.getChoosenField();
List<ContentRequestBean> contentRequestBean = Utils.convertJsonStringToList(formEntity.getContent(), ContentRequestBean.class);
for (ContentRequestBean contentRequestBean1 : contentRequestBean) {
FlowDataEntity flowDataEntity = flowDataRepository.findByFormIdAndChoosenField(formEntity.getId(), contentRequestBean1.getId());
if (flowDataEntity != null) {
choosenField = flowDataEntity.getChoosenField();
if (Boolean.TRUE.equals(contentRequestBean1.getId().equals(choosenField))) {
contentRequestBean2 = contentRequestBean1;
break;
}
}
}
if (contentRequestBean2 != null) {
List<SettingRequestBean> settingRequestBeansDB = contentRequestBean2.getSettings();
for (ContentRequestBean contentRequestBeanRequest : formRequest.getContent()) {
@@ -138,6 +141,13 @@ public class FormDao {
}
}
}
else {
Utils.setIfUpdated(formEntity::getLabel, formEntity::setLabel, formRequest.getLabel());
Utils.setIfUpdated(formEntity::getContent, formEntity::setContent, setContentResponseBean(formRequest.getContent()));
formEntity.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
formEntity = saveFormEntity(formEntity);
return convertFormEntityToFormResponseBean(formEntity);
}
return null;
}

View File

@@ -17,4 +17,7 @@ public interface FlowDataRepository extends JpaRepository<FlowDataEntity,Long> {
public Optional<FlowDataEntity> findByChoosenValueAndFormIdIn(String fieldValue, List<Long> nextFormIds);
public List<FlowDataEntity> findByFormIdInAndCallId(List<Long> previousFormIds, Long callId);
public FlowDataEntity findByFormIdAndChoosenField(Long formId, String choosenField);
}