Skip to content

fix: убрать неиспользуемые библиотеки#5

Open
moratti72r wants to merge 3 commits intomainfrom
add-database
Open

fix: убрать неиспользуемые библиотеки#5
moratti72r wants to merge 3 commits intomainfrom
add-database

Conversation

@moratti72r
Copy link
Owner

No description provided.

Copy link

@TyutterinYakov TyutterinYakov left a comment

Choose a reason for hiding this comment

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

Добрый день! Отметил оставшиеся небольшие недочеты) Хорошего дня! Если возникнут вопросы - пиши в пачку, буду рад помочь🌞


@PutMapping("/{id}/friends/{friendId}")
public User addToFriends(@PathVariable Integer id, @PathVariable Integer friendId) {
public ResponseEntity addToFriends(@PathVariable Integer id, @PathVariable Integer friendId) {

Choose a reason for hiding this comment

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

Возврат ResponseEntity для установки код ответа 200 - не требуется, так как это стандартный код ответа, если все хорошо)


@DeleteMapping("/{id}/friends/{friendId}")
public User removeToFriends(@PathVariable Integer id, @PathVariable Integer friendId) {
public ResponseEntity removeToFriends(@PathVariable Integer id, @PathVariable Integer friendId) {

Choose a reason for hiding this comment

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

Возврат ResponseEntity для установки код ответа 200 - не требуется, так как это стандартный код ответа, если все хорошо)
Можно было бы сделать метод void

@RequiredArgsConstructor
public class MPAController {

private final MpaDaoImpl mpaDao;

Choose a reason for hiding this comment

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

Уровень контроллера не должен работать напрямую с уровнем доступа к данным) Всех взаимодействие должно осуществляться через прослойку в виде сервиса)

@RequiredArgsConstructor
public class GenreController {

private final GenreDao genreDao;

Choose a reason for hiding this comment

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

Уровень контроллера не должен работать напрямую с уровнем доступа к данным) Всех взаимодействие должно осуществляться через прослойку в виде сервиса)


@PutMapping("/{id}/like/{userId}")
public Film addLike(@PathVariable Integer id, @PathVariable Integer userId) {
public ResponseEntity<?> addLike(@PathVariable Integer id, @PathVariable Integer userId) {

Choose a reason for hiding this comment

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

Аналогично и здесь, метод следует сделать void


@Override
public List<User> getAllFriends(Integer id) {
if (contains(id)) {

Choose a reason for hiding this comment

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

Аналогично, подобные проверки следует вынести на уровень сервиса, так как это часть бизнес-правил, не очень принято выбрасывать исключение на уровне репозитория)


@Override
public List<User> getMutualFriends(Integer idUser, Integer otherIdUser) {
if (idUser.equals(otherIdUser)) {

Choose a reason for hiding this comment

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

Аналогично, подобные проверки следует вынести на уровень сервиса, так как это часть бизнес-правил, не очень принято выбрасывать исключение на уровне репозитория)

throw new IncorrectArgumentsException(UserDbStorage.class);
}
if (!contains(idUser)) {
throw new EntityNotFoundException(UserDbStorage.class);

Choose a reason for hiding this comment

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

Аналогично, подобные проверки следует вынести на уровень сервиса, так как это часть бизнес-правил, не очень принято выбрасывать исключение на уровне репозитория)


@Override
public User upDate(User user) {
SqlRowSet usersRows = jdbcTemplate.queryForRowSet("SELECT * FROM mov_users WHERE id = ?", user.getId());

Choose a reason for hiding this comment

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

Аналогично, подобные проверки следует вынести на уровень сервиса, так как это часть бизнес-правил, не очень принято выбрасывать исключение на уровне репозитория)

(предложение)Но можно было бы обойтись здесь даже без дополнительно запроса, а проверить то, что вернул метод update, так как он вернет значение int, равное количеству обновленных строк)


@Override
public Film upDate(Film film) {
SqlRowSet filmsRows = jdbcTemplate.queryForRowSet("select * from films where id = ?", film.getId());

Choose a reason for hiding this comment

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

Аналогично, подобные проверки следует вынести на уровень сервиса, так как это часть бизнес-правил, не очень принято выбрасывать исключение на уровне репозитория)

(предложение)Но можно было бы обойтись здесь даже без дополнительно запроса, а проверить то, что вернул метод update, так как он вернет значение int, равное количеству обновленных строк)

Copy link

@TyutterinYakov TyutterinYakov left a comment

Choose a reason for hiding this comment

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

Добрый день! Поздравляю с успешной сдачей спринта! Сил и терпения на этом сложном, но интересном пути🌞 Успехов в обучении и прекрасного дня!🎇☀️

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.

2 participants

Comments