Fixed form issue
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user