43 lines
941 B
PHP
43 lines
941 B
PHP
<?php
|
|
/**
|
|
* This crontab file is part of item.
|
|
*
|
|
* @author ctexthuang
|
|
* @contact ctexthuang@qq.com
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Cron\Chef;
|
|
|
|
use App\Lib\Log;
|
|
use App\Service\Cron\RankTaskService;
|
|
use Exception;
|
|
use Hyperf\Crontab\Annotation\Crontab;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use Psr\Container\ContainerExceptionInterface;
|
|
use Psr\Container\NotFoundExceptionInterface;
|
|
|
|
#[Crontab(rule: "0 12 * * 6", name: "RankTask", singleton: true , callback: "execute", memo: "厨师排行榜数据生成")]
|
|
class RankTask
|
|
{
|
|
/**
|
|
* @var Log
|
|
*/
|
|
#[Inject]
|
|
protected Log $log;
|
|
|
|
/**
|
|
* @return void
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
*/
|
|
public function execute(): void
|
|
{
|
|
try {
|
|
(new RankTaskService)->handle();
|
|
}catch (Exception $e){
|
|
$this->log->error(__CLASS__.$e->getMessage());
|
|
}
|
|
}
|
|
} |