From 3e69145e5848b014fad47da9ef38105c3954402c Mon Sep 17 00:00:00 2001 From: Lufei Date: Mon, 7 Nov 2022 15:31:18 +0800 Subject: [PATCH] * Support task restart api. --- api/v1/entries/taskrestart.php | 43 ++++++++++++++++++++++++++++++++++ config/routes.php | 1 + 2 files changed, 44 insertions(+) create mode 100644 api/v1/entries/taskrestart.php diff --git a/api/v1/entries/taskrestart.php b/api/v1/entries/taskrestart.php new file mode 100644 index 0000000000..a43f576d5a --- /dev/null +++ b/api/v1/entries/taskrestart.php @@ -0,0 +1,43 @@ + + * @package entries + * @version 1 + * @link http://www.zentao.net + */ +class taskRestartEntry extends entry +{ + /** + * POST method. + * + * @param int $taskID + * @access public + * @return string + */ + public function post($taskID) + { + $task = $this->loadModel('task')->getByID($taskID); + + $fields = 'assignedTo,realStarted'; + $this->batchSetPost($fields, $task); + + $fields = 'consumed,left,comment'; + $this->batchSetPost($fields); + + $control = $this->loadController('task', 'restart'); + $this->requireFields('consumed,left'); + $control->restart($taskID); + + $data = $this->getData(); + if(!$data) return $this->send400('error'); + if(isset($data->result) and $data->result == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message); + + $task = $this->loadModel('task')->getByID($taskID); + + return $this->send(200, $task); + } +} diff --git a/config/routes.php b/config/routes.php index 97dd57daa8..70fc7b041b 100644 --- a/config/routes.php +++ b/config/routes.php @@ -90,6 +90,7 @@ $routes['/tasks/:id'] = 'task'; $routes['/tasks/:id/assignto'] = 'taskAssignTo'; $routes['/tasks/:id/start'] = 'taskStart'; $routes['/tasks/:id/pause'] = 'taskPause'; +$routes['/tasks/:id/restart'] = 'taskRestart'; $routes['/tasks/:id/finish'] = 'taskFinish'; $routes['/tasks/:id/close'] = 'taskClose'; $routes['/tasks/:id/estimate'] = 'taskRecordEstimate';