From bc94b384aa565bbac5759fba727fe71a1a749462 Mon Sep 17 00:00:00 2001 From: "zhangf@suq.cn" Date: Wed, 2 Sep 2026 09:55:15 +0800 Subject: [PATCH] =?UTF-8?q?refactor(category):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E4=B8=8B=E6=9C=80=E6=96=B0=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除了CategorySubContent模型的查询操作 - 移除了子内容模型的相关数据获取代码 - 清理了分类关联文章列表的数据处理流程 - 简化了siblingCates方法的业务逻辑 - 优化了代码结构,提升了执行效率 --- app/common.php | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/app/common.php b/app/common.php index 071cd75..0a6aee1 100644 --- a/app/common.php +++ b/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 [];