From 743f35ffef2f8459a6217be7c21d29e278b81fe5 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: Sun, 14 May 2023 23:44:06 +0400 Subject: [PATCH] LabWork05 35 --- build.gradle | 7 +- frontend/spa-vue/src/pages/categories.vue | 22 ---- frontend/spa-vue/src/pages/products.vue | 92 +++++++++++++++- .../controller/CategoryController.java | 3 +- .../HardwareShop/controller/CategoryDTO.java | 4 + .../controller/CategoryMvcController.java | 65 +++++++++++ .../controller/ManufacturerController.java | 3 +- .../controller/ManufacturerDTO.java | 6 + .../controller/ManufacturerMvcController.java | 64 +++++++++++ .../controller/ProductController.java | 19 +++- .../HardwareShop/controller/ProductDTO.java | 9 ++ .../controller/ProductMvcController.java | 104 ++++++++++++++++++ .../is/sbapp/HardwareShop/models/Product.java | 2 +- .../HardwareShop/services/ProductService.java | 9 +- .../sbapp/Util/Errors/AdviceController.java | 3 +- .../ru/ulstu/is/sbapp/WebConfiguration.java | 8 ++ src/main/resources/templates/categories.html | 49 +++++++++ .../resources/templates/category-update.html | 31 ++++++ src/main/resources/templates/default.html | 48 ++++++++ src/main/resources/templates/error.html | 10 ++ .../templates/manufacturer-update.html | 31 ++++++ .../resources/templates/manufacturers.html | 51 +++++++++ src/main/resources/templates/product-mtm.html | 50 +++++++++ .../resources/templates/product-update.html | 44 ++++++++ src/main/resources/templates/products.html | 59 ++++++++++ 25 files changed, 755 insertions(+), 38 deletions(-) create mode 100644 src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/CategoryMvcController.java create mode 100644 src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ManufacturerMvcController.java create mode 100644 src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ProductMvcController.java create mode 100644 src/main/resources/templates/categories.html create mode 100644 src/main/resources/templates/category-update.html create mode 100644 src/main/resources/templates/default.html create mode 100644 src/main/resources/templates/error.html create mode 100644 src/main/resources/templates/manufacturer-update.html create mode 100644 src/main/resources/templates/manufacturers.html create mode 100644 src/main/resources/templates/product-mtm.html create mode 100644 src/main/resources/templates/product-update.html create mode 100644 src/main/resources/templates/products.html diff --git a/build.gradle b/build.gradle index f92defc..59873d2 100644 --- a/build.gradle +++ b/build.gradle @@ -13,11 +13,14 @@ repositories { } dependencies { - // https://mvnrepository.com/artifact/commons-io/commons-io - implementation group: 'commons-io', name: 'commons-io', version: '2.6' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'com.h2database:h2:2.1.210' + implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' + implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect' + implementation 'org.webjars:bootstrap:5.1.3' + implementation 'org.webjars:jquery:3.6.0' + implementation 'org.webjars:font-awesome:6.1.0' implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.5' diff --git a/frontend/spa-vue/src/pages/categories.vue b/frontend/spa-vue/src/pages/categories.vue index a3e2c3a..4b39e5d 100644 --- a/frontend/spa-vue/src/pages/categories.vue +++ b/frontend/spa-vue/src/pages/categories.vue @@ -19,9 +19,6 @@ - - - @@ -98,9 +95,6 @@ export default { const addModal = document.getElementById('editModal'); addModal.addEventListener('shown.bs.modal', function () { }) - const ModelForProducts = document.getElementById('ModelForProducts'); - addModal.addEventListener('shown.bs.modal', function () { - }) }, data() { @@ -169,22 +163,6 @@ export default { console.log(error); }); }, - getProductsFromCategory(category_id){ - axios.get(this.URL + `group/${category_id}/products`) - .then(response => { - this.products = response.data; - console.log(response.data); - }) - .catch(error => { - console.log(error); - }); - }, - OpenModelForProducts() { - document.getElementById("ModelForProducts").style.display = "block"; - }, - closeModelForProducts() { - document.getElementById("ModelForProducts").style.display = "none"; - }, } } diff --git a/frontend/spa-vue/src/pages/products.vue b/frontend/spa-vue/src/pages/products.vue index f5a5a95..f233779 100644 --- a/frontend/spa-vue/src/pages/products.vue +++ b/frontend/spa-vue/src/pages/products.vue @@ -25,6 +25,9 @@ + + + @@ -69,6 +72,44 @@ + diff --git a/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/CategoryController.java b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/CategoryController.java index bf1f1d5..5d11f66 100644 --- a/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/CategoryController.java +++ b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/CategoryController.java @@ -3,6 +3,7 @@ package ru.ulstu.is.sbapp.HardwareShop.controller; import org.springframework.web.bind.annotation.*; import ru.ulstu.is.sbapp.HardwareShop.models.Category; import ru.ulstu.is.sbapp.HardwareShop.services.CategoryService; +import ru.ulstu.is.sbapp.WebConfiguration; import javax.validation.Valid; import javax.xml.crypto.dsig.CanonicalizationMethod; @@ -11,7 +12,7 @@ import java.io.IOException; import java.util.List; @RestController -@RequestMapping("/category") +@RequestMapping(WebConfiguration.REST_API + "/category") public class CategoryController { private final CategoryService categoryService; diff --git a/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/CategoryDTO.java b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/CategoryDTO.java index 1a0a3b9..f88528a 100644 --- a/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/CategoryDTO.java +++ b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/CategoryDTO.java @@ -24,4 +24,8 @@ public class CategoryDTO { public String getName() { return name; } + + public void setId(Long id) { this.id = id; } + + public void setName(String name) { this.name = name; } } diff --git a/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/CategoryMvcController.java b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/CategoryMvcController.java new file mode 100644 index 0000000..b5b9d3d --- /dev/null +++ b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/CategoryMvcController.java @@ -0,0 +1,65 @@ +package ru.ulstu.is.sbapp.HardwareShop.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; +import ru.ulstu.is.sbapp.HardwareShop.models.Category; +import ru.ulstu.is.sbapp.HardwareShop.services.CategoryService; + +import java.io.IOException; + +@Controller +@RequestMapping("/category") +public class CategoryMvcController { + private final CategoryService categoryService; + + public CategoryMvcController(CategoryService categoryService) { + this.categoryService = categoryService; + } + + @GetMapping + public String getCategories(Model model) { + model.addAttribute("categories", categoryService.findAllCategories() + .stream() + .map(CategoryDTO::new) + .toList()); + return "categories"; + } + + @GetMapping(value = {"/update", "/update/{id}"}) + public String updateCategory(@PathVariable(required = false) Long id, + Model model) { + if (id == null || id <= 0) { + model.addAttribute("categoryDto", new CategoryDTO()); + } else { + model.addAttribute("categoryDto", id); + model.addAttribute("categoryDto", new CategoryDTO(categoryService.findCategory(id))); + } + return "category-update"; + } + + @PostMapping(value = {"/", "/{id}"}) + public String saveCategory(@PathVariable(required = false) Long id, + @ModelAttribute("categoryDto") CategoryDTO categoryDTO, + BindingResult bindingResult, + Model model) throws IOException { + if (bindingResult.hasErrors()) { + model.addAttribute("errors", + bindingResult.getAllErrors()); + return "category-update"; + } + if (id == null || id <= 0) { + categoryService.addCategory(categoryDTO); + } else { + categoryService.updateCategory(id, categoryDTO); + } + return "redirect:/category"; + } + + @PostMapping("/delete/{id}") + public String deleteCategory(@PathVariable Long id) { + categoryService.deleteCategory(id); + return "redirect:/category"; + } +} diff --git a/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ManufacturerController.java b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ManufacturerController.java index 93c277a..b01559a 100644 --- a/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ManufacturerController.java +++ b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ManufacturerController.java @@ -4,13 +4,14 @@ package ru.ulstu.is.sbapp.HardwareShop.controller; import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.web.bind.annotation.*; import ru.ulstu.is.sbapp.HardwareShop.services.ManufacturerService; +import ru.ulstu.is.sbapp.WebConfiguration; import javax.validation.Valid; import java.io.IOException; import java.util.List; @RestController -@RequestMapping("/manufacturer") +@RequestMapping(WebConfiguration.REST_API + "/manufacturer") public class ManufacturerController { private final ManufacturerService manufacturerService; diff --git a/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ManufacturerDTO.java b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ManufacturerDTO.java index 783cac8..ea45a81 100644 --- a/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ManufacturerDTO.java +++ b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ManufacturerDTO.java @@ -30,4 +30,10 @@ public class ManufacturerDTO { public String getAddress() { return address; } + + public void setId(Long id) { this.id = id; } + + public void setName(String name) { this.name = name; } + + public void setAddress(String address) { this.address = address; } } diff --git a/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ManufacturerMvcController.java b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ManufacturerMvcController.java new file mode 100644 index 0000000..c6e09f9 --- /dev/null +++ b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ManufacturerMvcController.java @@ -0,0 +1,64 @@ +package ru.ulstu.is.sbapp.HardwareShop.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; +import ru.ulstu.is.sbapp.HardwareShop.services.ManufacturerService; + +import java.io.IOException; + +@Controller +@RequestMapping("/manufacturer") +public class ManufacturerMvcController { + private final ManufacturerService manufacturerService; + + public ManufacturerMvcController(ManufacturerService manufacturerService) { + this.manufacturerService = manufacturerService; + } + + @GetMapping + public String getManufacturers(Model model) { + model.addAttribute("manufacturers", + manufacturerService.findAllManufacturers().stream() + .map(ManufacturerDTO::new) + .toList()); + return "manufacturers"; + } + + @GetMapping(value = {"/update", "/update/{id}"}) + public String editManufacturer(@PathVariable(required = false) Long id, + Model model) { + if (id == null || id <= 0) { + model.addAttribute("manufacturerDto", new ManufacturerDTO()); + } else { + model.addAttribute("manufacturerDto", id); + model.addAttribute("manufacturerDto", new ManufacturerDTO(manufacturerService.findManufacturer(id))); + } + return "manufacturer-update"; + } + + @PostMapping(value = {"/", "/{id}"}) + public String saveManufacturer(@PathVariable(required = false) Long id, + @ModelAttribute("manufacturerDto") ManufacturerDTO manufacturerDTO, + BindingResult bindingResult, + Model model) throws IOException { + if (bindingResult.hasErrors()) { + model.addAttribute("errors", + bindingResult.getAllErrors()); + return "manufacturer-update"; + } + if (id == null || id <= 0) { + manufacturerService.addManufacturer(manufacturerDTO); + } else { + manufacturerService.updateManufacturer(id, manufacturerDTO); + } + return "redirect:/manufacturer"; + } + + @PostMapping("/delete/{id}") + public String deleteGenre(@PathVariable Long id) { + manufacturerService.deleteManufacturer(id); + return "redirect:/manufacturer"; + } +} 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 39781ab..1130572 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 @@ -6,6 +6,7 @@ import org.springframework.web.multipart.MultipartFile; import ru.ulstu.is.sbapp.HardwareShop.models.Product; import ru.ulstu.is.sbapp.HardwareShop.services.ManufacturerService; import ru.ulstu.is.sbapp.HardwareShop.services.ProductService; +import ru.ulstu.is.sbapp.WebConfiguration; import javax.validation.Valid; import java.io.IOException; @@ -13,7 +14,7 @@ import java.util.Base64; import java.util.List; @RestController -@RequestMapping("/product") +@RequestMapping(WebConfiguration.REST_API + "/product") public class ProductController { private final ProductService productService; @@ -34,6 +35,11 @@ public class ProductController { .toList(); } + @GetMapping("/{id}/manufacturers") + public List getProductManufacturers(@PathVariable Long id){ + return productService.getProductManufacturers(id).stream().map(ManufacturerDTO::new).toList(); + } + @PostMapping public ProductDTO createProduct(@RequestBody @Valid ProductDTO productDTO) throws IOException{ return new ProductDTO(productService.addProduct(productDTO)); @@ -44,9 +50,14 @@ public class ProductController { return new ProductDTO(productService.updateProduct(id, productDTO)); } - @PostMapping("/{id}/{manufacturer}") - public void addManufacturer(@PathVariable Long id, @PathVariable Long manufacturer_id) { - productService.addManufacturersToProduct(id, manufacturer_id); + @PostMapping("/{id}/Manufacturer/{manufacturerId}") + public void addManufacturer(@PathVariable Long id, @PathVariable Long manufacturerId) { + productService.addManufacturersToProduct(id, manufacturerId); + } + + @DeleteMapping("/{id}/Manufacturer/{manufacturerId}") + public void removeManufacturer(@PathVariable Long id, @PathVariable Long manufacturerId) { + productService.removeManufacturersToProduct(id, manufacturerId); } @DeleteMapping("/{id}") 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 0c494d1..8a49791 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 @@ -15,6 +15,8 @@ public class ProductDTO { @JsonProperty("categoryId") private Long category_id; + private String categoryName; + private String name; public ProductDTO() {} @@ -25,6 +27,7 @@ public class ProductDTO { this.price = product.getPrice(); this.photo = new String(product.getPhoto(), StandardCharsets.UTF_8); this.category_id = product.getCategory().getId(); + this.categoryName = product.getCategory().getName(); } public Long getId() { @@ -45,9 +48,15 @@ public class ProductDTO { return category_id; } + public String getCategoryName() { return categoryName; } + + public void setId(Long id) { this.id = id; } + public void setPhoto(String photo) { this.photo = photo; } public void setName(String name) { this.name = name; } public void setPrice(Integer price) { this.price = price; } + + public void setCategoryName(String name) { this.categoryName = name; } } diff --git a/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ProductMvcController.java b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ProductMvcController.java new file mode 100644 index 0000000..6c9d4ea --- /dev/null +++ b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/controller/ProductMvcController.java @@ -0,0 +1,104 @@ +package ru.ulstu.is.sbapp.HardwareShop.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import ru.ulstu.is.sbapp.HardwareShop.services.CategoryService; +import ru.ulstu.is.sbapp.HardwareShop.services.ManufacturerService; +import ru.ulstu.is.sbapp.HardwareShop.services.ProductService; + +import java.io.IOException; +import java.util.Base64; + +@Controller +@RequestMapping("/product") +public class ProductMvcController { + private final ProductService productService; + private final ManufacturerService manufacturerService; + + private final CategoryService categoryService; + + public ProductMvcController(ProductService productService, ManufacturerService manufacturerService, CategoryService categoryService) { + this.productService = productService; + this.manufacturerService = manufacturerService; + this.categoryService = categoryService; + } + + @GetMapping + public String getProducts(Model model) { + model.addAttribute("products", + productService.findAllProducts().stream() + .map(ProductDTO::new) + .toList()); + return "products"; + } + + @GetMapping(value = {"/update", "/update/{id}"}) + public String updateProduct(@PathVariable(required = false) Long id, + Model model) { + model.addAttribute("Manufacturers", manufacturerService.findAllManufacturers()); + if (id == null || id <= 0) { + model.addAttribute("productDto", new ProductDTO()); + } else { + model.addAttribute("productDto", id); + model.addAttribute("productDto", new ProductDTO(productService.findProduct(id))); + } + return "product-update"; + } + + @PostMapping(value = {"/", "/{id}"}) + public String saveProduct(@PathVariable(required = false) Long id, + @RequestParam(value = "multipartFile") MultipartFile multipartFile, + @ModelAttribute("productDto") ProductDTO productDTO, + BindingResult bindingResult, + Model model) throws IOException { + if (bindingResult.hasErrors()) { + model.addAttribute("errors", + bindingResult.getAllErrors()); + return "product-update"; + } + productDTO.setPhoto("data:" + multipartFile.getContentType() + ";base64," + Base64.getEncoder().encodeToString(multipartFile.getBytes())); + productDTO.setCategoryName(categoryService.findCategory(productDTO.getCategory_id()).getName()); + if (id == null || id <= 0) { + productService.addProduct(productDTO); + } else { + productService.updateProduct(id, productDTO); + } + return "redirect:/product"; + } + + @PostMapping("/delete/{id}") + public String deleteBook(@PathVariable Long id) { + productService.deleteProduct(id); + return "redirect:/product"; + } + + @GetMapping("/{id}/manufacturers") + public String getProductManufacturers(@PathVariable Long id, Model model){ + model.addAttribute("product", + new ProductDTO(productService.findProduct(id))); + model.addAttribute("productmanufacturers", + productService.getProductManufacturers(id).stream() + .map(ManufacturerDTO::new) + .toList()); + model.addAttribute("manufacturers", + manufacturerService.findAllManufacturers().stream() + .map(ManufacturerDTO::new) + .toList()); + return "product-mtm"; + } + + @PostMapping("/{id}/manufacturers") + public String addManufacturerToProduct(@PathVariable Long id, @RequestParam(value = "manufacturerid") Long manufacturerid){ + productService.addManufacturersToProduct(id, manufacturerid); + return "redirect:/product/" + id.toString() + "/manufacturers"; + } + + @PostMapping("/{id}/manufacturers/{manufacturerid}") + public String removeManufacturerFromProduct(@PathVariable Long id, @PathVariable Long manufacturerid){ + productService.removeManufacturersToProduct(id, manufacturerid); + return "redirect:/product/" + id.toString() + "/manufacturers"; + } +} diff --git a/src/main/java/ru/ulstu/is/sbapp/HardwareShop/models/Product.java b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/models/Product.java index e6685f2..7ebd735 100644 --- a/src/main/java/ru/ulstu/is/sbapp/HardwareShop/models/Product.java +++ b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/models/Product.java @@ -58,7 +58,7 @@ public class Product { public String getName() { return name; } - public void setName() { this.name = name; } + public void setName(String name) { this.name = name; } public void setPrice(Integer price) { this.price = price; } diff --git a/src/main/java/ru/ulstu/is/sbapp/HardwareShop/services/ProductService.java b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/services/ProductService.java index 4058c5a..a44b99c 100644 --- a/src/main/java/ru/ulstu/is/sbapp/HardwareShop/services/ProductService.java +++ b/src/main/java/ru/ulstu/is/sbapp/HardwareShop/services/ProductService.java @@ -76,8 +76,10 @@ public class ProductService { @Transactional public Product updateProduct(Long id, ProductDTO productDTO) { final Product currentProduct = findProduct(id); + currentProduct.setName(productDTO.getName()); currentProduct.setPrice(productDTO.getPrice()); - /*currentProduct.setPhoto(productDTO.getPhoto().getBytes(StandardCharsets.UTF_8));*/ + currentProduct.setPhoto(productDTO.getPhoto().getBytes(StandardCharsets.UTF_8)); + currentProduct.setCategory(categoryService.findCategory(productDTO.getCategory_id())); validatorUtil.validate(currentProduct); return productRepository.save(currentProduct); } @@ -121,8 +123,7 @@ public class ProductService { } @Transactional - public List getProductManufacturers(Long id){ - List manufacturers = productRepository.getManufacturers(id); - return manufacturers; + public List getProductManufacturers(Long id){ + return productRepository.findById(id).get().getManufacturerList(); } } diff --git a/src/main/java/ru/ulstu/is/sbapp/Util/Errors/AdviceController.java b/src/main/java/ru/ulstu/is/sbapp/Util/Errors/AdviceController.java index 32c7d59..2175acc 100644 --- a/src/main/java/ru/ulstu/is/sbapp/Util/Errors/AdviceController.java +++ b/src/main/java/ru/ulstu/is/sbapp/Util/Errors/AdviceController.java @@ -7,10 +7,11 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.RestController; import ru.ulstu.is.sbapp.Util.Validation.ValidationException; import java.util.stream.Collectors; -@ControllerAdvice +@ControllerAdvice(annotations = RestController.class) public class AdviceController { @ExceptionHandler({ ValidationException.class diff --git a/src/main/java/ru/ulstu/is/sbapp/WebConfiguration.java b/src/main/java/ru/ulstu/is/sbapp/WebConfiguration.java index 64d729a..2e3ce44 100644 --- a/src/main/java/ru/ulstu/is/sbapp/WebConfiguration.java +++ b/src/main/java/ru/ulstu/is/sbapp/WebConfiguration.java @@ -2,10 +2,18 @@ package ru.ulstu.is.sbapp; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration public class WebConfiguration implements WebMvcConfigurer { + public static final String REST_API = "/api"; + @Override + public void addViewControllers(ViewControllerRegistry registry) { + WebMvcConfigurer.super.addViewControllers(registry); + registry.addViewController("product"); + } + @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**").allowedMethods("*"); diff --git a/src/main/resources/templates/categories.html b/src/main/resources/templates/categories.html new file mode 100644 index 0000000..31ff918 --- /dev/null +++ b/src/main/resources/templates/categories.html @@ -0,0 +1,49 @@ + + + + + +
+
+ + Добавить + +
+
+ + + + + + + + + + + + +
НазваниеРедактировать запись
+ +
+ + Изменить + + +
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/category-update.html b/src/main/resources/templates/category-update.html new file mode 100644 index 0000000..dc822b2 --- /dev/null +++ b/src/main/resources/templates/category-update.html @@ -0,0 +1,31 @@ + + + + + +
+
+
+
+ + +
+
+ + + Назад + +
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/default.html b/src/main/resources/templates/default.html new file mode 100644 index 0000000..c437993 --- /dev/null +++ b/src/main/resources/templates/default.html @@ -0,0 +1,48 @@ + + + + + Онлайн магазин + + + + + + + +
+ +
+
+
+
+
+
+
+
+
End
+
+
+
+ + + + \ No newline at end of file diff --git a/src/main/resources/templates/error.html b/src/main/resources/templates/error.html new file mode 100644 index 0000000..566549b --- /dev/null +++ b/src/main/resources/templates/error.html @@ -0,0 +1,10 @@ + + + + + Title + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/manufacturer-update.html b/src/main/resources/templates/manufacturer-update.html new file mode 100644 index 0000000..ba5890e --- /dev/null +++ b/src/main/resources/templates/manufacturer-update.html @@ -0,0 +1,31 @@ + + + + + +
+
+
+
+ + +
+
+ + + Назад + +
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/manufacturers.html b/src/main/resources/templates/manufacturers.html new file mode 100644 index 0000000..52ba672 --- /dev/null +++ b/src/main/resources/templates/manufacturers.html @@ -0,0 +1,51 @@ + + + + + +
+
+ + Добавить + +
+
+ + + + + + + + + + + + + +
НазваниеАдрессРедактировать запись
+ + +
+ + Изменить + + +
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/product-mtm.html b/src/main/resources/templates/product-mtm.html new file mode 100644 index 0000000..74189c3 --- /dev/null +++ b/src/main/resources/templates/product-mtm.html @@ -0,0 +1,50 @@ + + + + + +
+
+ + + + + + + + + + + + +
НазваниеРедактировать запись
+ +
+ +
+
+ +
+
+
+
+
+ + +
+
+
+ Закрыть +
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/product-update.html b/src/main/resources/templates/product-update.html new file mode 100644 index 0000000..30a5779 --- /dev/null +++ b/src/main/resources/templates/product-update.html @@ -0,0 +1,44 @@ + + + + + +
+
+
+
+ + +
+
+ + +
+
+ + + +
+ + +
+ + + Назад + +
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/products.html b/src/main/resources/templates/products.html new file mode 100644 index 0000000..17f2163 --- /dev/null +++ b/src/main/resources/templates/products.html @@ -0,0 +1,59 @@ + + + + + +
+
+ + Добавить + +
+
+ + + + + + + + + + + + + + + + +
НазваниеЦенаФотоКатегорияРедактировать запись
+ + + + +
+ +
+
+
+
+ + \ No newline at end of file