使用模型重写部分逻辑
This commit is contained in:
parent
d59d078fa0
commit
d8577d7350
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class Timetable extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'timetable';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
}
|
|
@ -22,9 +22,9 @@
|
|||
'driver' => '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',
|
||||
|
|
Loading…
Reference in New Issue