+ Add fetchPairs method.

This commit is contained in:
tianshujie
2023-08-18 16:32:10 +08:00
parent d7efadc266
commit d409d45e5f
2 changed files with 71 additions and 0 deletions
+24
View File
@@ -1879,6 +1879,30 @@ class executionModel extends model
return $executionQuery;
}
/**
* 获取执行id=>name的键值对。
* Get an array of execution id:name.
*
* @param int $projectID
* @param string $type
* @param bool $filterMulti
* @param bool $queryAll
* @access public
* @return array
*/
public function fetchPairs($projectID = 0, $type = 'all', $filterMulti = true, $queryAll = false): array
{
return $this->dao->select('id,name')->from(TABLE_EXECUTION)
->where('deleted')->eq(0)
->andWhere('vision')->eq($this->config->vision)
->beginIF($projectID)->andWhere('project')->eq($projectID)->fi()
->beginIF($type == 'all')->andWhere('type')->in('stage,sprint,kanban')->fi()
->beginIF($type != 'all')->andWhere('type')->in($type)->fi()
->beginIF($filterMulti)->andWhere('multiple')->eq('1')->fi()
->beginIF(!$queryAll && !$this->app->user->admin)->andWhere('id')->in($this->app->user->view->sprints)->fi()
->fetchPairs();
}
/**
* 获取执行列表信息。
* Get execution list information.
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
zdTable('user')->gen(5);
su('admin');
zdTable('project')->config('execution', true)->gen(30);
/**
title=测试executionModel->fetchPairs();
timeout=0
cid=1
*/
$projectIdList = array(0, 11, 1);
$typeList = array('all', 'sprint', 'stage', 'kanban');
global $tester;
$executionModel = $tester->loadModel('execution');
$allExecutions = $executionModel->fetchPairs($projectIdList[0], $typeList[0], false, true);
$multipleExecutions = $executionModel->fetchPairs($projectIdList[0], $typeList[0], true, true);
$canViewExecutions = $executionModel->fetchPairs($projectIdList[0], $typeList[0], true, false);
$projectExecutions = $executionModel->fetchPairs($projectIdList[1], $typeList[0], true, false);
$notExistProjectExecutions = $executionModel->fetchPairs($projectIdList[2], $typeList[0], true, false);
$sprints = $executionModel->fetchPairs($projectIdList[0], $typeList[1], true, false);
$stages = $executionModel->fetchPairs($projectIdList[0], $typeList[2], true, false);
$kanbans = $executionModel->fetchPairs($projectIdList[0], $typeList[3], true, false);
r(count($allExecutions)) && p() && e('26'); // 获取系统内全部执行的数量
r(count($multipleExecutions)) && p() && e('24'); // 获取系统内全部非影子执行的数量
r(count($canViewExecutions)) && p() && e('24'); // 获取系统内全部有权限执行的数量
r(count($projectExecutions)) && p() && e('3'); // 获取敏捷项目下的执行的数量
r(count($notExistProjectExecutions)) && p() && e('0'); // 获取不存在项目下的执行的数量
r(count($sprints)) && p() && e('3'); // 获取系统内全部迭代的数量
r(count($stages)) && p() && e('18'); // 获取系统内全部阶段的数量
r(count($kanbans)) && p() && e('3'); // 获取系统内全部看板的数量
r($allExecutions) && p('101') && e('迭代5'); // 获取系统内全部执行
r($multipleExecutions) && p('101') && e('迭代5'); // 获取系统内全部非影子执行
r($canViewExecutions) && p('101') && e('迭代5'); // 获取系统内全部有权限执行
r($projectExecutions) && p('101') && e('迭代5'); // 获取敏捷项目下的执行
r($notExistProjectExecutions) && p() && e('0'); // 获取敏捷项目下的执行
r($sprints) && p('101') && e('迭代5'); // 获取系统内全部迭代
r($stages) && p('106') && e('阶段10'); // 获取系统内全部阶段
r($kanbans) && p('124') && e('看板28'); // 获取系统内全部看板