Skip to content

Commit 6994559

Browse files
committed
fix13
1 parent 29904d3 commit 6994559

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

ewm-service/src/main/java/ru/practicum/ewm/event/service/PublicEventServiceImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ public EventFullDto getEvent(Long eventId, HttpServletRequest request) {
102102
Map<Long, Long> viewsMap = getViewsMap(List.of(event));
103103
Long views = viewsMap.getOrDefault(eventId, 0L);
104104

105-
if (eventId == 7L && views > 0) {
106-
views = 1L;
107-
}
105+
// if (eventId == 7L && views > 0) {
106+
// views = 1L;
107+
// }
108108

109109
Long confirmed = eventRepository.countConfirmedRequests(eventId);
110110
return EventMapper.toEventFullDto(event, views, confirmed);

statistics/server/src/main/java/ru/practicum/statistics/exception/ErrorHandler.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import lombok.Getter;
55
import org.springframework.http.HttpStatus;
66
import org.springframework.web.bind.MethodArgumentNotValidException;
7+
import org.springframework.web.bind.MissingServletRequestParameterException;
78
import org.springframework.web.bind.annotation.ExceptionHandler;
89
import org.springframework.web.bind.annotation.ResponseStatus;
910
import org.springframework.web.bind.annotation.RestControllerAdvice;
@@ -46,4 +47,10 @@ static class ErrorResponse {
4647
private final String error;
4748
private final String description;
4849
}
50+
51+
@ExceptionHandler(MissingServletRequestParameterException.class)
52+
@ResponseStatus(HttpStatus.BAD_REQUEST)
53+
public ErrorResponse handleMissingParams(MissingServletRequestParameterException e) {
54+
return new ErrorResponse("Ошибка валидации", "Отсутствует обязательный параметр: " + e.getParameterName());
55+
}
4956
}

0 commit comments

Comments
 (0)