* code for task #44334.

This commit is contained in:
王怡栋
2021-11-19 11:04:30 +08:00
parent e0f2e88048
commit 7dbcf304d1

View File

@@ -9,42 +9,22 @@
* @version 1
* @link http://www.zentao.net
*/
class bugsEntry extends entry
class bugsEntry extends entry
{
/**
* GET method.
*
* @param int $productID
* @param int $projectID
* @param int $executionID
* @access public
* @return void
*/
public function get($productID = 0, $projectID = 0, $executionID = 0)
public function get($productID = 0)
{
if(!$productID) $productID = $this->param('product', 0);
if(!$projectID) $projectID = $this->param('project', 0);
if(!$executionID) $executionID = $this->param('execution', 0);
if(empty($productID)) $productID = $this->param('product', 0);
if(empty($productID)) return $this->sendError(400, 'Need product id.');
if($projectID)
{
$control = $this->loadController('project', 'bug');
$control->bug($projectID, $productID, $this->param('order', 'status,id_desc'), $this->param('build', 0), $this->param('status', 'all'), 0, $this->param('limit', 20), $this->param('page', 1));
}
elseif($executionID)
{
$control = $this->loadController('execution', 'bug');
$control->bug($executionID, $productID, $this->param('order', 'status,id_desc'), $this->param('build', 0), $this->param('status', 'all'), 0, $this->param('limit', 20), $this->param('page', 1));
}
elseif($productID)
{
$control = $this->loadController('bug', 'browse');
$control->browse($productID, $this->param('branch', ''), $this->param('status', ''), 0, $this->param('order', ''), 0, $this->param('limit', 20), $this->param('page', 1));
}
else
{
return $this->sendError(400, 'Need product or project or execution id.');
}
$control = $this->loadController('bug', 'browse');
$control->browse($productID, $this->param('branch', ''), $this->param('status', 'unclosed'), 0, $this->param('order', 'id_desc'), 0, $this->param('limit', 20), $this->param('page', 1));
$data = $this->getData();
@@ -55,16 +35,31 @@ class bugsEntry extends entry
$result = array();
foreach($bugs as $bug)
{
$result[] = $this->format($bug, 'activatedDate:time,openedDate:time,assignedDate:time,resolvedDate:time,closedDate:time,lastEditedDate:time,deadline:date,deleted:bool');
$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[$bug->id] = $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));
$storyChangeds = $this->dao->select('t1.id')->from(TABLE_BUG)->alias('t1')
->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story=t2.id')
->where('t1.id')->in(array_keys($result))
->andWhere('t1.story')->ne('0')
->andWhere('t1.storyVersion != t2.version')
->fetchPairs('id', 'id');
foreach($storyChangeds as $bugID)
{
$status = array('code' => 'storyChanged', 'name' => $this->lang->bug->changed);
$result[$bugID]->status = $status;
}
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'bugs' => array_values($result)));
}
if(isset($data->status) and $data->status == 'fail')
{
return $this->sendError(400, $data->message);
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
return $this->sendError(400, 'error');
}
@@ -91,7 +86,7 @@ class bugsEntry extends entry
$this->requireFields('title,pri,severity,type,openedBuild');
$control->create($productID);
$data = $this->getData();
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
if(isset($data->result) and !isset($data->id)) return $this->sendError(400, $data->message);