From 9da525af6418a6de5433a61245cc46e769dc8d5c Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 10 Oct 2024 16:36:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B4=AD=E4=B9=B0=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E4=BC=98=E6=83=A0=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除冗余的用户ID设置代码 - 改用类属性存储用户ID,提高性能 - 修正查询条件,确保只查询用户相关数据 - 优化计数逻辑,无用户时返回0 --- .../PurchaseProductOfferController.php | 1 - .../PurchaseProductOfferLists.php | 12 +++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/api/controller/purchase_product_offer/PurchaseProductOfferController.php b/app/api/controller/purchase_product_offer/PurchaseProductOfferController.php index ff5b04181..658a806f7 100644 --- a/app/api/controller/purchase_product_offer/PurchaseProductOfferController.php +++ b/app/api/controller/purchase_product_offer/PurchaseProductOfferController.php @@ -26,7 +26,6 @@ class PurchaseProductOfferController extends BaseApiController */ public function lists() { - $this->request->__set('uid',$this->userId); return $this->dataLists(new PurchaseProductOfferLists()); } diff --git a/app/api/lists/purchase_product_offer/PurchaseProductOfferLists.php b/app/api/lists/purchase_product_offer/PurchaseProductOfferLists.php index 73ef2ef1d..1edf7275f 100644 --- a/app/api/lists/purchase_product_offer/PurchaseProductOfferLists.php +++ b/app/api/lists/purchase_product_offer/PurchaseProductOfferLists.php @@ -18,7 +18,6 @@ use app\api\lists\BaseApiDataLists; class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchInterface { - public $userId; /** * @notes 设置搜索条件 * @return \string[][] @@ -44,9 +43,8 @@ class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchI */ public function lists(): array { - $uid=$this->request->__get('uid'); - if($uid){ - $this->searchWhere[]=['buyer_id','=',$uid]; + if($this->userId>0){ + $this->searchWhere[]=['buyer_id','=',$this->userId]; }else{ return []; } @@ -87,10 +85,10 @@ class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchI */ public function count(): int { - if($this->userId){ - return 0; - }else{ + if($this->userId>0){ return PurchaseProductOffer::where($this->searchWhere)->count(); + }else{ + return 0; } }