Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
0c25c297f7 |
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,6 +13,17 @@
|
||||
<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;">
|
||||
@ -62,9 +73,14 @@
|
||||
currentPage=${currentPage}) }" />
|
||||
</th:block>
|
||||
</div>
|
||||
<!-- <div class="tab-pane container fade" id="stats">
|
||||
|
||||
</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>
|
||||
</div>
|
||||
</th:block>
|
||||
@ -73,35 +89,3 @@
|
||||
</body>
|
||||
|
||||
</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,6 +18,7 @@ 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;
|
||||
@ -34,6 +35,7 @@ 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;
|
||||
@ -50,13 +52,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.getTypeId()).getName());
|
||||
dto.setTypeName(typeService.get(dto.getTypeName()).getName());
|
||||
return dto;
|
||||
}
|
||||
|
||||
@ -66,7 +68,7 @@ public class ProductController {
|
||||
|
||||
private ProductEntity toEntity(ProductDto dto) {
|
||||
final ProductEntity entity = modelMapper.map(dto, ProductEntity.class);
|
||||
entity.setType(typeService.get(dto.getTypeId()));
|
||||
entity.setType(typeService.get(dto.getTypeName()));
|
||||
return entity;
|
||||
}
|
||||
|
||||
@ -74,7 +76,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) {
|
||||
|
||||
@ -92,13 +94,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 Long typeId;
|
||||
private String typeName;
|
||||
|
||||
@NotNull
|
||||
@Min(1)
|
||||
@ -43,12 +43,12 @@ public class ProductDto {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getTypeId() {
|
||||
return typeId;
|
||||
public String getTypeName() {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
public void setTypeId(Long typeId) {
|
||||
this.typeId = typeId;
|
||||
public void setTypeName(String typeName) {
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
public Double getPrice() {
|
||||
|
@ -1,15 +1,15 @@
|
||||
package com.example.demo.products.api;
|
||||
|
||||
public class ProductGroupedDto {
|
||||
private Long typeId;
|
||||
private String typeName;
|
||||
private Long totalPrice;
|
||||
|
||||
public Long getTypeId() {
|
||||
return typeId;
|
||||
public String getTypeName() {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
public void setTypeId(Long typeId) {
|
||||
this.typeId = typeId;
|
||||
public void setTypeName(String typeName) {
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
public Long getTotalPrice() {
|
||||
|
@ -49,6 +49,12 @@ 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,6 +13,17 @@
|
||||
<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;">
|
||||
@ -62,9 +73,14 @@
|
||||
currentPage=${currentPage}) }" />
|
||||
</th:block>
|
||||
</div>
|
||||
<!-- <div class="tab-pane container fade" id="stats">
|
||||
|
||||
</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>
|
||||
</div>
|
||||
</th:block>
|
||||
@ -73,35 +89,3 @@
|
||||
</body>
|
||||
|
||||
</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