From 1a3ecbb4e9d4b439524cafbdd65f9972b563e4a5 Mon Sep 17 00:00:00 2001 From: ganzizi Date: Fri, 28 Apr 2023 09:28:44 +0800 Subject: [PATCH] =?UTF-8?q?perf=20=E6=96=B0=E5=A2=9E=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E8=B4=9F=E8=B4=A3=E4=BA=BA=E6=A0=87=E8=AF=86=E5=B9=B6=E6=8E=92?= =?UTF-8?q?=E7=AC=AC=E4=B8=80=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/UsersController.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 64f629b08..97cdf10b5 100755 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -707,11 +707,10 @@ class UsersController extends AbstractController $query->where("department", "")->orWhere("department", ",,"); }); } else { - // 关联user_departments表中owner_userid查询出负责人,重新排序,部门负责人始终在前面 $builder->where(function($query) use ($keys) { $query->where("department", "like", "%,{$keys['department']},%") ->orWhereIn('userid', function ($query) use ($keys) { - $query->select('owner_userid')->from('user_departments')->where("id", "=", trim($keys['department'], ',')) + $query->select(['owner_userid'])->from('user_departments')->where("id", "=", trim($keys['department'], ',')) ->orderByRaw("FIELD(owner_userid,{$keys['department']}) DESC"); }); }); @@ -726,7 +725,7 @@ class UsersController extends AbstractController $builder->whereNull('disable_at'); $builder->where('bot', 0); } - $builder = $keys['department'] == '0' ? $builder->orderByDesc('userid') : $builder; + $builder = $keys['department'] == '1' ? $builder : $builder->orderByDesc('userid'); $list = $builder->paginate(Base::getPaginate(50, 20)); // if ($getCheckinMac || isset($keys['department'])) {