feat: 新增获取所有商品接口(包括下架)用于商品管理
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取商品详情
|
* 获取商品详情
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取商品详情
|
* 获取商品详情
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取商品详情
|
* 获取商品详情
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
-- 添加商品长度、宽度、面积字段
|
|
||||||
ALTER TABLE order_items ADD COLUMN length DECIMAL(10,2) COMMENT '长度(cm)';
|
|
||||||
ALTER TABLE order_items ADD COLUMN width DECIMAL(10,2) COMMENT '宽度(cm)';
|
|
||||||
ALTER TABLE order_items ADD COLUMN area DECIMAL(10,4) COMMENT '面积(m²)';
|
|
||||||
Reference in New Issue
Block a user