From d04d46b6f93d49f61a7c8d8180ff1b9d23622cfc Mon Sep 17 00:00:00 2001 From: "zhangf@suq.cn" Date: Tue, 8 Sep 2026 10:10:16 +0800 Subject: [PATCH] =?UTF-8?q?feat(content):=20=E6=9B=B4=E6=96=B0=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=8E=92=E5=BA=8F=E9=80=BB=E8=BE=91=E4=BB=A5=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=A4=9A=E5=AD=97=E6=AE=B5=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 ContentService.php 中的查询排序方式,从单一 id 降序改为 sort 升序和 id 降序组合 - 更新 Model.php 中 getAllCustomArrayData 方法的默认排序参数 - 优化内容列表的数据排序策略,提升数据展示的灵活性 --- app/model/Model.php | 2 +- app/service/ContentService.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/model/Model.php b/app/model/Model.php index 6f9f60d..aec17d5 100644 --- a/app/model/Model.php +++ b/app/model/Model.php @@ -101,7 +101,7 @@ class Model extends BaseModel return dataReturn($this->sucCode,$this->getMsg,$res); } - public function getAllCustomArrayData($where,$order='id desc',$field="*",$with=[],$offset=0): array + public function getAllCustomArrayData($where,$order='sort asc,id desc',$field="*",$with=[],$offset=0): array { $key = md5($this->className . json_encode([$where,$order,$field,$with])); diff --git a/app/service/ContentService.php b/app/service/ContentService.php index 65e47fc..3aa8fd9 100644 --- a/app/service/ContentService.php +++ b/app/service/ContentService.php @@ -838,7 +838,10 @@ class ContentService { $content = $content -> where($param['where']); } $data = $content ->whereIn('id',$subIds) - ->order('id','desc') + ->order([ + 'sort'=>'asc', + 'id'=>'desc' + ]) ->field('id,seller_id,category_id,sub_category_ids,module_id,lang,main_id,title,sub_title,thumbnail,hits,admin_id,status,check_status,url as link_url,publish_time,sort,version,show_version,is_del,del_user_id') ->paginate($param['limit'])->each(function (&$item)use($param){ if(!empty($item['category'])){