123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- <?php
- /*
- |--------------------------------------------------------------------------
- | role.php 角色表
- |--------------------------------------------------------------------------
- */
- # 定义几个常用的选项
- $option = array
- (
- 1 => '可执行',
- 2 => '已完成',
- );
- $info = Dever::load('manage/project.get');
- $path = $info['manage']['path'];
- if(isset($info['manage']['setup']))
- {
- $path = $info['manage']['setup'];
- }
-
- # 获取project
- $project = function() use ($info)
- {
- $data = array();
- foreach($info as $k => $v)
- {
- //$k = $v['lib'];
- if (isset($v['lang']) && isset($v['name'])) {
- $data[$k]['id'] = $v['name'];
- $data[$k]['name'] = $v['lang'] . '('.$v['name'].')';
- }
- }
- return $data;
- };
- return array
- (
- # 表名
- 'name' => 'cron',
- # 显示给用户看的名称
- 'lang' => '计划任务',
- 'desc' => Dever::markdown('**启动cron的方法,以下三项任选其一:**
- 1. 常规任务:请将 ```* * * * * root php '.$path.'daemon/main.php``` 放到cron中[建议每分钟执行一次]
- 2. 用户触发:请在 ```config/base.php里开启cron=true``` [一般适用于虚拟主机]
- 3. 长期运行:请执行 ```php '.$path.'daemon/loop.php 1>/dev/null 2>&1 &``` 指令,放置后台运行[一般用于队列等需要长期运行的项目]'),
- # 数据结构
- 'struct' => array
- (
- 'id' => array
- (
- 'type' => 'int-11',
- 'name' => 'ID',
- 'default' => '',
- 'desc' => '',
- 'match' => 'is_numeric',
- 'search' => 'order',
- 'list' => true,
- ),
-
- 'name' => array
- (
- 'type' => 'varchar-32',
- 'name' => '任务名',
- 'default' => '',
- 'desc' => '请输入任务名',
- 'match' => 'is_string',
- 'update' => 'text',
- 'search' => 'fulltext',
- 'list' => true,
- ),
- 'project' => array
- (
- 'type' => 'varchar-30',
- 'name' => '项目',
- 'default' => '',
- 'desc' => '请选择项目',
- 'match' => 'is_string',
- 'update' => 'select',
- 'option' => $project,
- 'list' => true,
- ),
-
- 'interface' => array
- (
- 'type' => 'varchar-100',
- 'name' => '接口(命令行)',
- 'default' => '',
- 'desc' => '请输入接口(命令行)',
- 'match' => 'is_string',
- 'update' => 'text',
- ),
- 'ldate' => array
- (
- 'type' => 'int-11',
- 'name' => '执行时间',
- 'match' => 'is_numeric',
- 'desc' => '请选择执行时间',
- 'update' => 'date',
- 'callback' => 'maketime',
- 'list' => 'date("Y-m-d H:i:s", {ldate})',
- ),
- 'time' => array
- (
- 'type' => 'int-11',
- 'name' => '时间间隔(为0则执行一次)',
- 'default' => '0',
- 'match' => 'is_numeric',
- 'desc' => '请输入时间间隔',
- 'update' => 'text',
- 'list' => true,
- ),
- 'state' => array
- (
- 'type' => 'tinyint-1',
- 'name' => '状态',
- 'default' => '1',
- 'desc' => '请选择状态',
- 'match' => 'is_numeric',
- 'option' => $option,
- 'update' => 'radio',
- 'list' => true,
- ),
-
- 'cdate' => array
- (
- 'type' => 'int-11',
- 'name' => '录入时间',
- 'match' => array('is_numeric', time()),
- 'desc' => '',
- # 只有insert时才生效
- 'insert' => true,
- //'list' => 'date("Y-m-d H:i:s", {cdate})',
- ),
- ),
-
- 'manage' => array
- (
- //'delete' => false
- ),
- # request 请求接口定义
- 'request' => array
- (
- # get
- 'get' => array
- (
- 'where' => array
- (
- 'ldate' => array('yes', '<='),
- 'state' => 1,
- ),
- 'type' => 'all',
- 'order' => array('id', 'desc'),
- 'col' => '*',
- ),
- # get
- 'getOne' => array
- (
- 'where' => array
- (
- 'project' => 'yes',
- 'interface' => 'yes',
- ),
- 'type' => 'one',
- ),
- ),
- );
|