diff --git a/app/admin/controller/monitor/CrontabController.php b/app/admin/controller/monitor/CrontabController.php index 4eef1f9aececaf9b0eb716897a6057ce8c7969e0..e8ef945689ee39775ef4421441e8c0f3c672df13 100644 --- a/app/admin/controller/monitor/CrontabController.php +++ b/app/admin/controller/monitor/CrontabController.php @@ -108,4 +108,21 @@ class CrontabController extends Crud return Json::fail($e->getMessage(), [], $e->getCode()); } } + + public function update(Request $request): Response + { + try { + $id = $request->route->param('id'); + $data = $this->inputFilter($request->all(),['month','week','day','hour','minute','second']); + if (isset($this->validate) && $this->validate) { + if (!$this->validate->scene('update')->check($data)) { + throw new Exception($this->validate->getError()); + } + } + $this->service->update($id, $data); + return $this->success('ok', []); + } catch (Throwable $e) { + return $this->fail($e->getMessage()); + } + } } diff --git a/app/services/system/SystemCrontabService.php b/app/services/system/SystemCrontabService.php index 6a86abfb814f84c2ea56840037702d6f923bda61..37788eef73570edb56d48bf103426faf832ce208 100644 --- a/app/services/system/SystemCrontabService.php +++ b/app/services/system/SystemCrontabService.php @@ -59,7 +59,7 @@ class SystemCrontabService extends BaseService foreach ($result as $item) { $item->rule_name .= ''; $item->set('last_running_time', date('Y-m-d H:i:s', $item->getData('last_running_time'))); - $item->logs = $systemCrontabLogService->dao->getModel() + $item->logs = $systemCrontabLogService->getModel() ->where(['crontab_id' => $item->id]) ->order('create_time', 'desc') ->find();