diff --git a/data.mv.db b/data.mv.db
index cc68819..3880e3e 100644
Binary files a/data.mv.db and b/data.mv.db differ
diff --git a/src/main/java/com/example/demo/users/api/UserCatalogController.java b/src/main/java/com/example/demo/users/api/UserCatalogController.java
new file mode 100644
index 0000000..b11f749
--- /dev/null
+++ b/src/main/java/com/example/demo/users/api/UserCatalogController.java
@@ -0,0 +1,85 @@
+package com.example.demo.users.api;
+
+import org.springframework.security.core.annotation.AuthenticationPrincipal;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.support.SessionStatus;
+
+import com.example.demo.core.configuration.Constants;
+import com.example.demo.core.session.SessionCart;
+import com.example.demo.games.api.GameDto;
+import com.example.demo.games.model.GameEntity;
+import com.example.demo.games.service.GameService;
+import com.example.demo.genres.model.GenreEntity;
+
+import jakarta.validation.Valid;
+
+@Controller
+@RequestMapping(UserCatalogController.URL)
+public class UserCatalogController {
+
+ private static final String CATALOG_VIEW = "catalog";
+ public static final String URL = "/catalog";
+ private static final String PAGE_ATTRIBUTE = "page";
+ private static final String ORDER_ATTRIBUTE = "order";
+ private static final String CART_ATTRIBUTE = "cart";
+
+
+ private final GameService gameService;
+ private final SessionCart cart;
+
+ public UserCatalogController(GameService gameService, SessionCart cart){
+ this.gameService = gameService;
+ this.cart = cart;
+ }
+
+ private GameDto toGameDto(GameEntity entity) {
+ var dto = new GameDto();
+ dto.setId(entity.getId());
+ dto.setGenres(entity.getGenres().stream().map(GenreEntity::getId).toList());
+ dto.setDescription(entity.getDescription());
+ dto.setName(entity.getName());
+ dto.setPrice(entity.getPrice());
+ dto.setTypeId(entity.getType().getId());
+ return dto;
+ }
+
+ @GetMapping
+ public String getCatalog(
+ @RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
+ Model model) {
+ model.addAttribute(ORDER_ATTRIBUTE, new UserCartDto());
+ model.addAttribute(PAGE_ATTRIBUTE, page);
+ model.addAttribute("games",
+ gameService.getAll(0, 0).stream()
+ .map(this::toGameDto)
+ .toList());
+ return CATALOG_VIEW;
+ }
+ ///catalog/addCart/{id}
+
+ @PostMapping
+ public String addOrderToCart(
+ @ModelAttribute(name = ORDER_ATTRIBUTE) @Valid UserCartDto order,
+ BindingResult bindingResult,
+ SessionStatus status,
+ Model model) {
+ if (bindingResult.hasErrors()) {
+ return CATALOG_VIEW;
+ }
+ status.setComplete();
+ order.setGameName(gameService.get(order.getGame()).getName());
+ order.setPrice(gameService.get(order.getGame()).getPrice());
+ cart.computeIfPresent(order.hashCode(), (key, value) -> {
+ return value;
+ });
+ cart.put(order.hashCode(), order);
+ return Constants.REDIRECT_VIEW + URL;
+ }
+}
diff --git a/src/main/resources/public/css/style.css b/src/main/resources/public/css/style.css
index 7c99b70..083be6c 100644
--- a/src/main/resources/public/css/style.css
+++ b/src/main/resources/public/css/style.css
@@ -40,10 +40,12 @@ td form {
.my-navbar {
background-color: #08D9D6 !important;
+ color: rgb(30, 29, 29);
}
.my-navbar .link a:hover {
text-decoration: underline;
+ color: rgb(30, 29, 29);
}
.my-navbar .logo {
diff --git a/src/main/resources/public/risk-of-rain-returns.jpg b/src/main/resources/public/risk-of-rain-returns.jpg
new file mode 100644
index 0000000..b8f0282
Binary files /dev/null and b/src/main/resources/public/risk-of-rain-returns.jpg differ
diff --git a/src/main/resources/templates/catalog.html b/src/main/resources/templates/catalog.html
index e69de29..39afe31 100644
--- a/src/main/resources/templates/catalog.html
+++ b/src/main/resources/templates/catalog.html
@@ -0,0 +1,53 @@
+
+
+
+
+ Каталог
+
+
+
+
+
+
Игры
+
+
+

+
+
+
Популярные новинки:
+
+
+
+
+
+
+
+ |
+ Название |
+ Описание |
+ Цена |
+ |
+
+
+
+  |
+ |
+ |
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/templates/default.html b/src/main/resources/templates/default.html
index cfab8e5..c139671 100644
--- a/src/main/resources/templates/default.html
+++ b/src/main/resources/templates/default.html
@@ -47,6 +47,13 @@
Консоль H2
+
+ Каталог
+
+
+ Заказы
+