From 79d92a2e554c0898db3e3f2a0177a0ee6854ed3f Mon Sep 17 00:00:00 2001 From: "yangsai@163.com" <2624183217@qq.com> Date: Thu, 6 Jun 2024 14:22:26 +0800 Subject: [PATCH] YS --- application/controllers/Api/Cage.php | 1 + application/models/Cage.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/application/controllers/Api/Cage.php b/application/controllers/Api/Cage.php index 31c5d74..05be4e8 100644 --- a/application/controllers/Api/Cage.php +++ b/application/controllers/Api/Cage.php @@ -46,6 +46,7 @@ class Api_CageController extends Ctrl_Api{ $params['uid'] = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid']; $params['keyword'] = empty($this->POST['keyword'])?'':$this->POST['keyword']; $params['page'] = empty($this->POST['page'])?1:$this->POST['page']; + $params['desc'] = empty($this->POST['desc'])||!isset($this->POST['desc'])?'desc':Tool_Fnc::safe_string($this->POST['desc']); $data = $this->Cagemodel->getModelList($params); Tool_Fnc::apiMsg('笼位获取成功', '200',$data); } diff --git a/application/models/Cage.php b/application/models/Cage.php index e86b962..50744da 100644 --- a/application/models/Cage.php +++ b/application/models/Cage.php @@ -25,9 +25,9 @@ class CageModel extends Orm_Base{ $sql .=" and (number like '%{$params['keyword']}%' or strains like '%{$params['keyword']}%')"; } if(!empty($params['order'])){ - $sql .=" order by {$params['order']} desc"; + $sql .=" order by {$params['order']} {$params['desc']}"; }else{ - $sql .=" order by id desc"; + $sql .=" order by id {$params['desc']}"; } $data['count'] = count($this->query($sql)); $offset = ($params['page']-1)*$limmit;