From 6699eda08536f71c2cc8b31117ce19ba111259fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=90=D0=BB=D0=B5=D0=B9?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Sat, 13 May 2023 00:25:15 +0400 Subject: [PATCH] LabWork04 34 --- .gitignore | 3 +++ frontend/spa-vue/src/models/Product.js | 2 +- frontend/spa-vue/src/pages/products.vue | 10 ++++++---- .../HardwareShop/controller/ProductController.java | 1 - .../is/sbapp/HardwareShop/controller/ProductDTO.java | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index b515354..8731139 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,9 @@ bin/ !**/src/test/**/bin/ ### IntelliJ IDEA ### +*.png +*.jpeg +*.webp .idea *.iws *.iml diff --git a/frontend/spa-vue/src/models/Product.js b/frontend/spa-vue/src/models/Product.js index 9a65fa9..2e825e4 100644 --- a/frontend/spa-vue/src/models/Product.js +++ b/frontend/spa-vue/src/models/Product.js @@ -4,6 +4,6 @@ export default class Product{ this.name = data?.name; this.price = data?.price; this.photo = data?.photo; - this.category_id = data?.category_id; + this.categoryId = data?.categoryId; } } \ No newline at end of file diff --git a/frontend/spa-vue/src/pages/products.vue b/frontend/spa-vue/src/pages/products.vue index 02a8ee5..f5a5a95 100644 --- a/frontend/spa-vue/src/pages/products.vue +++ b/frontend/spa-vue/src/pages/products.vue @@ -16,8 +16,8 @@ {{ prdct.name }} {{ prdct.price }} - {{ prdct.photo }} - {{ prdct.category_id }} + + {{ prdct && categories.find(ctgr => ctgr.id === prdct.categoryId).name }} @@ -53,7 +53,7 @@
- @@ -77,6 +77,7 @@ import Product from "../models/Product"; export default { created() { this.getProducts(); + this.getCategories(); }, mounted() { const addModal = document.getElementById('editModal'); @@ -114,7 +115,8 @@ export default { console.log(error); }); }, - addProduct(){ + async addProduct(){ + await this.toBase64(); this.product.price = parseInt(this.product.price); console.log(this.product); axios.post(this.URL + "product", this.product) diff --git a/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ProductController.java b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ProductController.java index 3dd524d..39781ab 100644 --- a/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ProductController.java +++ b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ProductController.java @@ -1,6 +1,5 @@ package ru.ulstu.is.sbapp.HardwareShop.controller; -import io.swagger.v3.oas.annotations.parameters.RequestBody; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; diff --git a/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ProductDTO.java b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ProductDTO.java index 08ea9a7..0c494d1 100644 --- a/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ProductDTO.java +++ b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ProductDTO.java @@ -10,9 +10,9 @@ public class ProductDTO { private Integer price; - private String photo; + @JsonProperty("categoryId") private Long category_id; private String name;