Compare commits
2 Commits
083a8cb4c7
...
ed0138c777
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed0138c777 | ||
|
|
0a62e19d51 |
@@ -79,6 +79,18 @@ public class ProductController {
|
|||||||
return Result.success(productService.getProducts(categoryId, keyword, page, pageSize));
|
return Result.success(productService.getProducts(categoryId, keyword, page, pageSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有商品(包括下架的,用于管理)
|
||||||
|
*/
|
||||||
|
@GetMapping("/all")
|
||||||
|
public Result<Page<Product>> getAllProducts(
|
||||||
|
@RequestParam(required = false) String categoryId,
|
||||||
|
@RequestParam(required = false) String keyword,
|
||||||
|
@RequestParam(defaultValue = "1") Integer page,
|
||||||
|
@RequestParam(defaultValue = "20") Integer pageSize) {
|
||||||
|
return Result.success(productService.getAllProducts(categoryId, keyword, page, pageSize));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取商品详情
|
* 获取商品详情
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -70,5 +70,20 @@ public class CreateOrderRequest {
|
|||||||
* 销售单价(用户可自定义)
|
* 销售单价(用户可自定义)
|
||||||
*/
|
*/
|
||||||
private BigDecimal price;
|
private BigDecimal price;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 长度(cm)
|
||||||
|
*/
|
||||||
|
private BigDecimal length;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 宽度(cm)
|
||||||
|
*/
|
||||||
|
private BigDecimal width;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 面积(m²)
|
||||||
|
*/
|
||||||
|
private BigDecimal area;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,21 @@ public class OrderItem {
|
|||||||
*/
|
*/
|
||||||
private BigDecimal subtotal;
|
private BigDecimal subtotal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 长度(cm)
|
||||||
|
*/
|
||||||
|
private BigDecimal length;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 宽度(cm)
|
||||||
|
*/
|
||||||
|
private BigDecimal width;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 面积(m²)
|
||||||
|
*/
|
||||||
|
private BigDecimal area;
|
||||||
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
@TableField(fill = FieldFill.INSERT)
|
||||||
private LocalDateTime createdAt;
|
private LocalDateTime createdAt;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ public interface ProductService {
|
|||||||
*/
|
*/
|
||||||
Page<Product> getProducts(String categoryId, String keyword, Integer page, Integer pageSize);
|
Page<Product> getProducts(String categoryId, String keyword, Integer page, Integer pageSize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有商品(包括下架的)
|
||||||
|
*/
|
||||||
|
Page<Product> getAllProducts(String categoryId, String keyword, Integer page, Integer pageSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取商品详情
|
* 获取商品详情
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -113,6 +113,9 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
item.setDescription(product.getDescription());
|
item.setDescription(product.getDescription());
|
||||||
item.setPrice(price);
|
item.setPrice(price);
|
||||||
item.setQuantity(itemDTO.getQuantity());
|
item.setQuantity(itemDTO.getQuantity());
|
||||||
|
item.setLength(itemDTO.getLength());
|
||||||
|
item.setWidth(itemDTO.getWidth());
|
||||||
|
item.setArea(itemDTO.getArea());
|
||||||
item.setSubtotal(subtotal);
|
item.setSubtotal(subtotal);
|
||||||
orderItems.add(item);
|
orderItems.add(item);
|
||||||
|
|
||||||
@@ -364,6 +367,9 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
item.setDescription(product.getDescription());
|
item.setDescription(product.getDescription());
|
||||||
item.setPrice(price);
|
item.setPrice(price);
|
||||||
item.setQuantity(itemDTO.getQuantity());
|
item.setQuantity(itemDTO.getQuantity());
|
||||||
|
item.setLength(itemDTO.getLength());
|
||||||
|
item.setWidth(itemDTO.getWidth());
|
||||||
|
item.setArea(itemDTO.getArea());
|
||||||
item.setSubtotal(subtotal);
|
item.setSubtotal(subtotal);
|
||||||
orderItems.add(item);
|
orderItems.add(item);
|
||||||
orderItemMapper.insert(item);
|
orderItemMapper.insert(item);
|
||||||
|
|||||||
@@ -99,6 +99,20 @@ public class ProductServiceImpl implements ProductService {
|
|||||||
return productMapper.selectPage(pageParam, wrapper);
|
return productMapper.selectPage(pageParam, wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<Product> getAllProducts(String categoryId, String keyword, Integer page, Integer pageSize) {
|
||||||
|
Page<Product> pageParam = new Page<>(page, pageSize);
|
||||||
|
LambdaQueryWrapper<Product> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (StringUtils.hasText(categoryId)) {
|
||||||
|
wrapper.eq(Product::getCategoryId, categoryId);
|
||||||
|
}
|
||||||
|
if (StringUtils.hasText(keyword)) {
|
||||||
|
wrapper.like(Product::getName, keyword);
|
||||||
|
}
|
||||||
|
wrapper.orderByDesc(Product::getCreatedAt);
|
||||||
|
return productMapper.selectPage(pageParam, wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取商品详情
|
* 获取商品详情
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user