+ Add productplan methods for api.
This commit is contained in:
@@ -29,7 +29,11 @@ class productplanEntry extends Entry
|
||||
if(!$data or !isset($data->status)) return $this->send400('error');
|
||||
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
|
||||
|
||||
$plan = $this->format($data->data->plan, 'begin:date,end:date,deleted:bool');
|
||||
$plan = $data->data->plan;
|
||||
$plan->stories = $data->data->planStories;
|
||||
$plan->bugs = $data->data->planBugs;
|
||||
|
||||
$plan = $this->format($plan, 'begin:date,end:date,deleted:bool,stories:array,bugs:array');
|
||||
|
||||
return $this->send(200, $plan);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* The productplanlinkbug entry point of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2021 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
|
||||
* @package entries
|
||||
* @version 1
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
class productplanLinkBugEntry extends entry
|
||||
{
|
||||
/**
|
||||
* POST method.
|
||||
*
|
||||
* @param int $planID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function post($planID)
|
||||
{
|
||||
$fields = 'bugs';
|
||||
$this->batchSetPost($fields);
|
||||
|
||||
$control = $this->loadController('productplan', 'linkBug');
|
||||
$control->linkBug($planID);
|
||||
|
||||
$data = $this->getData();
|
||||
if(isset($data->result) and $data->result == 'success')
|
||||
{
|
||||
$control = $this->loadController('productplan', 'view');
|
||||
$control->view($planID);
|
||||
|
||||
$data = $this->getData();
|
||||
if(!$data or !isset($data->status)) return $this->send400('error');
|
||||
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
|
||||
|
||||
$plan = $data->data->plan;
|
||||
$plan->stories = $data->data->planStories;
|
||||
$plan->bugs = $data->data->planBugs;
|
||||
|
||||
$plan = $this->format($plan, 'begin:date,end:date,deleted:bool,stories:array,bugs:array');
|
||||
|
||||
return $this->send(200, $plan);
|
||||
}
|
||||
|
||||
$this->sendError(400, array('message' => isset($data->message) ? $data->message : 'error'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* The productplanlinkstory entry point of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2021 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
|
||||
* @package entries
|
||||
* @version 1
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
class productplanLinkStoryEntry extends entry
|
||||
{
|
||||
/**
|
||||
* POST method.
|
||||
*
|
||||
* @param int $planID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function post($planID)
|
||||
{
|
||||
$fields = 'stories';
|
||||
$this->batchSetPost($fields);
|
||||
|
||||
$control = $this->loadController('productplan', 'linkStory');
|
||||
$control->linkStory($planID);
|
||||
|
||||
$data = $this->getData();
|
||||
if(isset($data->result) and $data->result == 'success')
|
||||
{
|
||||
$control = $this->loadController('productplan', 'view');
|
||||
$control->view($planID);
|
||||
|
||||
$data = $this->getData();
|
||||
if(!$data or !isset($data->status)) return $this->send400('error');
|
||||
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
|
||||
|
||||
$plan = $data->data->plan;
|
||||
$plan->stories = $data->data->planStories;
|
||||
$plan->bugs = $data->data->planBugs;
|
||||
|
||||
$plan = $this->format($plan, 'begin:date,end:date,deleted:bool,stories:array,bugs:array');
|
||||
|
||||
return $this->send(200, $plan);
|
||||
}
|
||||
|
||||
$this->sendError(400, array('message' => isset($data->message) ? $data->message : 'error'));
|
||||
}
|
||||
}
|
||||
@@ -57,4 +57,34 @@ class productplansEntry extends entry
|
||||
|
||||
return $this->sendError(400, 'error');
|
||||
}
|
||||
|
||||
/**
|
||||
* POST method.
|
||||
*
|
||||
* @param int $productID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function post($productID = 0)
|
||||
{
|
||||
if(!$productID) $productID = $this->param('product', 0);
|
||||
if(!$productID) return $this->sendError(400, 'No product id.');
|
||||
|
||||
$fields = 'branch,begin,end,title,desc';
|
||||
$this->batchSetPost($fields);
|
||||
|
||||
$control = $this->loadController('productplan', 'create');
|
||||
$control->create($productID, $this->param('branch', 0), $this->param('parent', 0));
|
||||
|
||||
$data = $this->getData();
|
||||
if(isset($data->result) and $data->result == 'success')
|
||||
{
|
||||
$plan = $this->loadModel('productplan')->getByID($data->id);
|
||||
$plan->stories = array();
|
||||
$plan->bugs = array();
|
||||
return $this->send(200, $plan);
|
||||
}
|
||||
|
||||
$this->sendError(400, array('message' => isset($data->message) ? $data->message : 'error'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* The productplanunlinkbug entry point of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2021 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
|
||||
* @package entries
|
||||
* @version 1
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
class productplanUnlinkBugEntry extends entry
|
||||
{
|
||||
/**
|
||||
* POST method.
|
||||
*
|
||||
* @param int $planID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function post($planID)
|
||||
{
|
||||
$productplan = $this->loadModel('productplan');
|
||||
foreach($this->request('bugs', array()) as $bugID)
|
||||
{
|
||||
$productplan->unlinkBug($bugID, $planID);
|
||||
if(dao::isError()) return $this->sendError('error');
|
||||
}
|
||||
|
||||
$control = $this->loadController('productplan', 'view');
|
||||
$control->view($planID);
|
||||
|
||||
$data = $this->getData();
|
||||
if(!$data or !isset($data->status)) return $this->send400('error');
|
||||
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
|
||||
|
||||
$plan = $data->data->plan;
|
||||
$plan->stories = $data->data->planStories;
|
||||
$plan->bugs = $data->data->planBugs;
|
||||
|
||||
$plan = $this->format($plan, 'begin:date,end:date,deleted:bool,stories:array,bugs:array');
|
||||
|
||||
return $this->send(200, $plan);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* The productplanunlinkstory entry point of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2021 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
|
||||
* @package entries
|
||||
* @version 1
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
class productplanUnlinkStoryEntry extends entry
|
||||
{
|
||||
/**
|
||||
* POST method.
|
||||
*
|
||||
* @param int $planID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function post($planID)
|
||||
{
|
||||
$productplan = $this->loadModel('productplan');
|
||||
foreach($this->request('stories', array()) as $storyID)
|
||||
{
|
||||
$productplan->unlinkStory($storyID, $planID);
|
||||
if(dao::isError()) return $this->sendError('error');
|
||||
}
|
||||
|
||||
$control = $this->loadController('productplan', 'view');
|
||||
$control->view($planID);
|
||||
|
||||
$data = $this->getData();
|
||||
if(!$data or !isset($data->status)) return $this->send400('error');
|
||||
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
|
||||
|
||||
$plan = $data->data->plan;
|
||||
$plan->stories = $data->data->planStories;
|
||||
$plan->bugs = $data->data->planBugs;
|
||||
|
||||
$plan = $this->format($plan, 'begin:date,end:date,deleted:bool,stories:array,bugs:array');
|
||||
|
||||
return $this->send(200, $plan);
|
||||
}
|
||||
}
|
||||
+7
-3
@@ -23,9 +23,13 @@ $routes['/products/:id'] = 'product';
|
||||
$routes['/productlines'] = 'productLines';
|
||||
$routes['/productlines/:id'] = 'productLine';
|
||||
|
||||
$routes['/productplans'] = 'productPlans';
|
||||
$routes['/products/:id/plans'] = 'productPlans';
|
||||
$routes['/productplans/:id'] = 'productPlan';
|
||||
$routes['/productplans'] = 'productPlans';
|
||||
$routes['/products/:id/plans'] = 'productPlans';
|
||||
$routes['/productplans/:id'] = 'productPlan';
|
||||
$routes['/productplans/:id/linkstory'] = 'productPlanLinkStory';
|
||||
$routes['/productplans/:id/unlinkstory'] = 'productPlanUnlinkStory';
|
||||
$routes['/productplans/:id/linkbug'] = 'productPlanLinkBug';
|
||||
$routes['/productplans/:id/unlinkbug'] = 'productPlanUnlinkBug';
|
||||
|
||||
$routes['/releases'] = 'releases';
|
||||
$routes['/products/:id/releases'] = 'releases';
|
||||
|
||||
@@ -576,43 +576,47 @@ class baseEntry
|
||||
{
|
||||
switch($type)
|
||||
{
|
||||
case 'time':
|
||||
$timeFormat = $this->param('timeFormat', 'utc');
|
||||
if($timeFormat == 'utc')
|
||||
{
|
||||
if(!$value or $value == '0000-00-00 00:00:00') return null;
|
||||
return gmdate("Y-m-d\TH:i:s\Z", strtotime($value));
|
||||
}
|
||||
return $value;
|
||||
case 'date':
|
||||
if(!$value or $value == '0000-00-00') return null;
|
||||
return $value;
|
||||
case 'bool':
|
||||
return !empty($value);
|
||||
case 'int':
|
||||
return (int) $value;
|
||||
case 'idList':
|
||||
$values = explode(',', $value);
|
||||
if(empty($values)) return array();
|
||||
case 'time':
|
||||
$timeFormat = $this->param('timeFormat', 'utc');
|
||||
if($timeFormat == 'utc')
|
||||
{
|
||||
if(!$value or $value == '0000-00-00 00:00:00') return null;
|
||||
return gmdate("Y-m-d\TH:i:s\Z", strtotime($value));
|
||||
}
|
||||
return $value;
|
||||
case 'date':
|
||||
if(!$value or $value == '0000-00-00') return null;
|
||||
return $value;
|
||||
case 'bool':
|
||||
return !empty($value);
|
||||
case 'int':
|
||||
return (int) $value;
|
||||
case 'idList':
|
||||
$values = explode(',', $value);
|
||||
if(empty($values)) return array();
|
||||
|
||||
$idList = array();
|
||||
foreach($values as $val)
|
||||
{
|
||||
if($val !== '') $idList[] = (int) $val;
|
||||
}
|
||||
return $idList;
|
||||
case 'stringList':
|
||||
$values = explode(',', $value);
|
||||
if(empty($values)) return array();
|
||||
$idList = array();
|
||||
foreach($values as $val)
|
||||
{
|
||||
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;
|
||||
$stringList = array();
|
||||
foreach($values as $val)
|
||||
{
|
||||
if($val !== '') $stringList[] = $val;
|
||||
}
|
||||
return $stringList;
|
||||
case 'array':
|
||||
$array = array();
|
||||
if(!empty($value)) foreach($value as $v) $array[] = $v;
|
||||
return $array;
|
||||
default:
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -394,6 +394,7 @@ class productplan extends control
|
||||
if(!empty($_POST['stories']))
|
||||
{
|
||||
$this->productplan->linkStory($planID);
|
||||
if($this->viewType == 'json') return $this->send(array('result' => 'success'));
|
||||
die(js::locate(inlink('view', "planID=$planID&type=story&orderBy=$orderBy"), 'parent'));
|
||||
}
|
||||
|
||||
@@ -531,6 +532,7 @@ class productplan extends control
|
||||
if(!empty($_POST['bugs']))
|
||||
{
|
||||
$this->productplan->linkBug($planID);
|
||||
if($this->viewType == 'json') return $this->send(array('result' => 'success'));
|
||||
die(js::locate(inlink('view', "planID=$planID&type=bug&orderBy=$orderBy"), 'parent'));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user