* Return id when create object by API.

This commit is contained in:
holan20180123
2021-05-12 17:00:26 +08:00
parent ac6f3f5201
commit 49e9302c31
9 changed files with 33 additions and 17 deletions
+1 -1
View File
@@ -108,7 +108,7 @@ class projectrelease extends control
$this->loadModel('action')->create('release', $releaseID, 'opened');
$this->executeHooks($releaseID);
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $releaseID));
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $releaseID));
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('view', "releaseID=$releaseID")));
}
+1
View File
@@ -70,6 +70,7 @@ class release extends control
$this->executeHooks($releaseID);
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $releaseID));
if(isonlybody()) $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => "parent.loadProductBuilds($productID)"));
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('view', "releaseID=$releaseID")));
}
+1
View File
@@ -119,6 +119,7 @@ class repo extends control
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $repoID));
$link = $this->repo->createLink('showSyncCommit', "repoID=$repoID&objectID=$objectID", '', false);
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $link));
}
+1
View File
@@ -280,6 +280,7 @@ class sso extends control
if($_POST)
{
$result = $this->sso->createUser();
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $result['id']));
if($result['status'] != 'success') die($result['data']);
die('success');
}
+10 -10
View File
@@ -3,7 +3,7 @@ class ssoModel extends model
{
/**
* Check Key.
*
*
* @access public
* @return bool
*/
@@ -16,8 +16,8 @@ class ssoModel extends model
/**
* Get bind user.
*
* @param string $user
*
* @param string $user
* @access public
* @return object
*/
@@ -28,7 +28,7 @@ class ssoModel extends model
/**
* Get bind users with ranzhi.
*
*
* @access public
* @return array
*/
@@ -38,8 +38,8 @@ class ssoModel extends model
}
/**
* Bind user.
*
* Bind user.
*
* @access public
* @return object
*/
@@ -83,14 +83,14 @@ class ssoModel extends model
/**
* Create a user from ranzhi.
*
*
* @access public
* @return void
*/
public function createUser()
{
$user = $this->dao->select('*')->from(TABLE_USER)->where('account')->eq($this->post->account)->fetch();
if($user) return array('status' => 'fail', 'data' => $this->lang->sso->bindHasAccount);
if($user) return array('status' => 'fail', 'data' => $this->lang->sso->bindHasAccount);
$user = new stdclass();
$user->account = $this->post->account;
@@ -101,7 +101,7 @@ class ssoModel extends model
$this->dao->insert(TABLE_USER)->data($user)->autoCheck()->exec();
if(dao::isError()) return array('status' => 'fail', 'data' => dao::getError());
return array('status' => 'success');
if(dao::isError()) return array('status' => 'fail', 'data' => dao::getError());
return array('status' => 'success', 'id' => $this->dao->lastInsertId());
}
}
+3 -1
View File
@@ -61,6 +61,7 @@ class stakeholder extends control
}
$actionID = $this->loadModel('action')->create('stakeholder', $stakeholderID, 'added');
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $stakeholderID));
$moduleName = $this->app->openApp == 'program' ? 'program' : $this->moduleName;
$methodName = $this->app->openApp == 'program' ? 'stakeholder' : 'browse';
@@ -102,7 +103,8 @@ class stakeholder extends control
{
if($_POST)
{
$this->stakeholder->batchCreate();
$stakeholderList = $this->stakeholder->batchCreate();
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'idList' => $stakeholderList));
die(js::locate($this->createLink('stakeholder', 'browse', "projectID=$projectID"), 'parent'));
}
+6 -2
View File
@@ -104,7 +104,7 @@ class stakeholderModel extends model
* Batch create stakeholders for a project.
*
* @access public
* @return void
* @return array
*/
public function batchCreate()
{
@@ -116,6 +116,7 @@ class stakeholderModel extends model
$oldJoin = $this->dao->select('`user`, createdDate')->from(TABLE_STAKEHOLDER)->where('objectID')->eq((int)$this->session->project)->andWhere('objectType')->eq('project')->fetchPairs();
$this->dao->delete()->from(TABLE_STAKEHOLDER)->where('objectID')->eq((int)$this->session->project)->andWhere('objectType')->eq('project')->exec();
$stakeholderList = array();
foreach($accounts as $key => $account)
{
if(empty($account)) continue;
@@ -130,7 +131,8 @@ class stakeholderModel extends model
$this->dao->insert(TABLE_STAKEHOLDER)->data($stakeholder)->exec();
$stakeholderID = $this->dao->lastInsertId();
$stakeholderID = $this->dao->lastInsertId();
$stakeholderList[] = $stakeholderID;
$this->action->create('stakeholder', $stakeholderID, 'added');
}
@@ -141,6 +143,8 @@ class stakeholderModel extends model
$changedAccounts = array_unique($changedAccounts);
$this->loadModel('user')->updateUserView($this->session->project, 'project', $changedAccounts);
return $stakeholderList;
}
/**
+5 -1
View File
@@ -146,6 +146,8 @@ class story extends control
$this->executeHooks($storyID);
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $storyID));
/* If link from no head then reload. */
if(isonlybody()) $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent'));
@@ -404,6 +406,7 @@ class story extends control
if(dao::isError()) die(js::error(dao::getError()));
}
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'idList' => $stories));
if(isonlybody()) die(js::closeModal('parent.parent', 'this'));
if($storyID)
@@ -1274,7 +1277,7 @@ class story extends control
$response['result'] = 'success';
$response['message'] = $this->lang->story->successToTask;
$this->story->batchToTask($executionID, $this->session->project);
$tasks = $this->story->batchToTask($executionID, $this->session->project);
if(dao::isError())
{
@@ -1283,6 +1286,7 @@ class story extends control
$this->send($response);
}
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'idList' => $tasks));
$response['locate'] = $this->createLink('execution', 'task', "executionID=$executionID");
$this->send($response);
}
+5 -2
View File
@@ -1564,7 +1564,7 @@ class storyModel extends model
* @param int $executionID
* @param int $projectID
* @access public
* @return bool
* @return bool|array
*/
public function batchToTask($executionID, $projectID = 0)
{
@@ -1590,6 +1590,7 @@ class storyModel extends model
if(dao::isError()) return false;
/* Create tasks. */
$tasks = array();
$stories = $this->getByList($data->storyIdList);
foreach($stories as $story)
{
@@ -1627,9 +1628,11 @@ class storyModel extends model
->exec();
if(dao::isError()) return false;
$taskID = $this->dao->lastInsertID();
$taskID = $this->dao->lastInsertID();
$tasks[] = $taskID;
$this->action->create('task', $taskID, 'Opened', '');
}
return $tasks;
}
/**