WokerTask/app/adminapi/controller/task/TaskController.php

126 lines
3.6 KiB
PHP
Raw Permalink Normal View History

2023-12-27 14:06:33 +08:00
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\controller\task;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\task\TaskLists;
use app\common\logic\task\TaskLogic;
use app\adminapi\validate\task\TaskValidate;
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
use app\common\model\task_template\TaskTemplate;
/**
* 任务控制器
* Class TaskController
* @package app\adminapi\controller\task
*/
class TaskController extends BaseAdminController
{
/**
* @notes 获取任务列表
* @return \think\response\Json
* @author likeadmin
* @date 2023/08/05 13:39
*/
public function lists()
{
return $this->dataLists(new TaskLists());
}
/**
* @notes 添加任务
* @return \think\response\Json
* @author likeadmin
* @date 2023/08/05 13:39
*/
public function add()
{
$params = (new TaskValidate())->post()->goCheck('add');
if($params['type']==1){
$arr=[42,43,44,45];//信息更新
$params['extend']['informationg']['arr']=$arr;
$params['extend']['informationg']['arr_count']=count($arr);
$params['extend']['informationg']['update']=[];
$params['extend']['informationg']['update_count']=0;
}
$result = TaskLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(TaskLogic::getError());
}
public function CronAdd(){
$all=TaskSchedulingPlan::whereDay('start_time')->with(['template_info','scheduling'])->select();
$res=TaskLogic::CronAdd($all->toArray());
if($res){
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(TaskLogic::getError());
}
/**
* @notes 编辑任务
* @return \think\response\Json
* @author likeadmin
* @date 2023/08/05 13:39
*/
public function edit()
{
$params = (new TaskValidate())->post()->goCheck('edit');
$result = TaskLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(TaskLogic::getError());
}
/**
* @notes 删除任务
* @return \think\response\Json
* @author likeadmin
* @date 2023/08/05 13:39
*/
public function delete()
{
$params = (new TaskValidate())->post()->goCheck('delete');
TaskLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取任务详情
* @return \think\response\Json
* @author likeadmin
* @date 2023/08/05 13:39
*/
public function detail()
{
$params = (new TaskValidate())->goCheck('detail');
$result = TaskLogic::detail($params);
return $this->data($result);
}
}