* Return id when create object by api.

This commit is contained in:
holan20180123
2021-05-12 15:23:13 +08:00
parent 0d83fa5a31
commit 9fd362073f
4 changed files with 31 additions and 21 deletions

View File

@@ -12,9 +12,9 @@
class branch extends control
{
/**
* Manage branch
*
* @param int $productID
* Manage branch
*
* @param int $productID
* @access public
* @return void
*/
@@ -24,7 +24,8 @@ class branch extends control
if($_POST)
{
$this->branch->manage($productID);
$newBranches = $this->branch->manage($productID);
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'idList' => $newBranches));
die(js::reload('parent'));
}
@@ -40,7 +41,7 @@ class branch extends control
/**
* Sort branch.
*
*
* @access public
* @return void
*/
@@ -51,12 +52,12 @@ class branch extends control
/**
* Ajax get drop menu.
*
* @param int $productID
*
* @param int $productID
* @param int $branch
* @param string $module
* @param string $method
* @param string $extra
* @param string $module
* @param string $method
* @param string $extra
* @access public
* @return void
*/
@@ -77,10 +78,10 @@ class branch extends control
}
/**
* Delete branch
*
* @param int $branchID
* @param string $confirm
* Delete branch
*
* @param int $branchID
* @param string $confirm
* @access public
* @return void
*/
@@ -100,9 +101,9 @@ class branch extends control
/**
* Ajax get branches.
*
* @param int $productID
* @param int $oldBranch
*
* @param int $productID
* @param int $oldBranch
* @access public
* @return void
*/

View File

@@ -98,7 +98,8 @@ class branchModel extends model
public function manage($productID)
{
$oldBranches = $this->getPairs($productID, 'noempty');
$data = fixer::input('post')->get();
$data = fixer::input('post')->get();
if(isset($data->branch))
{
foreach($data->branch as $branchID => $branch)
@@ -106,13 +107,17 @@ class branchModel extends model
if($oldBranches[$branchID] != $branch) $this->dao->update(TABLE_BRANCH)->set('name')->eq($branch)->where('id')->eq($branchID)->exec();
}
}
$branches = array();
foreach($data->newbranch as $i => $branch)
{
if(empty($branch)) continue;
$this->dao->insert(TABLE_BRANCH)->set('name')->eq($branch)->set('product')->eq($productID)->set('`order`')->eq(count($data->branch) + $i + 1)->exec();
$branches[] = $this->dao->lastInsertId();
}
return dao::isError();
if(dao::isError()) return false;
return $branches;
}
/**

View File

@@ -27,7 +27,8 @@ class groupModel extends model
unset($group->limited);
$group->role = 'limited';
}
return $this->dao->insert(TABLE_GROUP)->data($group)->batchCheck($this->config->group->create->requiredFields, 'notempty')->exec();
$this->dao->insert(TABLE_GROUP)->data($group)->batchCheck($this->config->group->create->requiredFields, 'notempty')->exec();
return $this->dao->lastInsertId();
}
/**

View File

@@ -299,6 +299,8 @@ class project extends control
}
}
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $projectID));
if($this->app->openApp == 'program')
{
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('program', 'browse')));
@@ -612,8 +614,9 @@ class project extends control
if(!empty($_POST))
{
$_POST['project'] = $projectID;
$this->group->create();
$groupID = $this->group->create();
if(dao::isError()) die(js::error(dao::getError()));
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $groupID));
die(js::closeModal('parent.parent'));
}