Skip to content

Conversation

@walder86
Copy link
Owner

Добавить зависимости spring. Создать модели данных и котроллеры.

private final Map<Long, Film> films = new HashMap<>();

@GetMapping
public Collection<Film> findAll() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

залоггируй вызов метода

@PostMapping
public Film create(@Valid @RequestBody Film film) {

if (film.getReleaseDate().isBefore(LocalDate.of(1895, 12, 28))) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

эта валидация нужна и при обновлении фильма, поэтому вынеси в отдельный метод

log.debug("Пользователь с логином " + user.getLogin() + " уже существует");
throw new ValidationException("Пользователь с логином " + user.getLogin() + " уже существует");
}
if (user.getLogin().contains(" ")) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

эта проверка нужна и при обновлении пользователя, вынеси в отдельный метод

log.debug("Логин должен быть без пробелов");
throw new ValidationException("Логин должен быть без пробелов");
}
if (user.getBirthday().isAfter(LocalDate.now())) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

как и эта

}

user.setId(getNextId());
if (user.getName() == null || user.getName().isBlank())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

как и эта процедура

@Size(max = 200)
private String description;

private LocalDate releaseDate;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

для этого поля нужна аннотация @NotNull

private LocalDate releaseDate;

@Positive
private Integer duration;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и для этого тоже

private Long id;

@Email
private String email;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

для этого поля нужна аннотация @NotNull

@Email
private String email;

@NotNull

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лишняя аннотация, @notblank покроет и null, и пустую строку


private String name;

private LocalDate birthday;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

для этого поля нужна аннотация @NotNull

@walder86 walder86 merged commit 4efa976 into main May 29, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants