From 4cd6d5b97fa4cc4f3d8f78aa9e2c1d479a0679a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E9=81=93=E9=9C=96?= <409729760@qq.com> Date: Tue, 9 May 2023 09:48:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=96=87=E7=AB=A0=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E5=BF=85=E9=80=89=E4=BD=9C=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/ArticleController.php | 6 ++- app/controller/TestController.php | 61 ++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 app/controller/TestController.php diff --git a/app/controller/ArticleController.php b/app/controller/ArticleController.php index 216eb51..0c26961 100644 --- a/app/controller/ArticleController.php +++ b/app/controller/ArticleController.php @@ -102,7 +102,11 @@ class ArticleController extends BaseController }else{ $updateData['check_time'] = null; } - + + if(empty($updateData['account'])){ + return json(['msg' => 'fail', 'data' => '麻烦设置作者', 'code' => 201], 201); + } + Article::where('id', $param['id'])->update($updateData); return json(['msg' => 'success', 'data' => '编辑成功!', 'code' => 200], 200); diff --git a/app/controller/TestController.php b/app/controller/TestController.php new file mode 100644 index 0000000..313074e --- /dev/null +++ b/app/controller/TestController.php @@ -0,0 +1,61 @@ +quick_sort($arr); + dd($d); +// $length = count($arr); +// for ($i = 0; $i < $length; $i++) { +// for ($j = $i+1; $j < $length; $j++) { +// if($arr[$i] > $arr[$j]){ +// $res = $arr[$i]; +// $arr[$i] = $arr[$j]; +// $arr[$j] = $res; +// } +// } +// } +// dd($arr); + } + + /** + *快速排序 + */ + public function quick_sort($arr) + { + try { + + if (!isset($arr[1])) { + return $arr; + } + $left = array(); + $right = array(); + $first = $arr[0]; + foreach ($arr as $v) { + if ($v < $first) { + $left[] = $v; + } else { + $right[] = $v; + } + } + + $left = $this->quick_sort($left); + $right = $this->quick_sort($right); + $left[] = $first; + + }catch(\Exception $e) { + dd($e); + } + return array_merge($left, $right); + } + +}