From 08c284054bc5c87e7438efdfe140cd2f3e6cdcf6 Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Tue, 15 Mar 2022 08:21:32 +0800 Subject: [PATCH] *Close a task. --- api/v1/entries/taskclose.php | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 api/v1/entries/taskclose.php diff --git a/api/v1/entries/taskclose.php b/api/v1/entries/taskclose.php new file mode 100644 index 0000000000..774c115c53 --- /dev/null +++ b/api/v1/entries/taskclose.php @@ -0,0 +1,39 @@ + + * @package entries + * @version 1 + * @link http://www.zentao.net + */ +class taskCloseEntry extends Entry +{ + /** + * POST method. + * + * @param int $taskID + * @access public + * @return void + */ + public function post($taskID) + { + $task = $this->loadModel('task')->getByID($taskID); + + $fields = 'comment'; + $this->batchSetPost($fields); + + $control = $this->loadController('task', 'close'); + $control->close($taskID); + + $data = $this->getData(); + if(!$data) return $this->send400('error'); + if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message); + + $task = $this->loadModel('task')->getByID($taskID); + + $this->send(200, $task); + } +}