WokerTask/app/middleapi/controller/TaskSchedulingPlanControlle...

62 lines
2.2 KiB
PHP

<?php
namespace app\middleapi\controller;
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
use app\common\controller\BaseLikeAdminController;
/**
* 任务排期日历控制器
* Class TaskSchedulingPlanController
* @package app\adminapi\controller\task_scheduling_plan
*/
class TaskSchedulingPlanController extends BaseLikeAdminController
{
/**
* @notes 获取任务排期日历列表
* @return \think\response\Json
* @author likeadmin
* @date 2023/08/08 10:34
*/
public function lists()
{
if(!$this->request->isPost()){
return $this->fail('请求方式错误');
}
$params=$this->request->post(['page_no','page_size','template_id','scheduling_id','status','start_time','end_time']);
$where = [];
if (isset($params['template_id']) && $params['template_id'] != '') {
$where[] = ['template_id', '=', $params['template_id']];
}
if (isset($params['scheduling_id']) && $params['scheduling_id'] != '') {
$where[] = ['scheduling_id', '=', $params['scheduling_id']];
}
if (isset($params['status']) && $params['status'] != '') {
$where[] = ['status', '=', $params['status']];
}
if (isset($params['start_time']) && $params['start_time'] != '') {
$where[] = ['start_time', '>=', strtotime($params['start_time'])];
}
if (isset($params['end_time']) && $params['end_time'] != '') {
$where[] = ['end_time', '<=', strtotime($params['end_time'])];
}
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
$data = TaskSchedulingPlan::where($where)
->with(['template','templateInfo'])
->page($pageNo, $pageSize)
->order(['id' => 'desc'])
->select()
->toArray();
$count = TaskSchedulingPlan::where($where)->count();
$result = [
'lists' => $data,
'count' => $count,
'page_no' => $pageNo,
'page_size' => $pageSize
];
return $this->success('请求成功',$result);
}
}