+ Add testtask api task#41480

This commit is contained in:
zenggang
2021-08-24 10:20:09 +08:00
parent 19463a9c5f
commit 199f1a48b0
4 changed files with 69 additions and 1 deletions
+32
View File
@@ -0,0 +1,32 @@
<?php
/**
* 禅道API的todo资源类
* 版本V1
*
* The testtask entry point of zentaopms
* Version 1
*/
class testtaskEntry extends entry
{
public function get($testtaskID)
{
$control = $this->loadController('testtask', 'view');
$control->view($testtaskID);
$data = $this->getData();
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(!isset($data->data->task)) $this->sendError(400, 'error');
$testtask = $data->data->task;
$this->send(200, $this->format($testtask, 'realFinishedDate:time'));
}
public function delete($testtaskID)
{
$control = $this->loadController('testtask', 'delete');
$control->delete($testtaskID, 'yes');
$this->getData();
$this->sendSuccess(200, 'success');
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
/**
* 禅道API的testtasks资源类
* 版本V1
*
* The testtasks entry point of zentaopms
* Version 1
*/
class testtasksEntry extends entry
{
public function get()
{
$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', ''));
$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->tasks as $testtask)
{
$result[] = $this->format($testtask, 'realFinishedDate:time');
}
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'testtasks' => $result));
}
}
+3
View File
@@ -48,4 +48,7 @@ $routes['/products/:productID/issues'] = 'productIssues';
$routes['/todos'] = 'todos';
$routes['/todos/:id'] = 'todo';
$routes['/testtasks'] = 'testtasks';
$routes['/testtasks/:id'] = 'testtask';
$config->routes = $routes;
+6 -1
View File
@@ -285,7 +285,11 @@ class testtask extends control
/* Get test task, and set menu. */
$taskID = (int)$taskID;
$task = $this->testtask->getById($taskID, true);
if(!$task) die(js::error($this->lang->notFound) . js::locate('back'));
if(!$task)
{
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'message' => '404 Not found'));
die(js::error($this->lang->notFound) . js::locate('back'));
}
/* When the session changes, you need to query the related products again. */
if($this->session->project != $task->project) $this->view->products = $this->products = $this->product->getProductPairsByProject($task->project);
@@ -981,6 +985,7 @@ class testtask extends control
$browseList = $this->createLink('testtask', 'browse', "productID=$task->product");
if($this->app->openApp == 'execution') $browseList = $this->createLink('execution', 'testtask', "executionID=$task->execution");
if($this->app->openApp == 'project') $browseList = $this->createLink('project', 'testtask', "projectID=$task->project");
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success'));
die(js::locate($browseList, 'parent'));
}
}