* fix api of projectissue.

This commit is contained in:
zhujinyong
2021-07-30 15:17:56 +08:00
parent 8392165c9f
commit bdc440ddf6
4 changed files with 58 additions and 10 deletions
@@ -1,16 +1,18 @@
<?php
/**
* 禅道API的product issues资源类
* 禅道API的project issues资源类
* 版本V1
* 目前适用于Gitlab
*
* The product issues entry point of zentaopms
* The project issues entry point of zentaopms
* Version 1
*/
class productIssueEntry extends entry
class projectIssueEntry extends entry
{
public function get($issueID)
{
$this->setParam('timeFormat', 'utc');
$idParams = explode('-', $issueID);
if(count($idParams) < 2) $this->sendError(400, 'The id of issue is wrong.');
@@ -4,13 +4,15 @@
* 版本V1
* 目前适用于Gitlab
*
* The product issues entry point of zentaopms
* The project issues entry point of zentaopms
* Version 1
*/
class productIssuesEntry extends entry
class projectIssuesEntry extends entry
{
public function get($productID)
{
$this->setParam('timeFormat', 'utc');
$taskFields = 'id,status';
$taskStatus = array('' => '');
$taskStatus['wait'] = 'wait';
@@ -50,10 +52,16 @@ class productIssuesEntry extends entry
$taskFields .= ',name as title';
$storyFields .= ',title';
$bugFields .= ',title';
case 'lastEditedDate':
$taskFields .= ",if(lastEditedDate < '1970-01-01 01-01-01', openedDate, lastEditedDate) as lastEditedDate";
$storyFields .= ",if(lastEditedDate < '1970-01-01 01-01-01', openedDate, lastEditedDate) as lastEditedDate";
$bugFields .= ",if(lastEditedDate < '1970-01-01 01-01-01', openedDate, lastEditedDate) as lastEditedDate";
default:
$taskFields .= ',openedDate';
$storyFields .= ',openedDate';
$bugFields .= ',openedDate';
$order = 'openedDate';
}
$issues = array();
@@ -136,8 +144,9 @@ class productIssuesEntry extends entry
$r->assignedTo = $task->assignedTo;
$r->openedDate = $task->openedDate;
$r->openedBy = $task->openedBy;
$r->lastEditedDate = $task->lastEditedDate;
$r->lastEditedDate = $task->lastEditedDate < '1970-01-01 01:01:01' ? $task->openedDate : $task->lastEditedDate;
$r->status = $task->status;
$r->url = $this->createLink('task', 'view', "taskID=$task->id");
}
else if($issue['type'] == 'story')
{
@@ -150,8 +159,9 @@ class productIssuesEntry extends entry
$r->assignedTo = $story->assignedTo;
$r->openedDate = $story->openedDate;
$r->openedBy = $story->openedBy;
$r->lastEditedDate = $story->lastEditedDate;
$r->lastEditedDate = $story->lastEditedDate < '1970-01-01 01:01:01' ? $story->openedDate : $story->lastEditedDate;
$r->status = $story->status;
$r->url = $this->createLink('story', 'view', "storyID=$story->id");
}
else if($issue['type'] == 'bug')
{
@@ -164,9 +174,11 @@ class productIssuesEntry extends entry
$r->assignedTo = $bug->assignedTo;
$r->openedDate = $bug->openedDate;
$r->openedBy = $bug->openedBy;
$r->lastEditedDate = $bug->lastEditedDate;
$r->lastEditedDate = $bug->lastEditedDate < '1970-01-01 01:01:01' ? $bug->openedDate : $bug->lastEditedDate;
$r->status = $bug->status;
$r->url = $this->createLink('bug', 'view', "bugID=$bug->id");
}
$result[] = $this->format($r, 'openedDate:time,lastEditedDate:time');
}
@@ -190,4 +202,24 @@ class productIssuesEntry extends entry
return '';
}
/**
* Create url of issue.
*
* @param string $module
* @param string $method
* @param string $vars
* @access private
* @return string
*/
private function createLink($module, $method, $vars)
{
$link = helper::createLink($module, $method, $vars, 'html');
if($this->config->requestType == 'GET')
{
$pos = strpos($link, '.php');
$link = '/index' . substr($link, $pos);
}
return common::getSysURL() . $link;
}
}
+2 -2
View File
@@ -38,7 +38,7 @@ $routes['/user'] = 'user';
$routes['/programs'] = 'programs';
$routes['/programs/:id'] = 'program';
$routes['/issues/:issueID'] = 'productIssue';
$routes['/products/:productID/issues'] = 'productIssues';
$routes['/issues/:issueID'] = 'projectIssue';
$routes['/projects/:projectID/issues'] = 'projectIssues';
$config->routes = $routes;
+14
View File
@@ -86,6 +86,20 @@ class baseEntry
return $defaultValue;
}
/**
* 设置请求参数
* Set request param.
*
* @param string $key
* @param mixed $value
* @access public
* @return mixed
*/
public function setParam($key, $value)
{
$_GET[$key] = $value;
}
/**
* 解析请求数据
* Parse body of request data.