Browse Source

设置文章审核必选作者

master V0.1.5
刘道霖 3 years ago
parent
commit
4cd6d5b97f
  1. 4
      app/controller/ArticleController.php
  2. 61
      app/controller/TestController.php

4
app/controller/ArticleController.php

@ -103,6 +103,10 @@ class ArticleController extends BaseController
$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);

61
app/controller/TestController.php

@ -0,0 +1,61 @@
<?php
namespace app\controller;
use app\BaseController;
class TestController extends BaseController
{
/**
*冒泡排序
*/
public function bubble_sort()
{
$arr = [22, 69, 10];
$d = $this->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);
}
}
Loading…
Cancel
Save