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">
|
<div class = "container">
|
||||||
<h2>Товары</h2>
|
<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">
|
<div class="d-flex align-items-center justify-content-between">
|
||||||
<a href="/admin/product/edit/" class="btn btn-secondary">Добавить товар</a>
|
<a href="/admin/product/edit/" class="btn btn-secondary">Добавить товар</a>
|
||||||
<form class="search-form" th:action="@{/admin/product}" method="get" style="display: flex;">
|
<form class="search-form" th:action="@{/admin/product}" method="get" style="display: flex;">
|
||||||
@ -73,14 +62,9 @@
|
|||||||
currentPage=${currentPage}) }" />
|
currentPage=${currentPage}) }" />
|
||||||
</th:block>
|
</th:block>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane container fade" id="stats">
|
<!-- <div class="tab-pane container fade" id="stats">
|
||||||
<ul class="list-group mb-2">
|
|
||||||
<li th:each="stat : ${stats}" class="list-group-item">
|
</div> -->
|
||||||
<strong>[[${stat.typeName}]]</strong>:
|
|
||||||
[[${#numbers.formatDecimal(stat.totalPrice, 1, 2)}]] ₽
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</th:block>
|
</th:block>
|
||||||
@ -89,3 +73,35 @@
|
|||||||
</body>
|
</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.configuration.Constants;
|
||||||
import com.example.demo.core.security.UserPrincipal;
|
import com.example.demo.core.security.UserPrincipal;
|
||||||
import com.example.demo.products.model.ProductEntity;
|
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.model.ProductGrouped;
|
||||||
import com.example.demo.products.service.ProductService;
|
import com.example.demo.products.service.ProductService;
|
||||||
import com.example.demo.types.api.TypeDto;
|
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_EDIT_VIEW = "product-edit";
|
||||||
public static final String PRODUCT_ATTRIBUTE = "product";
|
public static final String PRODUCT_ATTRIBUTE = "product";
|
||||||
private static final String PAGE_ATTRIBUTE = "page";
|
private static final String PAGE_ATTRIBUTE = "page";
|
||||||
private static final String TYPEID_ATTRIBUTE = "typeId";
|
|
||||||
|
|
||||||
private final ProductService productService;
|
private final ProductService productService;
|
||||||
private final TypeService typeService;
|
private final TypeService typeService;
|
||||||
@ -52,13 +50,13 @@ public class ProductController {
|
|||||||
return modelMapper.map(entity, ProductDto.class);
|
return modelMapper.map(entity, ProductDto.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProductGroupedDto toGroupedDto(ProductGrouped entity) {
|
/*private ProductGroupedDto toGroupedDto(ProductGrouped entity) {
|
||||||
return modelMapper.map(entity, ProductGroupedDto.class);
|
return modelMapper.map(entity, ProductGroupedDto.class);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
private ExpandedProductDto toExpandedDto(ProductEntity entity, Long userId) {
|
private ExpandedProductDto toExpandedDto(ProductEntity entity, Long userId) {
|
||||||
ExpandedProductDto dto = modelMapper.map(entity, ExpandedProductDto.class);
|
ExpandedProductDto dto = modelMapper.map(entity, ExpandedProductDto.class);
|
||||||
dto.setTypeName(typeService.get(dto.getTypeName()).getName());
|
dto.setTypeName(typeService.get(dto.getTypeId()).getName());
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +66,7 @@ public class ProductController {
|
|||||||
|
|
||||||
private ProductEntity toEntity(ProductDto dto) {
|
private ProductEntity toEntity(ProductDto dto) {
|
||||||
final ProductEntity entity = modelMapper.map(dto, ProductEntity.class);
|
final ProductEntity entity = modelMapper.map(dto, ProductEntity.class);
|
||||||
entity.setType(typeService.get(dto.getTypeName()));
|
entity.setType(typeService.get(dto.getTypeId()));
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +74,7 @@ public class ProductController {
|
|||||||
public String getAll(
|
public String getAll(
|
||||||
@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||||
@RequestParam(name = "query", required = false) String query,
|
@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,
|
Model model,
|
||||||
@AuthenticationPrincipal UserPrincipal principal) {
|
@AuthenticationPrincipal UserPrincipal principal) {
|
||||||
|
|
||||||
@ -94,13 +92,13 @@ public class ProductController {
|
|||||||
model.addAllAttributes(attributes);
|
model.addAllAttributes(attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
model.addAllAttributes(PageAttributesMapper.toAttributes(
|
/*model.addAllAttributes(PageAttributesMapper.toAttributes(
|
||||||
productService.getAll(typeId, page, Constants.DEFUALT_PAGE_SIZE),
|
productService.getAll(typeId, page, Constants.DEFUALT_PAGE_SIZE),
|
||||||
this::toDto));
|
this::toDto));
|
||||||
model.addAttribute("stats",
|
model.addAttribute("stats",
|
||||||
productService.getTotal().stream()
|
productService.getTotal().stream()
|
||||||
.map(this::toGroupedDto)
|
.map(this::toGroupedDto)
|
||||||
.toList());
|
.toList()); */
|
||||||
|
|
||||||
model.addAttribute("query", query);
|
model.addAttribute("query", query);
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ public class ProductDto {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Min(1)
|
@Min(1)
|
||||||
private String typeName;
|
private Long typeId;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Min(1)
|
@Min(1)
|
||||||
@ -43,12 +43,12 @@ public class ProductDto {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypeName() {
|
public Long getTypeId() {
|
||||||
return typeName;
|
return typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTypeName(String typeName) {
|
public void setTypeId(Long typeId) {
|
||||||
this.typeName = typeName;
|
this.typeId = typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getPrice() {
|
public Double getPrice() {
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package com.example.demo.products.api;
|
package com.example.demo.products.api;
|
||||||
|
|
||||||
public class ProductGroupedDto {
|
public class ProductGroupedDto {
|
||||||
private String typeName;
|
private Long typeId;
|
||||||
private Long totalPrice;
|
private Long totalPrice;
|
||||||
|
|
||||||
public String getTypeName() {
|
public Long getTypeId() {
|
||||||
return typeName;
|
return typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTypeName(String typeName) {
|
public void setTypeId(Long typeId) {
|
||||||
this.typeName = typeName;
|
this.typeId = typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getTotalPrice() {
|
public Long getTotalPrice() {
|
||||||
|
@ -49,12 +49,6 @@ public class TypeService {
|
|||||||
.orElseThrow(() -> new NotFoundException(TypeEntity.class, id));
|
.orElseThrow(() -> new NotFoundException(TypeEntity.class, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
public TypeEntity get(String name) {
|
|
||||||
return repository.findByNameIgnoreCase(name)
|
|
||||||
.orElseThrow(() -> new IllegalArgumentException("Invalid typeName"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public TypeEntity create(TypeEntity entity) {
|
public TypeEntity create(TypeEntity entity) {
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
|
@ -13,17 +13,6 @@
|
|||||||
<div class = "container">
|
<div class = "container">
|
||||||
<h2>Товары</h2>
|
<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">
|
<div class="d-flex align-items-center justify-content-between">
|
||||||
<a href="/admin/product/edit/" class="btn btn-secondary">Добавить товар</a>
|
<a href="/admin/product/edit/" class="btn btn-secondary">Добавить товар</a>
|
||||||
<form class="search-form" th:action="@{/admin/product}" method="get" style="display: flex;">
|
<form class="search-form" th:action="@{/admin/product}" method="get" style="display: flex;">
|
||||||
@ -73,14 +62,9 @@
|
|||||||
currentPage=${currentPage}) }" />
|
currentPage=${currentPage}) }" />
|
||||||
</th:block>
|
</th:block>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane container fade" id="stats">
|
<!-- <div class="tab-pane container fade" id="stats">
|
||||||
<ul class="list-group mb-2">
|
|
||||||
<li th:each="stat : ${stats}" class="list-group-item">
|
</div> -->
|
||||||
<strong>[[${stat.typeName}]]</strong>:
|
|
||||||
[[${#numbers.formatDecimal(stat.totalPrice, 1, 2)}]] ₽
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</th:block>
|
</th:block>
|
||||||
@ -89,3 +73,35 @@
|
|||||||
</body>
|
</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