From c8825383bc41f93f34279e7c65911083b9b40df2 Mon Sep 17 00:00:00 2001 From: liugang Date: Wed, 13 Sep 2023 10:38:15 +0800 Subject: [PATCH] + testtaskModel: add method to batch assign cases in a testtask. --- module/testtask/model.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/module/testtask/model.php b/module/testtask/model.php index 918215e9c7..bba0e33f23 100755 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -987,6 +987,32 @@ class testtaskModel extends model return !dao::isError(); } + /** + * 批量指派一个测试单中的用例。 + * Batch assign cases in a testtask. + * + * @param int $taskID + * @param string $account + * @param array $caseIdList + * @access public + * @return bool + */ + public function batchAssign(int $taskID, string $account, array $caseIdList): bool + { + if(!$taskID || !$account || !$caseIdList) return false; + + $cases = $this->dao->select('`case`')->from(TABLE_TESTRUN)->where('task')->eq($taskID)->andWhere('`case`')->in($caseIdList)->fetchPairs(); + if(!$cases) return false; + + $this->dao->update(TABLE_TESTRUN)->set('assignedTo')->eq($account)->where('task')->eq($taskID)->andWhere('`case`')->in($cases)->exec(); + if(dao::isError()) return false; + + $this->loadModel('action'); + foreach($cases as $caseID) $this->action->create('case', $caseID, 'assigned', '', $account); + + return !dao::isError(); + } + /** * Get test runs of a test task. *