From ac6f3f52014b2cf3d417af14033db0a0df4c35dc Mon Sep 17 00:00:00 2001 From: holan20180123 <56391770@qq.com> Date: Wed, 12 May 2021 16:33:35 +0800 Subject: [PATCH] * Return id when create object by API. --- module/job/control.php | 3 ++- module/job/model.php | 30 +++++++++++++++--------------- module/product/control.php | 1 + module/productplan/control.php | 1 + module/program/control.php | 5 +++-- module/projectrelease/control.php | 2 ++ 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/module/job/control.php b/module/job/control.php index 0413a49e89..cc5ab162b0 100644 --- a/module/job/control.php +++ b/module/job/control.php @@ -63,8 +63,9 @@ class job extends control { if($_POST) { - $this->job->create(); + $jobID = $this->job->create(); 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' => $jobID)); $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse'))); } diff --git a/module/job/model.php b/module/job/model.php index 4c7c8f7a63..5d19e6c298 100644 --- a/module/job/model.php +++ b/module/job/model.php @@ -12,9 +12,9 @@ class jobModel extends model { /** - * Get by id. - * - * @param int $id + * Get by id. + * + * @param int $id * @access public * @return object */ @@ -25,7 +25,7 @@ class jobModel extends model /** * Get job list. - * + * * @param string $orderBy * @param object $pager * @access public @@ -44,7 +44,7 @@ class jobModel extends model /** * Get list by triggerType field. - * + * * @param string $triggerType * @param array $repoIdList * @access public @@ -107,7 +107,7 @@ class jobModel extends model /** * Create a job. - * + * * @access public * @return bool */ @@ -164,13 +164,13 @@ class jobModel extends model $id = $this->dao->lastInsertId(); $this->initJob($id, $job, $this->post->repoType); - return true; + return $id; } /** * Update a job. - * - * @param int $id + * + * @param int $id * @access public * @return bool */ @@ -236,10 +236,10 @@ class jobModel extends model /** * Init when create or update job. - * - * @param int $id - * @param object $job - * @param string $repoType + * + * @param int $id + * @param object $job + * @param string $repoType * @access public * @return bool */ @@ -281,8 +281,8 @@ class jobModel extends model /** * Exec job. - * - * @param int $id + * + * @param int $id * @access public * @return bool */ diff --git a/module/product/control.php b/module/product/control.php index 8aa6058300..7146d7157b 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -321,6 +321,7 @@ class product extends control $this->loadModel('action')->create('product', $productID, 'opened'); $this->executeHooks($productID); + if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $productID)); $openApp = $this->app->openApp; $moduleName = $openApp == 'program'? 'program' : $this->moduleName; diff --git a/module/productplan/control.php b/module/productplan/control.php index c1ad06ae9b..3a54d382f2 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -54,6 +54,7 @@ class productplan extends control $this->executeHooks($planID); + if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $planID)); if(isonlybody()) $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => 'parent.refreshPlan()')); $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('productplan', 'browse', "productID=$productID&branch=$branchID"))); } diff --git a/module/program/control.php b/module/program/control.php index b9c7e7be63..08d9c34aaf 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -124,10 +124,11 @@ class program extends control if($_POST) { - $projectID = $this->program->create(); + $programID = $this->program->create(); 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' => $programID)); - $this->loadModel('action')->create('program', $projectID, 'opened'); + $this->loadModel('action')->create('program', $programID, 'opened'); $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse'))); } diff --git a/module/projectrelease/control.php b/module/projectrelease/control.php index 49798c600d..5c677f310c 100644 --- a/module/projectrelease/control.php +++ b/module/projectrelease/control.php @@ -108,6 +108,8 @@ 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)); + $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('view', "releaseID=$releaseID"))); }