feat : cycle
This commit is contained in:
@@ -10,14 +10,24 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Cron\Good;
|
||||
|
||||
use App\Model\Cycle;
|
||||
use Hyperf\Crontab\Annotation\Crontab;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
|
||||
#[Crontab(rule: "0 5 * * *", name: "CycleCreateTask", singleton: true , callback: "execute", memo: "这是一个示例的定时任务")]
|
||||
#[Crontab(rule: "0 5 * * *", name: "CycleCreateTask", singleton: true , callback: "execute", memo: "创建新的周期任务")]
|
||||
class CycleCreateTask
|
||||
{
|
||||
/**
|
||||
* @var Cycle $cycleModel
|
||||
*/
|
||||
#[Inject]
|
||||
protected Cycle $cycleModel;
|
||||
|
||||
public function execute()
|
||||
{
|
||||
//todo Write logic
|
||||
var_dump(date('Y-m-d H:i:s', time()));
|
||||
|
||||
$maxDate = $this->cycleModel->max('date');
|
||||
}
|
||||
}
|
||||
31
app/Model/Cycle.php
Normal file
31
app/Model/Cycle.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
use Hyperf\DbConnection\Model\Model;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $dates
|
||||
* @property int $is_use
|
||||
* @property string $create_time
|
||||
*/
|
||||
class Cycle extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'cycle';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*/
|
||||
protected array $casts = ['id' => 'integer', 'is_use' => 'integer'];
|
||||
}
|
||||
Reference in New Issue
Block a user