From 6fe2ca6c5703107ab3bc162e8ee84e1b3ed85585 Mon Sep 17 00:00:00 2001 From: "Kayashov.SM" Date: Mon, 25 Aug 2025 14:57:06 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=B0=D1=82=D1=80=D0=B8=D0=B1=D1=83=D1=82=20=D0=BA?= =?UTF-8?q?=D0=B0=D1=80=D1=82=D0=B8=D0=BD=D0=BA=D0=B8=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D0=B8=D0=BD=D0=B3=D1=80=D0=B5=D0=B4=D0=B8=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=B8=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=20?= =?UTF-8?q?=D0=B0=D1=82=D1=80=D0=B8=D0=B1=D1=83=D1=82=20=D0=B0=D0=BD=D0=B3?= =?UTF-8?q?=D0=BB=D0=B8=D0=B9=D1=81=D0=BA=D0=BE=D0=B3=D0=BE=20=D0=BD=D0=B0?= =?UTF-8?q?=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/ingredients/EditIngredientPage.js | 4 ---- front/src/components/core/UserPopover.js | 3 ++- front/src/components/navigation/NavItem.js | 2 +- .../navigation}/isNavItemActive.js | 0 front/src/context/AuthContext.js | 2 +- front/src/context/UserContext.js | 2 +- front/src/lib/{ => clients}/TokenUtil.js | 2 +- front/src/lib/clients/api.js | 4 ++-- front/src/lib/sliceData.js | 18 ------------------ front/src/requests.js | 5 ----- .../dto/ingredient/IngredientResponseDto.java | 2 +- .../IngredientSimpleResponseDto.java | 2 +- .../ru/kayashov/bar/mapper/CocktailMapper.java | 2 +- .../kayashov/bar/mapper/IngredientMapper.java | 4 ++-- .../bar/model/entity/IngredientEntity.java | 2 +- .../bar/repository/IngredientRepository.java | 2 -- .../bar/service/IngredientService.java | 1 + 17 files changed, 15 insertions(+), 42 deletions(-) rename front/src/{lib => components/navigation}/isNavItemActive.js (100%) rename front/src/lib/{ => clients}/TokenUtil.js (95%) delete mode 100644 front/src/lib/sliceData.js diff --git a/front/src/app/pages/ingredients/EditIngredientPage.js b/front/src/app/pages/ingredients/EditIngredientPage.js index a96c311..b88dff0 100644 --- a/front/src/app/pages/ingredients/EditIngredientPage.js +++ b/front/src/app/pages/ingredients/EditIngredientPage.js @@ -111,10 +111,6 @@ export function EditIngredientPage() { variant="outlined" label={"Название"} value={ingredient.name} onChange={(e) => changeIngredientValue("name", e.target.value)}/> - changeIngredientValue("enName", e.target.value)}/> diff --git a/front/src/components/core/UserPopover.js b/front/src/components/core/UserPopover.js index 55af152..3a0643f 100644 --- a/front/src/components/core/UserPopover.js +++ b/front/src/components/core/UserPopover.js @@ -39,6 +39,7 @@ export function UserPopover({anchorEl, onClose, open}) { } catch (err) { logger.error('Sign out error', err); } + // eslint-disable-next-line }, [checkSession, location]); return ( @@ -85,7 +86,7 @@ export function UserPopover({anchorEl, onClose, open}) { } function userDescriptor(user) { - if(!user) { + if (!user) { return null; } if (!user.name) { diff --git a/front/src/components/navigation/NavItem.js b/front/src/components/navigation/NavItem.js index 0ea6b06..8a7db67 100644 --- a/front/src/components/navigation/NavItem.js +++ b/front/src/components/navigation/NavItem.js @@ -1,5 +1,5 @@ import Stack from "@mui/material/Stack"; -import {isNavItemActive} from "../../lib/isNavItemActive"; +import {isNavItemActive} from "./isNavItemActive"; import {navIcons} from "../core/navIcons"; import Box from "@mui/material/Box"; import Typography from "@mui/material/Typography"; diff --git a/front/src/lib/isNavItemActive.js b/front/src/components/navigation/isNavItemActive.js similarity index 100% rename from front/src/lib/isNavItemActive.js rename to front/src/components/navigation/isNavItemActive.js diff --git a/front/src/context/AuthContext.js b/front/src/context/AuthContext.js index 7cdfba6..7b3c5f8 100644 --- a/front/src/context/AuthContext.js +++ b/front/src/context/AuthContext.js @@ -1,7 +1,7 @@ import * as React from 'react'; import {useCallback, useEffect} from 'react'; import {logger} from "../lib/DefaultLogger"; -import {tokenUtil} from "../lib/TokenUtil"; +import {tokenUtil} from "../lib/clients/TokenUtil"; export const AuthContext = React.createContext(undefined); diff --git a/front/src/context/UserContext.js b/front/src/context/UserContext.js index 6e78ab9..16c0256 100644 --- a/front/src/context/UserContext.js +++ b/front/src/context/UserContext.js @@ -2,7 +2,7 @@ import * as React from "react"; import {createContext, useCallback, useEffect, useState} from "react"; import {logger} from "../lib/DefaultLogger"; import {userClient} from "../lib/clients/UserClient"; -import {tokenUtil} from "../lib/TokenUtil"; +import {tokenUtil} from "../lib/clients/TokenUtil"; export const UserContext = createContext(undefined); diff --git a/front/src/lib/TokenUtil.js b/front/src/lib/clients/TokenUtil.js similarity index 95% rename from front/src/lib/TokenUtil.js rename to front/src/lib/clients/TokenUtil.js index 5e84b11..437efb7 100644 --- a/front/src/lib/TokenUtil.js +++ b/front/src/lib/clients/TokenUtil.js @@ -1,5 +1,5 @@ import {decodeToken, isExpired} from "react-jwt"; -import {requests} from "../requests"; +import {requests} from "../../requests"; import axios from "axios"; class TokenUtil { diff --git a/front/src/lib/clients/api.js b/front/src/lib/clients/api.js index 6d7d2c2..fcf974b 100644 --- a/front/src/lib/clients/api.js +++ b/front/src/lib/clients/api.js @@ -1,7 +1,7 @@ import axios from "axios"; -import {tokenUtil} from "../TokenUtil"; +import {tokenUtil} from "./TokenUtil"; -const host = "localhost:8081"; //дебаг вместе с беком +const host = "localhost:8080"; //дебаг вместе с беком // const host = "192.168.1.100:8091"; //дебаг фронта // const host = "bar.kayashov.keenetic.pro"; //прод export const api = () => { diff --git a/front/src/lib/sliceData.js b/front/src/lib/sliceData.js deleted file mode 100644 index 9032d39..0000000 --- a/front/src/lib/sliceData.js +++ /dev/null @@ -1,18 +0,0 @@ -export const sliceData = (rows, page, elementOnPage) => { - if (!rows || rows.length === 0) { - return []; - } - - const maxPage = Math.ceil(rows.length / elementOnPage); - // const start = (page - 1) * elementOnPage; - const start = 0; - console.log(maxPage, start) - let end; - if (page === maxPage) { - end = rows.length; - } else { - end = start + elementOnPage; - } - - return rows.slice(start, end); -} \ No newline at end of file diff --git a/front/src/requests.js b/front/src/requests.js index 21e60d3..2fa6352 100644 --- a/front/src/requests.js +++ b/front/src/requests.js @@ -48,10 +48,5 @@ export const requests = { type: routes.ingredient + "/type", crud: routes.ingredient, }, - // receipt: { - // receipts: routes.bar + "receipt?id=", - // - // }, - unit: routes.unit + "/units" } \ No newline at end of file diff --git a/src/main/java/ru/kayashov/bar/controller/dto/ingredient/IngredientResponseDto.java b/src/main/java/ru/kayashov/bar/controller/dto/ingredient/IngredientResponseDto.java index b4e757e..fc8f280 100644 --- a/src/main/java/ru/kayashov/bar/controller/dto/ingredient/IngredientResponseDto.java +++ b/src/main/java/ru/kayashov/bar/controller/dto/ingredient/IngredientResponseDto.java @@ -32,7 +32,7 @@ public class IngredientResponseDto { .type(i.getType() != null ? i.getType().getName() : null) .abv(i.getAbv()) .isHave(i.getIsHave()) - .image("https://thecocktaildb.com/images/ingredients/" + i.getEnName() + "-Medium.png") + .image(i.getImage()) .description(i.getDescription()) .build(); } diff --git a/src/main/java/ru/kayashov/bar/controller/dto/ingredient/IngredientSimpleResponseDto.java b/src/main/java/ru/kayashov/bar/controller/dto/ingredient/IngredientSimpleResponseDto.java index 475ce24..1338fe3 100644 --- a/src/main/java/ru/kayashov/bar/controller/dto/ingredient/IngredientSimpleResponseDto.java +++ b/src/main/java/ru/kayashov/bar/controller/dto/ingredient/IngredientSimpleResponseDto.java @@ -16,7 +16,7 @@ public class IngredientSimpleResponseDto { public static IngredientSimpleResponseDto mapToDto(IngredientEntity ingredient) { return new IngredientSimpleResponseDto(ingredient.getId(), ingredient.getName(), - "https://thecocktaildb.com/images/ingredients/" + ingredient.getEnName() + "-Medium.png", + ingredient.getImage(), ingredient.getIsHave()); } } diff --git a/src/main/java/ru/kayashov/bar/mapper/CocktailMapper.java b/src/main/java/ru/kayashov/bar/mapper/CocktailMapper.java index d500d87..6d8d45b 100644 --- a/src/main/java/ru/kayashov/bar/mapper/CocktailMapper.java +++ b/src/main/java/ru/kayashov/bar/mapper/CocktailMapper.java @@ -154,7 +154,7 @@ public class CocktailMapper { private IngredientSimpleResponseDto createIngredientResponseDto(IngredientEntity i) { return new IngredientSimpleResponseDto(i.getId(), i.getName(), - "https://thecocktaildb.com/images/ingredients/" + i.getEnName() + "-Medium.png", + i.getImage(), i.getIsHave()); } diff --git a/src/main/java/ru/kayashov/bar/mapper/IngredientMapper.java b/src/main/java/ru/kayashov/bar/mapper/IngredientMapper.java index 9ffb41d..6fe8371 100644 --- a/src/main/java/ru/kayashov/bar/mapper/IngredientMapper.java +++ b/src/main/java/ru/kayashov/bar/mapper/IngredientMapper.java @@ -27,7 +27,7 @@ public class IngredientMapper { .type(i.getType() != null ? i.getType().getName() : null) .abv(i.getAbv()) .isHave(i.getIsHave()) - .image("https://thecocktaildb.com/images/ingredients/" + i.getEnName() + "-Medium.png") + .image(i.getImage()) .description(i.getDescription()) .build(); } @@ -40,7 +40,7 @@ public class IngredientMapper { private IngredientSimpleResponseDto mapIngredientToSimpleDto(IngredientEntity i) { return new IngredientSimpleResponseDto(i.getId(), i.getName(), - "https://thecocktaildb.com/images/ingredients/" + i.getEnName() + "-Medium.png", + i.getImage(), i.getIsHave()); } } diff --git a/src/main/java/ru/kayashov/bar/model/entity/IngredientEntity.java b/src/main/java/ru/kayashov/bar/model/entity/IngredientEntity.java index 6b2f217..7521f0c 100644 --- a/src/main/java/ru/kayashov/bar/model/entity/IngredientEntity.java +++ b/src/main/java/ru/kayashov/bar/model/entity/IngredientEntity.java @@ -33,10 +33,10 @@ public class IngredientEntity { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String name; - private String enName; private Boolean alcohol; private Integer abv; private Boolean isHave; + private String image; @Column(columnDefinition = "text") private String description; diff --git a/src/main/java/ru/kayashov/bar/repository/IngredientRepository.java b/src/main/java/ru/kayashov/bar/repository/IngredientRepository.java index c6aa875..fdaeb80 100644 --- a/src/main/java/ru/kayashov/bar/repository/IngredientRepository.java +++ b/src/main/java/ru/kayashov/bar/repository/IngredientRepository.java @@ -6,6 +6,4 @@ import ru.kayashov.bar.model.entity.IngredientEntity; import java.util.Optional; public interface IngredientRepository extends JpaRepository { - - Optional findByEnNameIgnoreCase(String name); } \ No newline at end of file diff --git a/src/main/java/ru/kayashov/bar/service/IngredientService.java b/src/main/java/ru/kayashov/bar/service/IngredientService.java index 925a789..d2b8dde 100644 --- a/src/main/java/ru/kayashov/bar/service/IngredientService.java +++ b/src/main/java/ru/kayashov/bar/service/IngredientService.java @@ -93,6 +93,7 @@ public class IngredientService { IngredientEntity entity; if (dto.getId() == null) { entity = new IngredientEntity(); + entity.setIsHave(false); } else { entity = repository.findById(dto.getId()) .orElse(null);