* Fix errors of api.

This commit is contained in:
zhujinyong
2021-11-29 13:09:05 +08:00
parent 4b57e8627b
commit be26a7c731
10 changed files with 61 additions and 25 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ class bugsEntry extends entry
if(empty($productID)) return $this->sendError(400, 'Need product 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));
$control->browse($productID, $this->param('branch', 'all'), $this->param('status', ''), 0, $this->param('order', 'id_desc'), 0, $this->param('limit', 20), $this->param('page', 1));
$data = $this->getData();
+9 -7
View File
@@ -84,15 +84,17 @@ class executionsEntry extends entry
$this->batchSetPost($fields);
$projectID = $this->param('project', $projectID);
$this->setPost('project', $projectID);
$this->setPost('acl', $this->request('acl', 'private'));
$this->setPost('project', $projectID);
$this->setPost('acl', $this->request('acl', 'private'));
$this->setPost('PO', $this->request('PO', ''));
$this->setPost('PM', $this->request('PM', ''));
$this->setPost('QD', $this->request('QD', ''));
$this->setPost('RD', $this->request('RD', ''));
$this->setPost('whitelist', $this->request('whitelist', array()));
$this->setPost('products', $this->request('products', array()));
$this->setPost('plans', $this->request('plans', array()));
$control = $this->loadController('execution', 'create');
$this->requireFields('name,code,begin,end,days');
$this->setPost('products', $this->request('products', array()));
$this->setPost('plans', $this->request('plans', array()));
$control = $this->loadController('execution', 'create'); $this->requireFields('name,code,begin,end,days');
$control->create($projectID);
$data = $this->getData();
+2 -1
View File
@@ -38,8 +38,9 @@ class programEntry extends Entry
$oldProgram = $this->loadModel('program')->getByID($programID);
/* Set $_POST variables. */
$fields = 'name,PM,budget,budgetUnit,desc,begin,end,realBegan,realEnd,ac,whitelist';
$fields = 'name,PM,budget,budgetUnit,desc,parent,begin,end,realBegan,realEnd,acl,whitelist';
$this->batchSetPost($fields, $oldProgram);
$this->setPost('parent', $this->request('parent', 0));
$control = $this->loadController('program', 'edit');
$control->edit($programID);
+25 -1
View File
@@ -72,6 +72,31 @@ class programsEntry extends Entry
return $this->send(200, array('programs' => array_values($result)));
}
/**
* POST method.
*
* @access public
* @return void
*/
public function post()
{
$fields = 'name,PM,budget,budgetUnit,desc,begin,end';
$this->batchSetPost($fields);
$this->setPost('acl', $this->request('acl', 'open'));
$this->setPost('whitelist', $this->request('whitelist', array()));
$control = $this->loadController('program', 'create');
$this->requireFields('name,begin,end');
$control->create($this->request('parent', 0));
$data = $this->getData();
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
$program = $this->loadModel('program')->getByID($data->id);
$this->send(201, $this->format($program, 'openedDate:time,whitelist:stringList'));
}
/**
* Get drop menu.
*
@@ -80,7 +105,6 @@ class programsEntry extends Entry
*/
public function getDropMenu()
{
$programs = $this->dao->select('id,name,parent,path,grade,`order`')->from(TABLE_PROJECT)
->where('deleted')->eq('0')
->andWhere('type')->eq('program')
+1 -1
View File
@@ -129,7 +129,7 @@ class storyEntry extends Entry
$this->getData();
$story = $this->story->getByID($storyID);
$this->sendSuccess(200, $this->format($story, 'openedDate:time,assignedDate:time,reviewedDate:time,lastEditedDate:time,closedDate:time,deleted:bool'));
$this->send(200, $this->format($story, 'openedDate:time,assignedDate:time,reviewedDate:time,lastEditedDate:time,closedDate:time,deleted:bool'));
}
/**
+1 -1
View File
@@ -35,7 +35,7 @@ class storyChangeEntry extends Entry
}
$control = $this->loadController('story', 'change');
$this->requireFields('title,spec');
$this->requireFields('title,spec,verify');
$control->change($storyID);
+1 -1
View File
@@ -43,7 +43,7 @@ class tasksEntry extends entry
foreach($tasks as $task)
{
if(isset($task->children)) $task->children = array_values((array)$task->children);
$result[] = $this->format($task, 'openedDate:time,assignedDate:time,realStarted:time,finishedDate:time,canceledDate:time,closedDate:time,lastEditedDate:time,deleted:bool');
$result[] = $this->format($task, 'deadline:date,openedDate:time,assignedDate:time,realStarted:time,finishedDate:time,canceledDate:time,closedDate:time,lastEditedDate:time,deleted:bool');
}
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'tasks' => $result));
}
+10 -10
View File
@@ -50,16 +50,16 @@ $routes['/products/:id/projects'] = 'productProjects';
$routes['/projects'] = 'projects';
$routes['/projects/:id'] = 'project';
$routes['/projects/:project/executions'] = 'executions';
$routes['/executions'] = 'executions';
$routes['/executions/:id'] = 'execution';
$routes['/projects/:id/executions'] = 'executions';
$routes['/executions'] = 'executions';
$routes['/executions/:id'] = 'execution';
$routes['/executions/:execution/tasks'] = 'tasks';
$routes['/tasks'] = 'tasks';
$routes['/tasks/:id'] = 'task';
$routes['/tasks/:id/assignto'] = 'taskAssignTo';
$routes['/tasks/:id/start'] = 'taskStart';
$routes['/tasks/:id/finish'] = 'taskFinish';
$routes['/executions/:id/tasks'] = 'tasks';
$routes['/tasks'] = 'tasks';
$routes['/tasks/:id'] = 'task';
$routes['/tasks/:id/assignto'] = 'taskAssignTo';
$routes['/tasks/:id/start'] = 'taskStart';
$routes['/tasks/:id/finish'] = 'taskFinish';
$routes['/users'] = 'users';
$routes['/users/:id'] = 'user';
@@ -73,7 +73,7 @@ $routes['/programs/:id/stakeholders'] = 'stakeholders';
$routes['/products/:id/issues'] = 'productIssues';
$routes['/projects/:id/issues'] = 'issues';
$routes['/issues'] = 'issues';
$routes['/issues/:issueID'] = 'issue';
$routes['/issues/:id'] = 'issue';
$routes['/todos'] = 'todos';
$routes['/todos/:id'] = 'todo';
+10
View File
@@ -601,6 +601,16 @@ class baseEntry
if($val !== '') $idList[] = (int) $val;
}
return $idList;
case 'stringList':
$values = explode(',', $value);
if(empty($values)) return array();
$stringList = array();
foreach($values as $val)
{
if($val !== '') $stringList[] = $val;
}
return $stringList;
default:
return $value;
}
+1 -2
View File
@@ -156,10 +156,9 @@ class program extends control
{
$programID = $this->program->create();
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $programID));
$this->loadModel('action')->create('program', $programID, 'opened');
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $programID, 'locate' => inlink('browse')));
}
$extra = str_replace(array(',', ' '), array('&', ''), $extra);