Compare commits
No commits in common. "lab4_5" and "main" have entirely different histories.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,17 +13,6 @@
|
||||
<div class = "container">
|
||||
<h2>Товары</h2>
|
||||
|
||||
<ul class="nav nav-underline justify-content-center" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-bs-toggle="pill" href="#products">Позиции</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-bs-toggle="pill" href="#stats">Статистика</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content mt-2">
|
||||
<div class="tab-pane container active" id="products">
|
||||
<div class="d-flex align-items-center justify-content-between">
|
||||
<a href="/admin/product/edit/" class="btn btn-secondary">Добавить товар</a>
|
||||
<form class="search-form" th:action="@{/admin/product}" method="get" style="display: flex;">
|
||||
@ -73,14 +62,9 @@
|
||||
currentPage=${currentPage}) }" />
|
||||
</th:block>
|
||||
</div>
|
||||
<div class="tab-pane container fade" id="stats">
|
||||
<ul class="list-group mb-2">
|
||||
<li th:each="stat : ${stats}" class="list-group-item">
|
||||
<strong>[[${stat.typeName}]]</strong>:
|
||||
[[${#numbers.formatDecimal(stat.totalPrice, 1, 2)}]] ₽
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- <div class="tab-pane container fade" id="stats">
|
||||
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</th:block>
|
||||
@ -88,4 +72,36 @@
|
||||
</main>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <ul class="nav nav-underline justify-content-center" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-bs-toggle="pill" href="#products">Позиции</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-bs-toggle="pill" href="#stats">Статистика</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content mt-2">
|
||||
<div class="tab-pane container active" id="products"> -->
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -18,7 +18,6 @@ import com.example.demo.core.api.PageAttributesMapper;
|
||||
import com.example.demo.core.configuration.Constants;
|
||||
import com.example.demo.core.security.UserPrincipal;
|
||||
import com.example.demo.products.model.ProductEntity;
|
||||
import com.example.demo.products.model.ProductGrouped;
|
||||
//import com.example.demo.products.model.ProductGrouped;
|
||||
import com.example.demo.products.service.ProductService;
|
||||
import com.example.demo.types.api.TypeDto;
|
||||
@ -35,7 +34,6 @@ public class ProductController {
|
||||
public static final String PRODUCT_EDIT_VIEW = "product-edit";
|
||||
public static final String PRODUCT_ATTRIBUTE = "product";
|
||||
private static final String PAGE_ATTRIBUTE = "page";
|
||||
private static final String TYPEID_ATTRIBUTE = "typeId";
|
||||
|
||||
private final ProductService productService;
|
||||
private final TypeService typeService;
|
||||
@ -52,13 +50,13 @@ public class ProductController {
|
||||
return modelMapper.map(entity, ProductDto.class);
|
||||
}
|
||||
|
||||
private ProductGroupedDto toGroupedDto(ProductGrouped entity) {
|
||||
/*private ProductGroupedDto toGroupedDto(ProductGrouped entity) {
|
||||
return modelMapper.map(entity, ProductGroupedDto.class);
|
||||
}
|
||||
}*/
|
||||
|
||||
private ExpandedProductDto toExpandedDto(ProductEntity entity, Long userId) {
|
||||
ExpandedProductDto dto = modelMapper.map(entity, ExpandedProductDto.class);
|
||||
dto.setTypeName(typeService.get(dto.getTypeName()).getName());
|
||||
dto.setTypeName(typeService.get(dto.getTypeId()).getName());
|
||||
return dto;
|
||||
}
|
||||
|
||||
@ -68,7 +66,7 @@ public class ProductController {
|
||||
|
||||
private ProductEntity toEntity(ProductDto dto) {
|
||||
final ProductEntity entity = modelMapper.map(dto, ProductEntity.class);
|
||||
entity.setType(typeService.get(dto.getTypeName()));
|
||||
entity.setType(typeService.get(dto.getTypeId()));
|
||||
return entity;
|
||||
}
|
||||
|
||||
@ -76,7 +74,7 @@ public class ProductController {
|
||||
public String getAll(
|
||||
@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
@RequestParam(name = "query", required = false) String query,
|
||||
@RequestParam(name = TYPEID_ATTRIBUTE, defaultValue = "0") int typeId,
|
||||
//@RequestParam(name = TYPEID_ATTRIBUTE, defaultValue = "0") int typeId,
|
||||
Model model,
|
||||
@AuthenticationPrincipal UserPrincipal principal) {
|
||||
|
||||
@ -94,13 +92,13 @@ public class ProductController {
|
||||
model.addAllAttributes(attributes);
|
||||
}
|
||||
|
||||
model.addAllAttributes(PageAttributesMapper.toAttributes(
|
||||
/*model.addAllAttributes(PageAttributesMapper.toAttributes(
|
||||
productService.getAll(typeId, page, Constants.DEFUALT_PAGE_SIZE),
|
||||
this::toDto));
|
||||
model.addAttribute("stats",
|
||||
productService.getTotal().stream()
|
||||
.map(this::toGroupedDto)
|
||||
.toList());
|
||||
.toList()); */
|
||||
|
||||
model.addAttribute("query", query);
|
||||
|
||||
|
@ -14,7 +14,7 @@ public class ProductDto {
|
||||
|
||||
@NotNull
|
||||
@Min(1)
|
||||
private String typeName;
|
||||
private Long typeId;
|
||||
|
||||
@NotNull
|
||||
@Min(1)
|
||||
@ -43,12 +43,12 @@ public class ProductDto {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return typeName;
|
||||
public Long getTypeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
||||
public void setTypeName(String typeName) {
|
||||
this.typeName = typeName;
|
||||
public void setTypeId(Long typeId) {
|
||||
this.typeId = typeId;
|
||||
}
|
||||
|
||||
public Double getPrice() {
|
||||
|
@ -1,15 +1,15 @@
|
||||
package com.example.demo.products.api;
|
||||
|
||||
public class ProductGroupedDto {
|
||||
private String typeName;
|
||||
private Long typeId;
|
||||
private Long totalPrice;
|
||||
|
||||
public String getTypeName() {
|
||||
return typeName;
|
||||
public Long getTypeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
||||
public void setTypeName(String typeName) {
|
||||
this.typeName = typeName;
|
||||
public void setTypeId(Long typeId) {
|
||||
this.typeId = typeId;
|
||||
}
|
||||
|
||||
public Long getTotalPrice() {
|
||||
|
@ -49,12 +49,6 @@ public class TypeService {
|
||||
.orElseThrow(() -> new NotFoundException(TypeEntity.class, id));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public TypeEntity get(String name) {
|
||||
return repository.findByNameIgnoreCase(name)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Invalid typeName"));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public TypeEntity create(TypeEntity entity) {
|
||||
if (entity == null) {
|
||||
|
@ -13,17 +13,6 @@
|
||||
<div class = "container">
|
||||
<h2>Товары</h2>
|
||||
|
||||
<ul class="nav nav-underline justify-content-center" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-bs-toggle="pill" href="#products">Позиции</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-bs-toggle="pill" href="#stats">Статистика</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content mt-2">
|
||||
<div class="tab-pane container active" id="products">
|
||||
<div class="d-flex align-items-center justify-content-between">
|
||||
<a href="/admin/product/edit/" class="btn btn-secondary">Добавить товар</a>
|
||||
<form class="search-form" th:action="@{/admin/product}" method="get" style="display: flex;">
|
||||
@ -73,14 +62,9 @@
|
||||
currentPage=${currentPage}) }" />
|
||||
</th:block>
|
||||
</div>
|
||||
<div class="tab-pane container fade" id="stats">
|
||||
<ul class="list-group mb-2">
|
||||
<li th:each="stat : ${stats}" class="list-group-item">
|
||||
<strong>[[${stat.typeName}]]</strong>:
|
||||
[[${#numbers.formatDecimal(stat.totalPrice, 1, 2)}]] ₽
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- <div class="tab-pane container fade" id="stats">
|
||||
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</th:block>
|
||||
@ -88,4 +72,36 @@
|
||||
</main>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <ul class="nav nav-underline justify-content-center" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-bs-toggle="pill" href="#products">Позиции</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-bs-toggle="pill" href="#stats">Статистика</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content mt-2">
|
||||
<div class="tab-pane container active" id="products"> -->
|
Loading…
Reference in New Issue
Block a user