* Return id when create object by API.

This commit is contained in:
holan20180123
2021-05-12 16:03:12 +08:00
parent c5dd642138
commit c5ac6e1bbe
5 changed files with 52 additions and 41 deletions

View File

@@ -70,7 +70,8 @@ class dept extends control
{
if(!empty($_POST))
{
$this->dept->manageChild($_POST['parentDeptID'], $_POST['depts']);
$deptIDList = $this->dept->manageChild($_POST['parentDeptID'], $_POST['depts']);
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'idList' => $deptIDList));
die(js::reload('parent'));
}
}

View File

@@ -318,7 +318,7 @@ class deptModel extends model
* @param int $parentDeptID
* @param string $childs
* @access public
* @return void
* @return array
*/
public function manageChild($parentDeptID, $childs)
{
@@ -335,17 +335,20 @@ class deptModel extends model
}
$i = 1;
$deptIDList = array();
foreach($childs as $deptID => $deptName)
{
if(empty($deptName)) continue;
if(is_numeric($deptID))
{
$dept = new stdclass();
$dept->name = strip_tags($deptName);
$dept->parent = $parentDeptID;
$dept->grade = $grade;
$dept->order = $this->post->maxOrder + $i * 10;
$this->dao->insert(TABLE_DEPT)->data($dept)->exec();
$deptID = $this->dao->lastInsertID();
$deptIDList[] = $deptID;
$childPath = $parentPath . "$deptID,";
$this->dao->update(TABLE_DEPT)->set('path')->eq($childPath)->where('id')->eq($deptID)->exec();
$i++;
@@ -356,6 +359,8 @@ class deptModel extends model
$this->dao->update(TABLE_DEPT)->set('name')->eq(strip_tags($deptName))->where('id')->eq($deptID)->exec();
}
}
return $deptIDList;
}
/**

View File

@@ -142,6 +142,7 @@ class doc extends control
$this->action->create('docLib', $libID, 'Created');
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $libID));
die(js::locate($this->createLink('doc', 'objectLibs', "type=$objectType&objectID=$objectID&libID=$libID"), 'parent.parent'));
}
else
@@ -288,6 +289,7 @@ class doc extends control
if(!empty($files)) $fileAction = $this->lang->addFiles . join(',', $files) . "\n" ;
$this->action->create('doc', $docID, 'Created', $fileAction);
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $docID));
$objectID = zget($lib, $lib->type, '');
$params = "type={$lib->type}&objectID=$objectID&libID={$lib->id}&docID=" . $docResult['id'];
$link = $this->createLink('doc', 'objectLibs', $params);

View File

@@ -49,6 +49,7 @@ class entry extends control
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
$this->loadModel('action')->create('entry', $id, 'created');
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $id));
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
}

View File

@@ -1287,6 +1287,8 @@ class execution extends control
$this->executeHooks($executionID);
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $executionID));
if($this->app->openApp == 'doc')
{
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('doc', 'objectLibs', "type=execution")));