Пятая лабораторная работа. Готово.
This commit is contained in:
parent
20af7ec707
commit
f4e33caffe
@ -1,6 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'org.springframework.boot' version '3.0.2'
|
id 'org.springframework.boot' version '3.0.1'
|
||||||
id 'io.spring.dependency-management' version '1.1.0'
|
id 'io.spring.dependency-management' version '1.1.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
@ -46,14 +46,14 @@ public class ProductController {
|
|||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public ProductDTO createProduct(@RequestBody @Valid ProductDTO productDTO){
|
public ProductDTO createProduct(@RequestBody @Valid ProductDTO productDTO){
|
||||||
final Product product = productService.addProduct(productDTO.getName());
|
final Product product = productService.addProduct(productDTO.getproductName());
|
||||||
return new ProductDTO(product);
|
return new ProductDTO(product);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
public ProductDTO updateProduct(@RequestBody @Valid ProductDTO productDTO,
|
public ProductDTO updateProduct(@RequestBody @Valid ProductDTO productDTO,
|
||||||
@PathVariable Long id){
|
@PathVariable Long id){
|
||||||
return new ProductDTO(productService.updateProduct(id, productDTO.getName()));
|
return new ProductDTO(productService.updateProduct(id, productDTO.getproductName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
|
@ -3,9 +3,7 @@ package com.example.ipLab.StoreDataBase.Controllers;
|
|||||||
import com.example.ipLab.StoreDataBase.DTO.CustomerDTO;
|
import com.example.ipLab.StoreDataBase.DTO.CustomerDTO;
|
||||||
import com.example.ipLab.StoreDataBase.DTO.ProductDTO;
|
import com.example.ipLab.StoreDataBase.DTO.ProductDTO;
|
||||||
import com.example.ipLab.StoreDataBase.DTO.StoreDTO;
|
import com.example.ipLab.StoreDataBase.DTO.StoreDTO;
|
||||||
import com.example.ipLab.StoreDataBase.Model.Customer;
|
|
||||||
import com.example.ipLab.StoreDataBase.Model.Store;
|
import com.example.ipLab.StoreDataBase.Model.Store;
|
||||||
import com.example.ipLab.StoreDataBase.Service.CustomerService;
|
|
||||||
import com.example.ipLab.StoreDataBase.Service.StoreService;
|
import com.example.ipLab.StoreDataBase.Service.StoreService;
|
||||||
import com.example.ipLab.WebConfiguration;
|
import com.example.ipLab.WebConfiguration;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
@ -36,14 +34,14 @@ public class StoreController {
|
|||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public StoreDTO createStore(@RequestBody @Valid StoreDTO storeDTO){
|
public StoreDTO createStore(@RequestBody @Valid StoreDTO storeDTO){
|
||||||
final Store store = storeService.addStore(storeDTO.getStoreName());
|
final Store store = storeService.addStore(storeDTO.getstoreName());
|
||||||
return new StoreDTO(store);
|
return new StoreDTO(store);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
public StoreDTO updateStore(@RequestBody @Valid StoreDTO storeDTO,
|
public StoreDTO updateStore(@RequestBody @Valid StoreDTO storeDTO,
|
||||||
@PathVariable Long id){
|
@PathVariable Long id){
|
||||||
return new StoreDTO(storeService.updateStore(id, storeDTO.getStoreName()));
|
return new StoreDTO(storeService.updateStore(id, storeDTO.getstoreName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("{id}/add")
|
@PutMapping("{id}/add")
|
||||||
|
@ -11,6 +11,7 @@ public class CustomerDTO {
|
|||||||
public String firstName;
|
public String firstName;
|
||||||
@NotBlank(message = "middleName can't be null or empty")
|
@NotBlank(message = "middleName can't be null or empty")
|
||||||
public String middleName;
|
public String middleName;
|
||||||
|
public String customerFIO;
|
||||||
|
|
||||||
public CustomerDTO(){
|
public CustomerDTO(){
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ public class CustomerDTO {
|
|||||||
this.lastName = customer.getLastName();
|
this.lastName = customer.getLastName();
|
||||||
this.firstName = customer.getFirstName();
|
this.firstName = customer.getFirstName();
|
||||||
this.middleName = customer.getMiddleName();
|
this.middleName = customer.getMiddleName();
|
||||||
|
this.customerFIO = lastName + " " + firstName + " " + middleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
@ -47,4 +49,12 @@ public class CustomerDTO {
|
|||||||
public void setmiddleName(String middleName) {
|
public void setmiddleName(String middleName) {
|
||||||
this.middleName = middleName;
|
this.middleName = middleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getcustomerFIO() {
|
||||||
|
return customerFIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setcustomerFIO(String customerFIO) {
|
||||||
|
this.customerFIO = customerFIO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.example.ipLab.StoreDataBase.DTO;
|
package com.example.ipLab.StoreDataBase.DTO;
|
||||||
|
|
||||||
|
import com.example.ipLab.StoreDataBase.Model.Customer;
|
||||||
import com.example.ipLab.StoreDataBase.Model.Ordered;
|
import com.example.ipLab.StoreDataBase.Model.Ordered;
|
||||||
|
import com.example.ipLab.StoreDataBase.Model.Product;
|
||||||
|
|
||||||
public class OrderedDTO {
|
public class OrderedDTO {
|
||||||
public Long id;
|
public Long id;
|
||||||
@ -33,18 +35,30 @@ public class OrderedDTO {
|
|||||||
return quantity;
|
return quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProductName() {
|
public String getproductName() {
|
||||||
return productName;
|
return productName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCustomerFIO() {
|
public void setproductName(String productName) {
|
||||||
|
this.productName = productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getcustomerFIO() {
|
||||||
return customerFIO;
|
return customerFIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStoreName() {
|
public void setcustomerFIO(String customerFIO) {
|
||||||
|
this.customerFIO = customerFIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getstoreName() {
|
||||||
return storeName;
|
return storeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setstoreName(String storeName) {
|
||||||
|
this.storeName = storeName;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getCustomerId() {
|
public Long getCustomerId() {
|
||||||
return customerId;
|
return customerId;
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@ package com.example.ipLab.StoreDataBase.DTO;
|
|||||||
|
|
||||||
import com.example.ipLab.StoreDataBase.Model.Product;
|
import com.example.ipLab.StoreDataBase.Model.Product;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ProductDTO {
|
public class ProductDTO {
|
||||||
public Long id;
|
public Long id;
|
||||||
public String productName;
|
public String productName;
|
||||||
@ -22,10 +20,14 @@ public class ProductDTO {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getproductName() {
|
||||||
return productName;
|
return productName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setproductName(String productName) {
|
||||||
|
this.productName = productName;
|
||||||
|
}
|
||||||
|
|
||||||
public String getStoreName() {
|
public String getStoreName() {
|
||||||
return storeName;
|
return storeName;
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,14 @@ public class StoreDTO {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStoreName() {
|
public String getstoreName() {
|
||||||
return storeName;
|
return storeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setstoreName(String storeName) {
|
||||||
|
this.storeName = storeName;
|
||||||
|
}
|
||||||
|
|
||||||
public List<ProductDTO> getProducts() {
|
public List<ProductDTO> getProducts() {
|
||||||
return products;
|
return products;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,65 @@
|
|||||||
|
package com.example.ipLab.StoreDataBase.MVC;
|
||||||
|
|
||||||
|
import com.example.ipLab.StoreDataBase.DTO.CustomerDTO;
|
||||||
|
import com.example.ipLab.StoreDataBase.DTO.OrderedDTO;
|
||||||
|
import com.example.ipLab.StoreDataBase.DTO.ProductDTO;
|
||||||
|
import com.example.ipLab.StoreDataBase.Service.CustomerService;
|
||||||
|
import com.example.ipLab.StoreDataBase.Service.OrderService;
|
||||||
|
import com.example.ipLab.StoreDataBase.Service.ProductService;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/order")
|
||||||
|
public class OrderedMVCController {
|
||||||
|
private final OrderService orderedService;
|
||||||
|
private final ProductService productService;
|
||||||
|
private final CustomerService customerService;
|
||||||
|
|
||||||
|
public OrderedMVCController(OrderService orderedService, ProductService productService, CustomerService customerService){
|
||||||
|
this.productService = productService;
|
||||||
|
this.customerService = customerService;
|
||||||
|
this.orderedService = orderedService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public String getOrdereds(Model model) {
|
||||||
|
model.addAttribute("orders",
|
||||||
|
orderedService.getAllOrders().stream()
|
||||||
|
.map(OrderedDTO::new)
|
||||||
|
.toList());
|
||||||
|
return "order";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = {"/edit/", "/edit/{id}"})
|
||||||
|
public String editOrdered(@PathVariable(required = false) Long id,
|
||||||
|
Model model) {
|
||||||
|
model.addAttribute("orderDTO", new OrderedDTO());
|
||||||
|
model.addAttribute("customers", customerService.getAllCustomers().stream().map(CustomerDTO::new).toList());
|
||||||
|
model.addAttribute("products", productService.getAllProductsWithStores().stream().map(ProductDTO::new).toList());
|
||||||
|
return "order-edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = {"/", "/{id}"})
|
||||||
|
public String saveOrdered(@RequestParam(value = "productId") Long productId,
|
||||||
|
@RequestParam(value = "customerId") Long customerId,
|
||||||
|
@ModelAttribute @Valid OrderedDTO orderedDto,
|
||||||
|
BindingResult bindingResult,
|
||||||
|
Model model) {
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
model.addAttribute("errors", bindingResult.getAllErrors());
|
||||||
|
return "ordered-edit";
|
||||||
|
}
|
||||||
|
orderedService.addOrder(productService.getProduct(productId), customerService.getCustomer(customerId), orderedDto.getQuantity());
|
||||||
|
return "redirect:/order";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/delete/{id}")
|
||||||
|
public String deleteOrdered(@PathVariable Long id) {
|
||||||
|
orderedService.deleteOrder(id);
|
||||||
|
return "redirect:/order";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package com.example.ipLab.StoreDataBase.MVC;
|
||||||
|
|
||||||
|
import com.example.ipLab.StoreDataBase.DTO.ProductDTO;
|
||||||
|
import com.example.ipLab.StoreDataBase.Service.ProductService;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/product")
|
||||||
|
public class ProductMVCController {
|
||||||
|
private final ProductService productService;
|
||||||
|
|
||||||
|
public ProductMVCController(ProductService productService) {
|
||||||
|
this.productService = productService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public String getProducts(Model model) {
|
||||||
|
model.addAttribute("products",
|
||||||
|
productService.getAllProducts().stream()
|
||||||
|
.map(ProductDTO::new)
|
||||||
|
.toList());
|
||||||
|
return "product";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = {"/edit/", "/edit/{id}"})
|
||||||
|
public String editProduct(@PathVariable(required = false) Long id,
|
||||||
|
Model model) {
|
||||||
|
if (id == null || id <= 0) {
|
||||||
|
model.addAttribute("productDTO", new ProductDTO());
|
||||||
|
} else {
|
||||||
|
model.addAttribute("productId", id);
|
||||||
|
model.addAttribute("productDTO", new ProductDTO(productService.getProduct(id)));
|
||||||
|
}
|
||||||
|
return "product-edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = {"/", "/{id}"})
|
||||||
|
public String saveProduct(@PathVariable(required = false) Long id,
|
||||||
|
@ModelAttribute @Valid ProductDTO productDto,
|
||||||
|
BindingResult bindingResult,
|
||||||
|
Model model) {
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
model.addAttribute("errors", bindingResult.getAllErrors());
|
||||||
|
return "product-edit";
|
||||||
|
}
|
||||||
|
if (id == null || id <= 0) {
|
||||||
|
productService.addProduct(productDto.getproductName());
|
||||||
|
} else {
|
||||||
|
productService.updateProduct(id, productDto.getproductName());
|
||||||
|
}
|
||||||
|
return "redirect:/product";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/delete/{id}")
|
||||||
|
public String deleteProduct(@PathVariable Long id) {
|
||||||
|
productService.deleteProduct(id);
|
||||||
|
return "redirect:/product";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,84 @@
|
|||||||
|
package com.example.ipLab.StoreDataBase.MVC;
|
||||||
|
|
||||||
|
import com.example.ipLab.StoreDataBase.DTO.CustomerDTO;
|
||||||
|
import com.example.ipLab.StoreDataBase.DTO.ProductDTO;
|
||||||
|
import com.example.ipLab.StoreDataBase.DTO.StoreDTO;
|
||||||
|
import com.example.ipLab.StoreDataBase.Service.ProductService;
|
||||||
|
import com.example.ipLab.StoreDataBase.Service.StoreService;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/store")
|
||||||
|
public class StoreMVCController {
|
||||||
|
private final StoreService storeService;
|
||||||
|
private final ProductService productService;
|
||||||
|
|
||||||
|
public StoreMVCController(StoreService storeService, ProductService productService) {
|
||||||
|
this.storeService = storeService;
|
||||||
|
this.productService = productService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public String getStores(Model model) {
|
||||||
|
model.addAttribute("stores",
|
||||||
|
storeService.getAllStores().stream()
|
||||||
|
.map(StoreDTO::new)
|
||||||
|
.toList());
|
||||||
|
return "store";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = {"/edit/", "/edit/{id}"})
|
||||||
|
public String editStore(@PathVariable(required = false) Long id,
|
||||||
|
Model model) {
|
||||||
|
if (id == null || id <= 0) {
|
||||||
|
model.addAttribute("storeDTO", new StoreDTO());
|
||||||
|
} else {
|
||||||
|
model.addAttribute("storeId", id);
|
||||||
|
model.addAttribute("storeDTO", new StoreDTO(storeService.getStore(id)));
|
||||||
|
}
|
||||||
|
return "store-edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/addToStore")
|
||||||
|
public String addToStore(@PathVariable(required = false) Long id,
|
||||||
|
Model model) {
|
||||||
|
model.addAttribute("stores", storeService.getAllStores().stream().map(StoreDTO::new).toList());
|
||||||
|
model.addAttribute("products", productService.getAllProductsWithoutStores().stream().map(ProductDTO::new).toList());
|
||||||
|
return "addToStore";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = {"/", "/{id}"})
|
||||||
|
public String saveStore(@PathVariable(required = false) Long id,
|
||||||
|
@ModelAttribute @Valid StoreDTO storeDto,
|
||||||
|
BindingResult bindingResult,
|
||||||
|
Model model) {
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
model.addAttribute("errors", bindingResult.getAllErrors());
|
||||||
|
return "store-edit";
|
||||||
|
}
|
||||||
|
if (id == null || id <= 0) {
|
||||||
|
storeService.addStore(storeDto.getstoreName());
|
||||||
|
} else {
|
||||||
|
storeService.updateStore(id, storeDto.getstoreName());
|
||||||
|
}
|
||||||
|
return "redirect:/store";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/add")
|
||||||
|
public String addProduct(@RequestParam(value = "storeId") Long storeId,
|
||||||
|
@RequestParam(value = "productId") Long productId
|
||||||
|
){
|
||||||
|
storeService.addProduct(storeId, productId);
|
||||||
|
return "redirect:/product";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/delete/{id}")
|
||||||
|
public String deleteStore(@PathVariable Long id) {
|
||||||
|
storeService.deleteStore(id);
|
||||||
|
return "redirect:/store";
|
||||||
|
}
|
||||||
|
}
|
BIN
backend/ipLab/src/main/resources/public/logo.png
Normal file
BIN
backend/ipLab/src/main/resources/public/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.7 KiB |
35
backend/ipLab/src/main/resources/templates/addToStore.html
Normal file
35
backend/ipLab/src/main/resources/templates/addToStore.html
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorate="~{default}">
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div layout:fragment="content">
|
||||||
|
<div th:text="${errors}" class="margin-bottom alert-danger"></div>
|
||||||
|
<form action="#" th:action="@{/store/add}" method="post">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="store" class="form-label">Покупатель</label>
|
||||||
|
<select id="store" class="form-select" th:name="storeId">
|
||||||
|
<option th:each="value: ${stores}" th:value="${value.id}" th:selected="${storeId} == ${value}">
|
||||||
|
<span th:text="${value.storeName}"></span>
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="product" class="form-label">Продукт</label>
|
||||||
|
<select id="product" class="form-select" th:name="productId">
|
||||||
|
<option th:each="value: ${products}" th:value="${value.id}" th:selected="${productId} == ${value}">
|
||||||
|
<span th:text="${value.productName}"></span>
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<button type="submit" class="btn btn-primary button-fixed">
|
||||||
|
<span>Добавить</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -21,10 +21,16 @@
|
|||||||
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
</button>
|
</button>
|
||||||
|
<div class="d-flex flex-row ml-3 ms-3 mt-auto mb-auto align-items-center">
|
||||||
|
<a>
|
||||||
|
<img src="/logo.png" alt="*" width="60" height="60" class="align-text-top"></img>
|
||||||
|
</a>
|
||||||
|
<div id="logoName">
|
||||||
|
<a href="/">boxStore</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="navbar-collapse collapse justify-content-end" id="navbarNav">
|
<div class="navbar-collapse collapse justify-content-end" id="navbarNav">
|
||||||
<ul class="navbar-nav" id="headerNavigation">
|
<ul class="navbar-nav" id="headerNavigation">
|
||||||
<a class="nav-link headNav" href="/"
|
|
||||||
th:classappend="${#strings.equals(activeLink, '/')} ? 'active' : ''">Главная</a>
|
|
||||||
<a class="nav-link headNav" href="/customer"
|
<a class="nav-link headNav" href="/customer"
|
||||||
th:classappend="${#strings.equals(activeLink, '/customer')} ? 'active' : ''">Клиенты</a>
|
th:classappend="${#strings.equals(activeLink, '/customer')} ? 'active' : ''">Клиенты</a>
|
||||||
<a class="nav-link headNav" href="/store"
|
<a class="nav-link headNav" href="/store"
|
||||||
@ -33,6 +39,8 @@
|
|||||||
th:classappend="${#strings.equals(activeLink, '/product')} ? 'active' : ''">Товары</a>
|
th:classappend="${#strings.equals(activeLink, '/product')} ? 'active' : ''">Товары</a>
|
||||||
<a class="nav-link headNav" href="/order"
|
<a class="nav-link headNav" href="/order"
|
||||||
th:classappend="${#strings.equals(activeLink, '/order')} ? 'active' : ''">Заказы</a>
|
th:classappend="${#strings.equals(activeLink, '/order')} ? 'active' : ''">Заказы</a>
|
||||||
|
<a class="nav-link headNav" href="/store/addToStore"
|
||||||
|
th:classappend="${#strings.equals(activeLink, '/order')} ? 'active' : ''">Доставка</a>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
42
backend/ipLab/src/main/resources/templates/order-edit.html
Normal file
42
backend/ipLab/src/main/resources/templates/order-edit.html
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorate="~{default}">
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div layout:fragment="content">
|
||||||
|
<div th:text="${errors}" class="margin-bottom alert-danger"></div>
|
||||||
|
<form action="#" th:action="@{/order/}" th:object="${orderDTO}" method="post">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="customer" class="form-label">Покупатель</label>
|
||||||
|
<select id="customer" class="form-select" th:name="customerId">
|
||||||
|
<option th:each="value: ${customers}" th:value="${value.id}" th:selected="${customerId} == ${value}">
|
||||||
|
<span th:text="${value.customerFIO}"></span>
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="product" class="form-label">Продукт</label>
|
||||||
|
<select id="product" class="form-select" th:name="productId">
|
||||||
|
<option th:each="value: ${products}" th:value="${value.id}" th:selected="${productId} == ${value}">
|
||||||
|
<span th:text="${value.productName}"></span>
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="quantity" class="form-label">Количество</label>
|
||||||
|
<input type="text" class="form-control" id="quantity" th:field="${orderDTO.quantity}" required="true">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<button type="submit" class="btn btn-primary button-fixed">
|
||||||
|
<span>Добавить</span>
|
||||||
|
</button>
|
||||||
|
<a class="btn btn-secondary button-fixed" th:href="@{/order}">
|
||||||
|
Назад
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
37
backend/ipLab/src/main/resources/templates/order.html
Normal file
37
backend/ipLab/src/main/resources/templates/order.html
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorate="~{default}">
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div layout:fragment="content">
|
||||||
|
<div>
|
||||||
|
<a class="btn btn-success button-fixed"
|
||||||
|
th:href="@{/order/edit/}">
|
||||||
|
<i class="fa-solid fa-plus"></i> Добавить
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-success table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">#</th>
|
||||||
|
<th scope="col">ФИО покупателя</th>
|
||||||
|
<th scope="col">Магазин</th>
|
||||||
|
<th scope="col">Товар</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr th:each="order, iterator: ${orders}">
|
||||||
|
<th scope="row" th:text="${iterator.index} + 1"/>
|
||||||
|
<td th:text="${order.customerFIO}"/>
|
||||||
|
<td th:text="${order.storeName}"/>
|
||||||
|
<td th:text="${order.productName}"/>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
27
backend/ipLab/src/main/resources/templates/product-edit.html
Normal file
27
backend/ipLab/src/main/resources/templates/product-edit.html
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorate="~{default}">
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div layout:fragment="content">
|
||||||
|
<div th:text="${errors}" class="margin-bottom alert-danger"></div>
|
||||||
|
<form action="#" th:action="@{/product/{id}(id=${id})}" th:object="${productDTO}" method="post">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="productName" class="form-label">Название товара</label>
|
||||||
|
<input type="text" class="form-control" id="productName" th:field="${productDTO.productName}" required="true">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<button type="submit" class="btn btn-primary button-fixed">
|
||||||
|
<span th:if="${id == null}">Добавить</span>
|
||||||
|
<span th:if="${id != null}">Обновить</span>
|
||||||
|
</button>
|
||||||
|
<a class="btn btn-secondary button-fixed" th:href="@{/product}">
|
||||||
|
Назад
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
53
backend/ipLab/src/main/resources/templates/product.html
Normal file
53
backend/ipLab/src/main/resources/templates/product.html
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorate="~{default}">
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div layout:fragment="content">
|
||||||
|
<div>
|
||||||
|
<a class="btn btn-success button-fixed "
|
||||||
|
th:href="@{/product/edit/}">
|
||||||
|
<i class="fa-solid fa-plus"></i> Добавить
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-success table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">#</th>
|
||||||
|
<th scope="col">Название товара</th>
|
||||||
|
<th scope="col">Название магазина</th>
|
||||||
|
<th scope="col"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr th:each="product, iterator: ${products}">
|
||||||
|
<th scope="row" th:text="${iterator.index} + 1"/>
|
||||||
|
<td th:text="${product.productName}"/>
|
||||||
|
<td th:text="${product.storeName}"/>
|
||||||
|
<td style="width: 10%">
|
||||||
|
<div class="btn-group" role="group" aria-label="Basic example">
|
||||||
|
<a class="btn btn-warning button-fixed button-sm"
|
||||||
|
th:href="@{/product/edit/{id}(id=${product.id})}">
|
||||||
|
<i class="fa fa-pencil" aria-hidden="true"></i> Изменить
|
||||||
|
</a>
|
||||||
|
<button type="button" class="btn btn-danger button-fixed button-sm"
|
||||||
|
th:attr="onclick=|confirm('Удалить запись?') && document.getElementById('remove-${product.id}').click()|">
|
||||||
|
<i class="fa fa-trash" aria-hidden="true"></i> Удалить
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<form th:action="@{/product/delete/{id}(id=${product.id})}" method="post">
|
||||||
|
<button th:id="'remove-' + ${product.id}" type="submit" style="display: none">
|
||||||
|
Удалить
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
27
backend/ipLab/src/main/resources/templates/store-edit.html
Normal file
27
backend/ipLab/src/main/resources/templates/store-edit.html
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorate="~{default}">
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div layout:fragment="content">
|
||||||
|
<div th:text="${errors}" class="margin-bottom alert-danger"></div>
|
||||||
|
<form action="#" th:action="@{/store/{id}(id=${id})}" th:object="${storeDTO}" method="post">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="storeName" class="form-label">Название магазина</label>
|
||||||
|
<input type="text" class="form-control" id="storeName" th:field="${storeDTO.storeName}" required="true">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<button type="submit" class="btn btn-primary button-fixed">
|
||||||
|
<span th:if="${id == null}">Добавить</span>
|
||||||
|
<span th:if="${id != null}">Обновить</span>
|
||||||
|
</button>
|
||||||
|
<a class="btn btn-secondary button-fixed" th:href="@{/store}">
|
||||||
|
Назад
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
51
backend/ipLab/src/main/resources/templates/store.html
Normal file
51
backend/ipLab/src/main/resources/templates/store.html
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorate="~{default}">
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div layout:fragment="content">
|
||||||
|
<div>
|
||||||
|
<a class="btn btn-success button-fixed"
|
||||||
|
th:href="@{/store/edit/}">
|
||||||
|
<i class="fa-solid fa-plus"></i> Добавить
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-success table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">#</th>
|
||||||
|
<th scope="col">Название магазина</th>
|
||||||
|
<th scope="col"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr th:each="store, iterator: ${stores}">
|
||||||
|
<th scope="row" th:text="${iterator.index} + 1"/>
|
||||||
|
<td th:text="${store.storeName}"/>
|
||||||
|
<td style="width: 10%">
|
||||||
|
<div class="btn-group" role="group" aria-label="Basic example">
|
||||||
|
<a class="btn btn-warning button-fixed button-sm"
|
||||||
|
th:href="@{/store/edit/{id}(id=${store.id})}">
|
||||||
|
<i class="fa fa-pencil" aria-hidden="true"></i> Изменить
|
||||||
|
</a>
|
||||||
|
<button type="button" class="btn btn-danger button-fixed button-sm"
|
||||||
|
th:attr="onclick=|confirm('Удалить запись?') && document.getElementById('remove-${store.id}').click()|">
|
||||||
|
<i class="fa fa-trash" aria-hidden="true"></i> Удалить
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<form th:action="@{/store/delete/{id}(id=${store.id})}" method="post">
|
||||||
|
<button th:id="'remove-' + ${store.id}" type="submit" style="display: none">
|
||||||
|
Удалить
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -17,6 +17,7 @@ export default class DataService {
|
|||||||
|
|
||||||
static async readAll(url, transformer) {
|
static async readAll(url, transformer) {
|
||||||
const response = await axios.get(this.dataUrlPrefix + url);
|
const response = await axios.get(this.dataUrlPrefix + url);
|
||||||
|
console.log(response);
|
||||||
return response.data.map(item => transformer(item));
|
return response.data.map(item => transformer(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user