Browse Source

refactor(category): 移除分类下最新内容查询逻辑

- 删除了CategorySubContent模型的查询操作
- 移除了子内容模型的相关数据获取代码
- 清理了分类关联文章列表的数据处理流程
- 简化了siblingCates方法的业务逻辑
- 优化了代码结构,提升了执行效率
master
zhangf@suq.cn 3 weeks ago
parent
commit
bc94b384aa
  1. 29
      app/common.php

29
app/common.php

@ -1496,35 +1496,6 @@ if (!function_exists('getOtherCategoryCategoryId')) {
if (empty($siblingCates)) {
return [];
}
// 4. 查询每个分类下最新一条内容
$cateSubModel = new \app\model\CategorySubContent();
$subContentModel = new \app\model\SubContent();
foreach ($siblingCates as &$cate) {
$cateSubIds = $cateSubModel->where('category_id', $cate['id'])
->where('seller_id', $sellerId)
->column('sub_content_id');
if (!empty($cateSubIds)) {
$content = $subContentModel->whereIn('id', $cateSubIds)
->where('seller_id', $sellerId)
->where('is_del', 1)
->with(['thumbnail' => function ($query) {
$query->field('id,name,url,type');
}])
->field('id,title,description')
->order('publish_time desc')
->limit($limit)
->select()
->toArray();
$cate['articles'] = $content;
} else {
$cate['articles'] = [];
}
}
return $siblingCates;
} catch (\Exception $e) {
return [];

Loading…
Cancel
Save