-
Notifications
You must be signed in to change notification settings - Fork 0
controllers-films-users. Создать модели данных и котроллеры. #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…данных и котроллеры.
| private final Map<Long, Film> films = new HashMap<>(); | ||
|
|
||
| @GetMapping | ||
| public Collection<Film> findAll() { |
There was a problem hiding this comment.
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))) { |
There was a problem hiding this comment.
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(" ")) { |
There was a problem hiding this comment.
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())) { |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
и для этого тоже
| private Long id; | ||
|
|
||
| private String email; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
для этого поля нужна аннотация @NotNull
| private String email; | ||
|
|
||
| @NotNull |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
для этого поля нужна аннотация @NotNull
…модели данных и котроллеры.
Добавить зависимости spring. Создать модели данных и котроллеры.