Skip to content

Conversation

@GwynbleiddWW
Copy link

Тесты не сделал, т.к. не очень понимаю как их делать, на курсе обучения мельком их захватывали. С докером знаком, но с H2, в данном задании, думаю, он особо не нужен, а с Heroku уже времени нет разбираться - дедлайн. Всё же постарался сделать так, чтобы было максимально современно и поменьше кода, настолько, насколько знаю про разработку)

Optional<Integer> getSocksMoreThan(String color, int cottonPart);

@Query("SELECT SUM (socks.quantity) FROM Socks AS socks WHERE socks.color = :color AND socks.cottonPart < :cottonPart")
Optional<Integer> getIdByColorAndCottonPart(String color, int cottonPart);

Choose a reason for hiding this comment

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

название метода не совпадают с запросом. может перепутал первый и последний?

}

public void income(SocksDto socksDto) {
Optional<Integer> id = socksRepository.getIdByColorAndCottonPart(socksDto.getColor(), socksDto.getCottonPart());

Choose a reason for hiding this comment

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

лишний запрос id, а потом объект по этому id. можно было бы сразу вытащить объект и его использовать


public int getAll(String color, String operation, int cottonPart) {
Optional<Integer> count = switch (operation) {
case "moreThan" -> socksRepository.getSocksMoreThan(color, cottonPart);

Choose a reason for hiding this comment

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

operation можно сделать enum, будет меньше ошибок

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