From 8b52518c4a0411c760d7cac83153da69e4f2c628 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Tue, 21 May 2019 15:53:42 +0400 Subject: [PATCH] #125 check method --- .../conference/service/ConferenceService.java | 7 +++++++ .../templates/conferences/conference.html | 14 +++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index 38ce659..4ee4198 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -92,6 +92,7 @@ public class ConferenceService extends BaseService { conferenceDto.setName(conferenceDto.getTitle()); filterEmptyDeadlines(conferenceDto); checkEmptyFieldsOfDeadline(conferenceDto, errors); + checkEmptyFieldsOfDates(conferenceDto, errors); checkUniqueName(conferenceDto, errors, conferenceDto.getId(), @@ -301,6 +302,12 @@ public class ConferenceService extends BaseService { } } + private void checkEmptyFieldsOfDates(ConferenceDto conferenceDto, Errors errors) { + if (conferenceDto.getBeginDate() == null || conferenceDto.getEndDate() == null) { + errors.rejectValue("beginDate", "errorCode", "Даты должны быть заполнены"); + } + } + public void filterEmptyDeadlines(ConferenceDto conferenceDto) { conferenceDto.setDeadlines(conferenceDto.getDeadlines().stream() .filter(dto -> dto.getDate() != null || !org.springframework.util.StringUtils.isEmpty(dto.getDescription())) diff --git a/src/main/resources/templates/conferences/conference.html b/src/main/resources/templates/conferences/conference.html index d629d4e..201aa01 100644 --- a/src/main/resources/templates/conferences/conference.html +++ b/src/main/resources/templates/conferences/conference.html @@ -42,12 +42,20 @@ placeholder="http://"/> +

Incorrect description

+

+
+

Incorrect description

+

+
@@ -65,6 +73,7 @@
+

Incorrect title

@@ -94,6 +103,10 @@ +

Incorrect date

+

@@ -123,7 +136,6 @@
-