#125 check method

This commit is contained in:
Nightblade73 2019-05-21 15:53:42 +04:00
parent 59bc0dbd34
commit 8b52518c4a
2 changed files with 20 additions and 1 deletions

View File

@ -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()))

View File

@ -42,12 +42,20 @@
placeholder="http://"/>
</div>
<p th:if="${#fields.hasErrors('url')}" th:errors="*{url}"
class="alert alert-danger">Incorrect description</p>
<p class="help-block text-danger"></p>
<div class="form-group">
<label for="description">Описание:</label>
<textarea class="form-control" rows="8" th:field="*{description}" id="description">
</textarea>
</div>
<p th:if="${#fields.hasErrors('description')}" th:errors="*{description}"
class="alert alert-danger">Incorrect description</p>
<p class="help-block text-danger"></p>
<div class="form-group">
<label for="deadlines">Дедлайны:</label>
<div class="deadline-list form-control list-group" id="deadlines">
@ -65,6 +73,7 @@
</div>
</div>
</div>
<p th:if="${#fields.hasErrors('deadlines')}" th:errors="*{deadlines}"
class="alert alert-danger">Incorrect title</p>
<p class="help-block text-danger"></p>
@ -94,6 +103,10 @@
</div>
</div>
</div>
<p th:if="${#fields.hasErrors('beginDate') || #fields.hasErrors('endDate')}"
th:errors="*{beginDate}"
class="alert alert-danger">Incorrect date</p>
<p class="help-block text-danger"></p>
<div class="form-group">
<label for="members">Участники:</label>
@ -123,7 +136,6 @@
</div>
<div class="form-group d-flex justify-content-between flex-wrap">
<!--<input type="hidden" th:value="*{ping}" th:name="ping"/>-->
<input id="ping-button" class="btn btn-primary"
type="submit" name="pingConference" value="Ping участникам"
th:disabled="*{id == null ? 'true' : 'false'}"/>