+ Finish task#41812,41813,41814

This commit is contained in:
zenggang
2021-08-26 14:54:16 +08:00
parent 043da8c966
commit e92f6632a4
4 changed files with 76 additions and 13 deletions
+26 -1
View File
@@ -8,8 +8,11 @@
*/
class issuesEntry extends entry
{
public function get()
public function get($projectID = 0)
{
if($projectID) return $this->getProjectIssues($projectID);
/* Get my issues defaultly. */
$control = $this->loadController('my', 'issue');
$control->issue($this->param('type', 'assignedTo'), $this->param('order', 'id_desc'), $this->param('total', 0), $this->param('limit', 20), $this->param('page', 1));
$data = $this->getData();
@@ -27,6 +30,28 @@ class issuesEntry extends entry
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'issues' => $result));
}
private function getProjectIssues($projectID)
{
$project = $this->loadModel('project')->getByID($projectID);
if(!$project) return $this->send404();
$control = $this->loadController('issue', 'browse');
$control->browse($projectID, $this->param('type', 'all'), 0, $this->param('order', ''), $this->param('total', 0), $this->param('limit', 20), $this->param('page', 1));
$data = $this->getData();
if(!isset($data->status)) return $this->sendError(400, 'error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
$pager = $data->data->pager;
$result = array();
foreach($data->data->issueList as $issue)
{
$result[] = $this->format($issue, 'createdDate:time,editedDate:time,assignedDate:time');
}
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'issues' => $result));
}
public function post($projectID = 0)
{
if((int) $projectID <= 0) $this->sendError(400, 'The id of project is wrong.');
+18 -4
View File
@@ -8,11 +8,25 @@
*/
class risksEntry extends entry
{
public function get()
public function get($projectID = 0)
{
$control = $this->loadController('my', 'risk');
$control->risk($this->param('type', 'assignedTo'), $this->param('order', 'id_desc'), $this->param('total', 0), $this->param('limit', 20), $this->param('page', 1));
$data = $this->getData();
if(!$projectID)
{
/* Get my risks defaultly. */
$control = $this->loadController('my', 'risk');
$control->risk($this->param('type', 'assignedTo'), $this->param('order', 'id_desc'), $this->param('total', 0), $this->param('limit', 20), $this->param('page', 1));
$data = $this->getData();
}
else
{
$project = $this->loadModel('project')->getByID($projectID);
if(!$project) return $this->send404();
/* Get risks by project. */
$control = $this->loadController('risk', 'browse');
$control->browse($projectID, $this->param('type', 'all'), '', $this->param('order', ''), $this->param('total', 0), $this->param('limit', 20), $this->param('page', 1));
$data = $this->getData();
}
if(!isset($data->status)) return $this->sendError(400, 'error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
+26 -3
View File
@@ -8,10 +8,14 @@
*/
class testtasksEntry extends entry
{
public function get()
public function get($projectID = 0)
{
$control = $this->loadController('testtask', 'browse');
$control->browse($this->param('productID', 0), $this->param('branch', ''), ($this->param('productID', 0) > 0 ? 'local' : 'all') . ',' . $this->param('status', 'totalStatus'), $this->param('order', 'date_desc'), $this->param('total', 0), $this->param('limit', 20), $this->param('page', 1), $this->param('begin', ''), $this->param('end', ''));
if($projectID) return $this->getProjectTesttasks($projectID);
/* Get all testtasks. */
$control = $this->loadController('testtask', 'browse');
$productID = $this->param('productID', 0);
$control->browse($productID, $this->param('branch', ''), ($productID > 0 ? 'local' : 'all') . ',' . $this->param('status', 'totalStatus'), $this->param('order', 'id_desc'), $this->param('total', 0), $this->param('limit', 20), $this->param('page', 1), $this->param('begin', ''), $this->param('end', ''));
$data = $this->getData();
if(!isset($data->status)) return $this->sendError(400, 'error');
@@ -26,4 +30,23 @@ class testtasksEntry extends entry
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'testtasks' => $result));
}
private function getProjectTesttasks($projectID)
{
$project = $this->loadModel('project')->getByID($projectID);
if(!$project) return $this->send404();
$this->app->loadClass('pager', $static = true);
$pager = pager::init($this->param('total', 0), $this->param('limit', 20), $this->param('page', 1));
$testtasks = $this->loadModel('testtask')->getProjectTasks($projectID, $this->param('order', 'id_desc'), $pager);
$result = array();
foreach($testtasks as $testtask)
{
$result[] = $this->format($testtask, 'realFinishedDate:time');
}
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'testtasks' => $result));
}
}
+6 -5
View File
@@ -50,11 +50,12 @@ $routes['/issues/:issueID'] = 'issue';
$routes['/todos'] = 'todos';
$routes['/todos/:id'] = 'todo';
$routes['/testtasks'] = 'testtasks';
$routes['/testtasks/:id'] = 'testtask';
$routes['/projects/:projectID/testtasks'] = 'testtasks';
$routes['/testtasks'] = 'testtasks';
$routes['/testtasks/:id'] = 'testtask';
$routes['/projects/:project/risks'] = 'risks';
$routes['/risks'] = 'risks';
$routes['/risks/:id'] = 'risk';
$routes['/projects/:projectID/risks'] = 'risks';
$routes['/risks'] = 'risks';
$routes['/risks/:id'] = 'risk';
$config->routes = $routes;