Browse Source

feat(search): 添加封面关联查询以优化搜索结果展示

- 在 SubContent 查询中新增 cover 关联关系
- 为 cover 关联配置字段筛选 (id, name, url, type)
- 保持原有的 thumbnail 和 category 关联查询逻辑
- 优化搜索结果中媒体资源的加载效率
master
zhangf@suq.cn 2 weeks ago
parent
commit
3ba69a2b6f
  1. 4
      app/controller/frontend/SearchController.php

4
app/controller/frontend/SearchController.php

@ -226,7 +226,9 @@ class SearchController extends BaseController
$baseWhere = ['seller_id' => $this->sellerId, 'is_del' => 1]; $baseWhere = ['seller_id' => $this->sellerId, 'is_del' => 1];
$content = (new SubContent())->with(['thumbnail'=>function($q){ $content = (new SubContent())->with(['thumbnail'=>function($q){
$q->field('id,name,url,type'); $q->field('id,name,url,type');
},'category'])->where($baseWhere)->whereIn('id', $listSubIds ?: [0]);
},'category', 'cover'=>function($q){
$q->field('id,name,url,type');
}])->where($baseWhere)->whereIn('id', $listSubIds ?: [0]);
$productIdSet = array_flip($productContentIds); $productIdSet = array_flip($productContentIds);
$newsIdSet = array_flip($newsContentIds); $newsIdSet = array_flip($newsContentIds);

Loading…
Cancel
Save