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/
### IntelliJ IDEA ###
*.png
*.jpeg
*.webp
.idea
*.iws
*.iml

View File

@ -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;
}
}

View File

@ -16,8 +16,8 @@
<tr v-for="prdct in products" :key="prdct.id">
<td>{{ prdct.name }}</td>
<td>{{ prdct.price }}</td>
<td>{{ prdct.photo }}</td>
<td>{{ prdct.category_id }}</td>
<td> <img :src = "prdct.photo"></td>
<td>{{ prdct && categories.find(ctgr => ctgr.id === prdct.categoryId).name }}</td>
<td>
<td>
<button class="btn btn-primary mr-2" @click="openModal('edit', prdct)">Изменить</button>
@ -53,7 +53,7 @@
</div>
<div class="form-group">
<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">
{{ category.name }}
</option>
@ -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)

View File

@ -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;

View File

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