From d8577d7350ab92327b5d0bc7d2bb1feb3110e577 Mon Sep 17 00:00:00 2001 From: lingling <1077478963@qq.com> Date: Sat, 20 Apr 2024 15:39:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=A8=A1=E5=9E=8B=E9=87=8D?= =?UTF-8?q?=E5=86=99=E9=83=A8=E5=88=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/IndexController.php | 25 ++++++++++++------------- app/model/Timetable.php | 29 +++++++++++++++++++++++++++++ config/database.php | 6 +++--- 3 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 app/model/Timetable.php diff --git a/app/controller/IndexController.php b/app/controller/IndexController.php index 7944461..83a0cd5 100644 --- a/app/controller/IndexController.php +++ b/app/controller/IndexController.php @@ -7,13 +7,15 @@ use support\Db; use app\result\Result; use Carbon\Carbon; +use app\model\Timetable; + class IndexController { public function index(Request $request) { static $readme; if (!$readme) { - $readme = '70'; + $readme = '700'; // $readme = file_get_contents(base_path('README.md')); } return $readme; @@ -22,18 +24,18 @@ class IndexController /** * 更新时间 */ - public function updated($name = 'ThinkPHP6') + public function updated($whether_manual = 1) { // 获取当前时间 $current = Carbon::now(); // 添加 21 天到当前时间 $trialExpires = $current->addDays(21); - $data = ['date' => $trialExpires->toDateString(), 'tip' => ' ']; - // $result = Db::table("demo")->where("id",1)->find(); - // dump($result); - Db::table('time_log')->insert($data); - return Result::show(200, 'ok', ['time' => $trialExpires]); + $timetable=new Timetable; + $timetable->date=$trialExpires->toDateString(); + $timetable->tip=$whether_manual==0?'自动提交':'手动提交'; + $timetable->save(); + return Result::show(200, 'ok', ['time' => $timetable]); } /** @@ -41,21 +43,18 @@ class IndexController */ public function scheduled_tasks($name = 'ThinkPHP6') { - $db_time = Db::table('time_log')->where('id', Db::table('time_log')->max('id'))->first(); - //dump($db_time); + $db_time = Timetable::where('id', Timetable::where('id','>',0)->max('id'))->first(); $time = $db_time['date']; // 获取当前时间 $current = Carbon::now(); for ($i = 0; $i < 8; $i++) { $current->subDay($i); if (strcmp($current->toDateString(), $time) == 0) { - - echo "to do "; - //$this->updated(""); - $i == 7 ? $this->updated("") : ''; + $i == 7 ? $this->updated(0) : ''; return Result::show(200, 'ok', ['time' => $current->toDateString(), 'time2' => $time]); } } + return Result::show(200,'ok',''); } public function send_msg($title, $body) { diff --git a/app/model/Timetable.php b/app/model/Timetable.php new file mode 100644 index 0000000..34ac7df --- /dev/null +++ b/app/model/Timetable.php @@ -0,0 +1,29 @@ + 'mysql', 'host' => '127.0.0.1', 'port' => 3306, - 'database' => 'kunkun_shagain_c', - 'username' => 'kunkun_shagain_c', - 'password' => 'JcAT8frcGfrrrJBN', + 'database' => 'sql', + 'username' => 'sql', + 'password' => 'arxYBLyp3nMePn5C', 'unix_socket' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci',