LabWork04 34

This commit is contained in:
Артём Алейкин 2023-05-13 00:25:15 +04:00
parent 5d16b4a2cd
commit 6699eda085
5 changed files with 11 additions and 7 deletions

3
.gitignore vendored
View File

@ -18,6 +18,9 @@ bin/
!**/src/test/**/bin/ !**/src/test/**/bin/
### IntelliJ IDEA ### ### IntelliJ IDEA ###
*.png
*.jpeg
*.webp
.idea .idea
*.iws *.iws
*.iml *.iml

View File

@ -4,6 +4,6 @@ export default class Product{
this.name = data?.name; this.name = data?.name;
this.price = data?.price; this.price = data?.price;
this.photo = data?.photo; this.photo = data?.photo;
this.category_id = data?.category_id; this.categoryId = data?.categoryId;
} }
} }

View File

@ -16,8 +16,8 @@
<tr v-for="prdct in products" :key="prdct.id"> <tr v-for="prdct in products" :key="prdct.id">
<td>{{ prdct.name }}</td> <td>{{ prdct.name }}</td>
<td>{{ prdct.price }}</td> <td>{{ prdct.price }}</td>
<td>{{ prdct.photo }}</td> <td> <img :src = "prdct.photo"></td>
<td>{{ prdct.category_id }}</td> <td>{{ prdct && categories.find(ctgr => ctgr.id === prdct.categoryId).name }}</td>
<td> <td>
<td> <td>
<button class="btn btn-primary mr-2" @click="openModal('edit', prdct)">Изменить</button> <button class="btn btn-primary mr-2" @click="openModal('edit', prdct)">Изменить</button>
@ -53,7 +53,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="category">Категория:</label> <label for="category">Категория:</label>
<select v-model="product.category_id" class="form-control"> <select v-model="product.categoryId" class="form-control">
<option v-for="(category, index) in categories" :key="index" :value="category.id"> <option v-for="(category, index) in categories" :key="index" :value="category.id">
{{ category.name }} {{ category.name }}
</option> </option>
@ -77,6 +77,7 @@ import Product from "../models/Product";
export default { export default {
created() { created() {
this.getProducts(); this.getProducts();
this.getCategories();
}, },
mounted() { mounted() {
const addModal = document.getElementById('editModal'); const addModal = document.getElementById('editModal');
@ -114,7 +115,8 @@ export default {
console.log(error); console.log(error);
}); });
}, },
addProduct(){ async addProduct(){
await this.toBase64();
this.product.price = parseInt(this.product.price); this.product.price = parseInt(this.product.price);
console.log(this.product); console.log(this.product);
axios.post(this.URL + "product", this.product) axios.post(this.URL + "product", this.product)

View File

@ -1,6 +1,5 @@
package ru.ulstu.is.sbapp.HardwareShop.controller; 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.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;

View File

@ -10,9 +10,9 @@ public class ProductDTO {
private Integer price; private Integer price;
private String photo; private String photo;
@JsonProperty("categoryId")
private Long category_id; private Long category_id;
private String name; private String name;