修复我的页统计空作品报错
This commit is contained in:
+6
-1
@@ -328,6 +328,7 @@ public class DashboardController {
|
||||
List<Map<String, Object>> productOrderCounts = orderItemMapper.selectMaps(
|
||||
new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<OrderItemDO>()
|
||||
.select("product_id, COUNT(*) as order_count")
|
||||
.isNotNull("product_id")
|
||||
.groupBy("product_id")
|
||||
.orderByDesc("order_count")
|
||||
.last("LIMIT 5")
|
||||
@@ -337,7 +338,11 @@ public class DashboardController {
|
||||
|
||||
// 遍历查询结果,获取商品详情
|
||||
for (Map<String, Object> map : productOrderCounts) {
|
||||
Long productId = Long.valueOf(map.get("product_id").toString());
|
||||
Object productIdValue = map.get("product_id");
|
||||
if (productIdValue == null) {
|
||||
continue;
|
||||
}
|
||||
Long productId = Long.valueOf(productIdValue.toString());
|
||||
ProductDO product = productMapper.selectById(productId);
|
||||
|
||||
if (product != null && (shopId == null || shopId.equals(product.getShopId()))) {
|
||||
|
||||
Reference in New Issue
Block a user