* Add an interface to query builds for block module.
This commit is contained in:
@@ -829,4 +829,25 @@ class buildModel extends model
|
||||
|
||||
return $menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为区块获取版本数据。
|
||||
* Get build's data for block.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param string $orderBy
|
||||
* @param int $limit
|
||||
* @access public
|
||||
* @return object[]
|
||||
*/
|
||||
public function getBuildBlockData(int $projectID = 0, string $orderBy = 'id_desc', int $limit = 10): array
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_BUILD)
|
||||
->where('deleted')->eq('0')
|
||||
->beginIF(!$this->app->user->admin)->andWhere('execution')->in($this->app->user->view->sprints)->fi()
|
||||
->beginIF($projectID)->andWhere('project')->eq($projectID)->fi()
|
||||
->orderBy($orderBy)
|
||||
->limit($limit)
|
||||
->fetchAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,4 +428,26 @@ class buildTest
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get build's data for block.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param string $orderBy
|
||||
* @param int $limit
|
||||
* @param bool $adminUser
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getBuildBlockDataTest(int $projectID = 0, string $orderBy = 'id_desc', int $limit = 10, bool $adminUser = true): array
|
||||
{
|
||||
global $tester;
|
||||
|
||||
if(!$adminUser) $tester->app->user->admin = false;
|
||||
|
||||
$build = $this->objectModel->getBuildBlockData($projectID, $orderBy, $limit);
|
||||
if(!$adminUser) $tester->app->user->admin = true;
|
||||
|
||||
return $build;
|
||||
}
|
||||
}
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/build.class.php';
|
||||
su('admin');
|
||||
|
||||
zdTable('project')->config('project')->gen(20);
|
||||
zdTable('build')->config('build')->gen(20);
|
||||
zdTable('userview')->config('userview')->gen(2);
|
||||
|
||||
/**
|
||||
|
||||
title=测试buildModel->getBuildBlockData();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
|
||||
*/
|
||||
|
||||
$build = new buildTest();
|
||||
|
||||
r(count($build->getBuildBlockDataTest(2))) && p('') && e('2'); // 管理员获取项目ID为2的版本总数
|
||||
r(count($build->getBuildBlockDataTest(2, 'id_desc', 10, false))) && p('') && e('1'); // 非管理员获取项目ID为2的版本总数
|
||||
r(count($build->getBuildBlockDataTest(10, 'id_desc', 10))) && p('') && e('1'); // 管理员获取项目ID为10且不包括已删除版本的版本总数
|
||||
r(count($build->getBuildBlockDataTest(0, 'id_desc', 15))) && p('') && e('15'); // 管理员获取前15条记录的总数
|
||||
r($build->getBuildBlockDataTest(8, 'id_asc')) && p('0:name') && e('项目8版本8'); // 管理员获取项目为8的版本列表,按照id升序
|
||||
@@ -0,0 +1,32 @@
|
||||
title: table zt_build
|
||||
author: Hu Fangzhou
|
||||
desc: ""
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
range: 1-20
|
||||
|
||||
- field: project
|
||||
range: 1-10
|
||||
|
||||
- field: product
|
||||
range: 1-10
|
||||
|
||||
- field: execution
|
||||
range: 10-20
|
||||
|
||||
- field: name
|
||||
fields:
|
||||
- field: name1
|
||||
range: 项目{10},执行{10}
|
||||
|
||||
- field: name2
|
||||
range: 1-10,11-20
|
||||
|
||||
- field: name3
|
||||
range: 版本
|
||||
|
||||
- field: name4
|
||||
range: 1-20
|
||||
- field: deleted
|
||||
range: 0{19},1
|
||||
@@ -0,0 +1,31 @@
|
||||
title: table zt_project
|
||||
author: Hu Fangzhou
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
range: 1-20
|
||||
- field: name
|
||||
note: "名称"
|
||||
fields:
|
||||
- field: name1
|
||||
range: 项目{10},执行{10}
|
||||
- field: name2
|
||||
range: 1-10{2}
|
||||
- field: project
|
||||
range: 0{10},1{3},2{2},4{3},6{2}
|
||||
- field: type
|
||||
range: project{10},sprint{4},stage{3},kanban{3}
|
||||
- field: lifetime
|
||||
range: "[]{10},short{2},long{1},ops{1},[]{6}"
|
||||
- field: attribute
|
||||
range: "[]{14},request,review,dev,[]{3}"
|
||||
- field: begin
|
||||
range: "20220101 000000:3M"
|
||||
type: timestamp
|
||||
format: "YY/MM/DD"
|
||||
- field: end
|
||||
range: "20230101 000000:1M"
|
||||
type: timestamp
|
||||
format: "YY/MM/DD"
|
||||
- field: vision
|
||||
range: rnd
|
||||
@@ -0,0 +1,32 @@
|
||||
title: table zt_userview
|
||||
desc: "可访问权限"
|
||||
author: Hu Fangzhou
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: account
|
||||
note: "用户名"
|
||||
range: admin,dev1
|
||||
- field: programs
|
||||
note: "项目集"
|
||||
range: 0
|
||||
prefix: ","
|
||||
postfix: ""
|
||||
format: ""
|
||||
- field: products
|
||||
note: "产品"
|
||||
range: "`1,3,5,7`,`2,4,6,8`"
|
||||
prefix: ","
|
||||
postfix: ""
|
||||
format: ""
|
||||
- field: projects
|
||||
note: "项目"
|
||||
range: "`1,3,5,7`,`2,4,6,8`"
|
||||
prefix: ","
|
||||
postfix: ""
|
||||
format: ""
|
||||
- field: sprints
|
||||
note: "迭代"
|
||||
range: "`11,13,15,17`,`12,14,16,18`"
|
||||
prefix: ","
|
||||
postfix: ""
|
||||
format: ""
|
||||
@@ -1,4 +1,5 @@
|
||||
title: table zt_build
|
||||
author: system
|
||||
desc: ""
|
||||
version: "1.0"
|
||||
fields:
|
||||
@@ -34,16 +35,16 @@ fields:
|
||||
- field: scmPath
|
||||
fields:
|
||||
- field: scmPath1
|
||||
range: [gitlab.zcorp.cc/easycorp/,svn.zcorp.cc/easysoft/trunk/zentaoext/]{3},[]{2}
|
||||
range: "[gitlab.zcorp.cc/easycorp/,svn.zcorp.cc/easysoft/trunk/zentaoext/]{3},[]{2}"
|
||||
|
||||
- field: scmPath2
|
||||
range: zentaopms,xuanxuan,zdoo,zentaopro,zentaobiz,zentaomax,[]{2}
|
||||
|
||||
- field: scmPath3
|
||||
range: [.git]{3},[]{5}
|
||||
range: "[.git]{3},[]{5}"
|
||||
|
||||
- field: filePath
|
||||
range: [www.csdn.net/,www.baidu.com/,www.juejin.cn/]{2},[]{2}
|
||||
range: "[www.csdn.net/,www.baidu.com/,www.juejin.cn/]{2},[]{2}"
|
||||
|
||||
- field: date
|
||||
range: "(-1M)-(+1w):60"
|
||||
|
||||
Reference in New Issue
Block a user