diff --git a/module/release/control.php b/module/release/control.php index 4c7ca8d1ad..d0e9ba835b 100644 --- a/module/release/control.php +++ b/module/release/control.php @@ -490,6 +490,7 @@ class release extends control } /** + * 批量解除发布跟需求的关联。 * Batch unlink story. * * @param int $releaseID @@ -498,7 +499,7 @@ class release extends control */ public function batchUnlinkStory(int $releaseID) { - $this->release->batchUnlinkStory($releaseID); + $this->release->batchUnlinkStory($releaseID, (array)$this->post->storyIdList); return $this->sendSuccess(array('load' => $this->createLink($this->app->rawModule, 'view', "releaseID={$releaseID}&type=story"))); } diff --git a/module/release/model.php b/module/release/model.php index ce3955c472..c9e326d18f 100644 --- a/module/release/model.php +++ b/module/release/model.php @@ -496,25 +496,30 @@ class releaseModel extends model } /** + * 批量解除发布跟需求的关联。 * Batch unlink story. * * @param int $releaseID + * @param array $storyIdList * @access public - * @return void + * @return bool */ - public function batchUnlinkStory($releaseID) + public function batchUnlinkStory(int $releaseID, array $storyIdList): bool { - $storyList = $this->post->storyIdList; - if(empty($storyList)) return true; + if(empty($storyIdList)) return true; $release = $this->getByID($releaseID); + if(!$release) return false; + $release->stories = ",$release->stories,"; - foreach($storyList as $storyID) $release->stories = str_replace(",$storyID,", ',', $release->stories); + foreach($storyIdList as $storyID) $release->stories = str_replace(",$storyID,", ',', $release->stories); $release->stories = trim($release->stories, ','); $this->dao->update(TABLE_RELEASE)->set('stories')->eq($release->stories)->where('id')->eq((int)$releaseID)->exec(); $this->loadModel('action'); - foreach($this->post->storyIdList as $unlinkStoryID) $this->action->create('story', $unlinkStoryID, 'unlinkedfromrelease', '', $releaseID); + foreach($storyIdList as $unlinkStoryID) $this->action->create('story', $unlinkStoryID, 'unlinkedfromrelease', '', $releaseID); + + return !dao::isError(); } /**