新增系统执行命令方法
parent
f5ad1a6d0c
commit
fb75494c64
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
//推广公司模型
|
||||
namespace Admin\Model;
|
||||
use Think\Model;
|
||||
|
||||
/**
|
||||
* 文档基础模型
|
||||
*/
|
||||
class CmdTasksModel extends Model{
|
||||
protected $tablePrefix = 'tab_';
|
||||
public function getTask()
|
||||
{
|
||||
//按顺序获取任务
|
||||
$has_run = $this->where(['status'=>"1"])->count();
|
||||
if($has_run > 0){
|
||||
return false;
|
||||
}
|
||||
$task = $this->field("id,params")->where(['status'=>"0"])->order("id asc")->find();
|
||||
if(empty($task)){
|
||||
return false;
|
||||
}else{
|
||||
//修改状态为执行中
|
||||
$this->save(['id'=>$task['id'],'status'=>"1","start_time"=>time()]);
|
||||
return $task;
|
||||
}
|
||||
}
|
||||
public function updateTask($params)
|
||||
{
|
||||
$this->save($params);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue