浏览代码

修复定时任务不能修改时间的BUG

Karson 8 年之前
父节点
当前提交
4217f56b1e
共有 2 个文件被更改,包括 27 次插入6 次删除
  1. 9 6
      application/admin/lang/zh-cn/general/crontab.php
  2. 18 0
      application/common/model/Crontab.php

+ 9 - 6
application/admin/lang/zh-cn/general/crontab.php

@@ -1,10 +1,13 @@
 <?php
 
 return [
-    'Title'        => '任务标题',
-    'Maximums'     => '最多执行',
-    'Sleep'        => '延迟秒数',
-    'Schedule'     => '执行周期',
-    'Executes'     => '执行次数',
-    'Execute time' => '执行时间',
+    'Title'              => '任务标题',
+    'Maximums'           => '最多执行',
+    'Sleep'              => '延迟秒数',
+    'Schedule'           => '执行周期',
+    'Executes'           => '执行次数',
+    'Execute time'       => '执行时间',
+    'Request Url'        => '请求URL',
+    'Execute Sql Script' => '执行SQL',
+    'Execute Shell'      => '执行Shell',
 ];

+ 18 - 0
application/common/model/Crontab.php

@@ -15,5 +15,23 @@ class Crontab extends Model
     // 定义字段类型
     protected $type = [
     ];
+    // 追加属性
+    protected $append = [
+    ];
+
+    protected function setBegintimeAttr($value)
+    {
+        return $value && !is_numeric($value) ? strtotime($value) : $value;
+    }
+
+    protected function setEndtimeAttr($value)
+    {
+        return $value && !is_numeric($value) ? strtotime($value) : $value;
+    }
+
+    protected function setExecutetimeAttr($value)
+    {
+        return $value && !is_numeric($value) ? strtotime($value) : $value;
+    }
 
 }