From 26b110b73ac6cacaec5ea79c4407a430f1f02727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A1=E6=A0=8B?= Date: Thu, 18 Nov 2021 13:45:32 +0800 Subject: [PATCH] * code for task #44331. --- api/v1/entries/executionbugs.php | 54 ++++++++++++++++++++++++++++++++ api/v1/entries/projectbugs.php | 2 +- config/routes.php | 9 +++--- module/doc/model.php | 1 + 4 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 api/v1/entries/executionbugs.php diff --git a/api/v1/entries/executionbugs.php b/api/v1/entries/executionbugs.php new file mode 100644 index 0000000000..e9a86f0d4c --- /dev/null +++ b/api/v1/entries/executionbugs.php @@ -0,0 +1,54 @@ + + * @package entries + * @version 1 + * @link http://www.zentao.net + */ +class executionBugsEntry extends entry +{ + /** + * GET method. + * + * @param int $executionID + * @access public + * @return void + */ + public function get($executionID = 0) + { + if(!$executionID) $executionID = $this->param('execution', 0); + if(empty($executionID)) return $this->sendError(400, 'Need execution id.'); + + $control = $this->loadController('execution', 'bug'); + $control->bug($executionID, $this->param('product', 0), $this->param('order', 'status,id_desc'), $this->param('build', 0), $this->param('status', 'all'), 0, 0, $this->param('limit', 20), $this->param('page', 1)); + + $data = $this->getData(); + + if(isset($data->status) and $data->status == 'success') + { + $bugs = $data->data->bugs; + $pager = $data->data->pager; + $result = array(); + foreach($bugs as $bug) + { + $status = array('code' => $bug->status, 'name' => $this->lang->bug->statusList[$bug->status]); + if($bug->status == 'active' and $bug->confirmed) $status = array('code' => 'confirmed', 'name' => $this->lang->bug->labelConfirmed); + if($bug->resolution == 'postponed') $status = array('code' => 'postponed', 'name' => $this->lang->bug->labelPostponed); + if(!empty($bug->delay)) $status = array('code' => 'delay', 'name' => $this->lang->bug->overdueBugs); + $bug->status = $status; + + $result[] = $this->format($bug, 'activatedDate:time,openedDate:time,assignedDate:time,resolvedDate:time,closedDate:time,lastEditedDate:time,deadline:date,deleted:bool'); + } + + return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'bugs' => $result)); + } + + if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message); + + return $this->sendError(400, 'error'); + } +} diff --git a/api/v1/entries/projectbugs.php b/api/v1/entries/projectbugs.php index 711e239970..589afe1940 100644 --- a/api/v1/entries/projectbugs.php +++ b/api/v1/entries/projectbugs.php @@ -9,7 +9,7 @@ * @version 1 * @link http://www.zentao.net */ -class projectbugsEntry extends entry +class projectBugsEntry extends entry { /** * GET method. diff --git a/config/routes.php b/config/routes.php index f0072833e6..e782bf3b79 100644 --- a/config/routes.php +++ b/config/routes.php @@ -39,10 +39,11 @@ $routes['/executions/:id/stories'] = 'executionStories'; $routes['/stories/:id'] = 'story'; $routes['/stories/:id/change'] = 'storyChange'; -$routes['/products/:id/bugs'] = 'bugs'; -$routes['/projects/:id/bugs'] = 'projectBugs'; -$routes['/bugs'] = 'bugs'; -$routes['/bugs/:id'] = 'bug'; +$routes['/products/:id/bugs'] = 'bugs'; +$routes['/projects/:id/bugs'] = 'projectBugs'; +$routes['/executions/:id/bugs'] = 'executionBugs'; +$routes['/bugs'] = 'bugs'; +$routes['/bugs/:id'] = 'bug'; $routes['/programs/:id/projects'] = 'projects'; $routes['/projects'] = 'projects'; diff --git a/module/doc/model.php b/module/doc/model.php index 0e93e7039e..46199a50f1 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -1647,6 +1647,7 @@ class docModel extends model $docItem->type = 'doc'; $docItem->id = $doc->id; $docItem->title = $doc->title; + $docItem->acl = $doc->acl; $docItem->url = helper::createLink('doc', 'view', "doc=$doc->id"); $buttons = '';