Compare commits

...

2 Commits

Author SHA1 Message Date
Agent
ed0138c777 feat: 新增获取所有商品接口(包括下架)用于商品管理
All checks were successful
continuous-integration/drone/push Build is passing
2026-04-01 15:18:41 +00:00
Agent
0a62e19d51 feat: 订单明细增加长度、宽度、面积字段 2026-04-01 14:01:55 +00:00
6 changed files with 67 additions and 0 deletions

View File

@@ -79,6 +79,18 @@ public class ProductController {
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));
}
/**
* 获取商品详情
*/

View File

@@ -70,5 +70,20 @@ public class CreateOrderRequest {
* 销售单价(用户可自定义)
*/
private BigDecimal price;
/**
* 长度(cm)
*/
private BigDecimal length;
/**
* 宽度(cm)
*/
private BigDecimal width;
/**
* 面积(m²)
*/
private BigDecimal area;
}
}

View File

@@ -86,6 +86,21 @@ public class OrderItem {
*/
private BigDecimal subtotal;
/**
* 长度(cm)
*/
private BigDecimal length;
/**
* 宽度(cm)
*/
private BigDecimal width;
/**
* 面积(m²)
*/
private BigDecimal area;
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createdAt;
}

View File

@@ -37,6 +37,11 @@ public interface ProductService {
*/
Page<Product> getProducts(String categoryId, String keyword, Integer page, Integer pageSize);
/**
* 获取所有商品(包括下架的)
*/
Page<Product> getAllProducts(String categoryId, String keyword, Integer page, Integer pageSize);
/**
* 获取商品详情
*/

View File

@@ -113,6 +113,9 @@ public class OrderServiceImpl implements OrderService {
item.setDescription(product.getDescription());
item.setPrice(price);
item.setQuantity(itemDTO.getQuantity());
item.setLength(itemDTO.getLength());
item.setWidth(itemDTO.getWidth());
item.setArea(itemDTO.getArea());
item.setSubtotal(subtotal);
orderItems.add(item);
@@ -364,6 +367,9 @@ public class OrderServiceImpl implements OrderService {
item.setDescription(product.getDescription());
item.setPrice(price);
item.setQuantity(itemDTO.getQuantity());
item.setLength(itemDTO.getLength());
item.setWidth(itemDTO.getWidth());
item.setArea(itemDTO.getArea());
item.setSubtotal(subtotal);
orderItems.add(item);
orderItemMapper.insert(item);

View File

@@ -99,6 +99,20 @@ public class ProductServiceImpl implements ProductService {
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);
}
/**
* 获取商品详情
*/