* Supply multiple config files.

This commit is contained in:
zhujinyong
2021-09-27 02:52:35 +08:00
parent eb04910243
commit e059381d7d
32 changed files with 1444 additions and 1747 deletions
+1 -1
View File
@@ -19,4 +19,4 @@ test/data/sql/
.DS_Store
vendor/
composer.lock
test/runtime/*
+4 -9
View File
@@ -1,11 +1,11 @@
title: moreDate
title: date
desc: 系统可用日期类型
author: ly
version: 1.0
field: moreDate
field: date
instances:
- instance: dateA
- instance: datetime
fields:
- field: year
range: 2019-2022
@@ -30,7 +30,7 @@ instances:
range: 0-59
format: "%02d"
- instance: dateB
- instance: date
fields:
- field: year
range: 2019-2022
@@ -42,8 +42,3 @@ instances:
- field: day
range: 1-27
format: "%02d"
- instance: dateC
fields:
- field: time
range: 1262275200-1893427200:R
+3 -2
View File
@@ -3,12 +3,13 @@ desc: 创建一些默认用户
author: ly
version: 1.0
field: user
instances:
- instance: user
note: 默认用户列表
fields:
- field: user
- field: account
range: admin,dev1,dev2,dev3,test1,test2,test3
- instance: userB
note: 逗号拼接用户
fields:
-4
View File
@@ -1,4 +0,0 @@
<?php
$config->dataRows = array();
$config->dataRows['zt_action'] = 1000;
$config->dataRows['zt_activity'] = 1000;
-75
View File
@@ -1,75 +0,0 @@
<?php
$dbms = 'mysql'; // 数据库类型。
$host = 'localhost'; // 数据库主机名。
$port = '3306'; // 数据库主机端口。
$dbName = 'zdata'; // 使用的数据库。
$user = 'root'; // 数据库连接用户名。
$password = 'root'; // 对应的密码。
$dsn = "$dbms:host=$host:$port;dbname=$dbName";
$dirPath = 'demo/story'; // 自定义数据的zdata文件路径。
/* 定义每个yaml文件生成SQL数量,自定义yaml文件名需和数据库表名对应。以下定义中键代表数据表名,值代表生成数量。*/
$zdataCount = array();
$zdataCount['zt_product'] = 100;
$zdataCount['zt_productplan'] = 500;
$zdataCount['zt_project'] = 100;
$zdataCount['zt_module'] = 1000;
$zdataCount['zt_story'] = 10000;
$zdataCount['zt_storyspec'] = 10000;
$zdataCount['zt_action'] = 10000;
$zdataExec = "zd -c $dirPath/%s -d %s -n %s -o $dirPath/sql/%s.sql -table %s";
set_time_limit(0);
try
{
$dbh = new PDO($dsn, $user, $password); // 初始化一个PDO对象。
echo $dbms . '连接成功' . PHP_EOL;
$yamlFilePath = scandir($dirPath);
foreach($yamlFilePath as $file)
{
if(strpos($file, '.yaml'))
{
$fileName = basename($file, '.yaml');
$count = isset($zdataCount[$fileName]) ? $zdataCount[$fileName] : 10;
$execYaml = sprintf($zdataExec, $file, $file, $count, $fileName, $fileName);
exec($execYaml); // 执行zdata命令调用yaml文件生成SQL数据。
echo '执行命令:' . $execYaml . PHP_EOL;
}
}
/* 读取生成的SQL文件,导入数据到数据库。*/
$sqlDir = $dirPath . '/sql/';
$sqlFilePath = scandir($sqlDir);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // 设置报错处理方式。
$dbh->exec("SET GLOBAL sql_mode = '';");
$dbh->exec("set names 'utf8'");
$dbh->beginTransaction();
foreach($sqlFilePath as $file)
{
if(strpos($file, '.sql'))
{
$tableName = basename($file, '.sql');
$truncate = 'truncate table ' . $tableName;
$dbh->exec($truncate);
$sql = file_get_contents($sqlDir . $file);
$count = $dbh->exec($sql);
echo $tableName . '表影响行数:' . $count . PHP_EOL;
}
}
$dbh->commit();
$dbh = null; // 关闭连接。
}
catch (PDOException $e)
{
die('Error!: ' . $e->getMessage() . PHP_EOL);
}
-13
View File
@@ -1,13 +0,0 @@
title: color
desc: 标题颜色
author: ly
version: 1.0
field: color
instances:
- instance: color
note: 标题颜色
fields:
- field: color
range: 3da7f5,75c941,2dbdb2,797ec9,ffaf38,ff4e3e
prefix: "#"
-49
View File
@@ -1,49 +0,0 @@
title: moreDate
desc: 系统可用日期类型
author: ly
version: 1.0
field: moreDate
instances:
- instance: dateA
fields:
- field: year
range: 2019-2022
postfix: "-"
- field: month
range: 1-12
format: "%02d"
postfix: "-"
- field: day
range: 1-27
format: "%02d"
postfix: " "
- field: hour
range: 0-23
format: "%02d"
postfix: ":"
- field: minute
range: 0-59
format: "%02d"
postfix: ":"
- field: second
range: 0-59
format: "%02d"
- instance: dateB
fields:
- field: year
range: 2019-2022
postfix: "-"
- field: month
range: 1-12
format: "%02d"
postfix: "-"
- field: day
range: 1-27
format: "%02d"
- instance: dateC
fields:
- field: time
range: 1262275200-1893427200:R
-60
View File
@@ -1,60 +0,0 @@
title: user
desc: 创建一些默认用户
author: ly
version: 1.0
instances:
- instance: user
note: 默认用户列表
fields:
- field: user
range: admin,dev1,dev2,dev3,test1,test2,test3
- instance: userB
note: 逗号拼接用户
fields:
- field: user1
range: admin
postfix: ","
- field: user2
range: dev1
postfix: ","
- field: user3
range: dev2
postfix: ","
- field: user4
range: dev3
postfix: ","
- field: user5
range: test1
postfix: ","
- field: user6
range: test2
postfix: ","
- field: user7
range: test3
- instance: userC
note: 前后逗号拼接用户
fields:
- field: user1
range: admin
prefix: ","
postfix: ","
- field: user2
range: dev1
postfix: ","
- field: user3
range: dev2
postfix: ","
- field: user4
range: dev3
postfix: ","
- field: user5
range: test1
postfix: ","
- field: user6
range: test2
postfix: ","
- field: user7
range: test3
postfix: ","
-14
View File
@@ -1,14 +0,0 @@
说明:
生成多个产品,为其添加计划、模块和需求。
数据:
生成100个产品,每个产品生成5个计划和10个模块,每个计划关联20个软件需求,每个模块分配5个用户需求,5个软件需求。
调用yaml:
zd -c demo/story/zt_product.yaml -d zt_product.yaml -n 100 -o demo/story/sql/zt_product.sql -table zt_product
zd -c demo/story/zt_productplan.yaml -n 500 -d zt_productplan.yaml -o demo/story/sql/zt_productplan.sql -table zt_productplan
zd -c demo/story/zt_project.yaml -d zt_project.yaml -n 100 -o demo/story/sql/zt_project.sql -table zt_project
zd -c demo/story/zt_module.yaml -d zt_module.yaml -n 1000 -o demo/story/sql/zt_module.sql -table zt_module
zd -c demo/story/zt_story.yaml -d zt_story.yaml -n 10000 -o demo/story/sql/zt_story.sql -table zt_story
zd -c demo/story/zt_storyspec.yaml -n 10000 -d zt_storyspec.yaml -o demo/story/sql/zt_storyspec.sql -table zt_storyspec
zd -c demo/story/zt_action.yaml -n 11700 -o demo/story/sql/zt_action.sql -table zt_action
-66
View File
@@ -1,66 +0,0 @@
title: table zt_action
desc: "系统日志"
author: automated export
version: "1.0"
fields:
- field: objectType
note: "对象类型"
range: product{100},project{100},module{1000},story{10000},productplan{500}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: objectID
note: "对象ID"
range: 1-100,1-100,1-1000,1-10000,1-500
prefix: ""
postfix: ""
loop: 0
format: ""
- field: product
note: "产品"
range: 1-100
prefix: ","
postfix: ","
loop: 0
format: ""
- field: project
note: "项目"
range: 1-100
prefix: ""
postfix: ""
loop: 0
format: ""
- field: actor
note: "操作者"
range: "admin"
prefix: ""
postfix: ""
loop: 0
format: ""
- field: action
note: "动作"
range: opened
postfix: ""
loop: 0
format: ""
- field: comment
note: "备注"
range: "1-10000"
prefix: "这是一个系统日志测试备注"
postfix: ""
loop: 0
format: ""
- field: extra
note: "附加参数"
range: "0"
prefix: ""
postfix: ""
loop: 0
- field: read
note: ""
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
-96
View File
@@ -1,96 +0,0 @@
title: table zt_module
desc: "模块"
author: automated export
version: "1.0"
fields:
- field: id
note: "ID"
range: 1-10000
prefix: ""
postfix: ""
loop: 0
format: ""
- field: root
note: "根目录"
range: 1-100{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: branch
note: "分支"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: name
note: "模块名称"
range: 1-10000
prefix: "需求模块"
postfix: ""
loop: 0
format: ""
- field: parent
note: "父ID"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: path
note: "ID路径"
range: 1-10000
prefix: ","
postfix: ","
loop: 0
format: ""
- field: grade
note: "等级"
range: 1
prefix: ""
postfix: ""
loop: 0
format: ""
- field: order
note: "排序"
range: 10-100:10
prefix: ""
postfix: ""
loop: 0
format: ""
- field: type
note: "对象类型"
range: story
prefix: ""
postfix: ""
loop: 0
format: ""
- field: owner
note: "所有者"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: collector
note: "收藏者"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: short
note: "模块简称"
range: 1-10000
prefix: "简称"
postfix: ""
loop: 0
format: ""
- field: deleted
note: "是否删除"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
-143
View File
@@ -1,143 +0,0 @@
title: table zt_product
desc: "产品"
author: automated export
version: "1.0"
fields:
- field: id
note: "ID"
range: 1-10000
prefix: ""
postfix: ""
loop: 0
format: ""
- field: program
note: "所属项目"
range: 1-10000
prefix: ""
postfix: ""
loop: 0
format: ""
- field: name
note: "产品名称"
range: 1-10000
prefix: "产品"
postfix: ""
loop: 0
format: ""
- field: code
note: "产品代号"
range: 1-10000
prefix: "code"
postfix: ""
loop: 0
format: ""
- field: line
note: "产品线"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: type
note: "产品类型"
range: normal
prefix: ""
postfix: ""
loop: 0
format: ""
- field: status
note: "状态"
range: normal
prefix: ""
postfix: ""
loop: 0
format: ""
- field: subStatus
note: "子状态"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: desc
note: "产品描述"
range: 1-10000
prefix: "这里是产品描述"
postfix: ""
loop: 0
format: ""
- field: PO
note: "产品负责人"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: QD
note: "测试负责人"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: RD
note: "发布负责人"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: acl
note: "访问控制"
range: open
prefix: ""
postfix: ""
loop: 0
format: ""
- field: whitelist
note: "分组白名单"
range: 1-10
prefix: ""
postfix: ""
loop: 0
format: ""
- field: createdBy
note: "创建者"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: createdDate
note: "创建日期"
from: common.date.v1.yaml
use: dateA
prefix: ""
postfix: ""
loop: 0
format: ""
- field: createdVersion
note: "创建版本"
range: 20.0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: order
note: "排序"
range: 5-10000:5
prefix: ""
postfix: ""
loop: 0
format: ""
- field: deleted
note: "是否删除"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
-77
View File
@@ -1,77 +0,0 @@
title: table zt_productplan
desc: "产品计划"
author: automated export
version: "1.0"
fields:
- field: id
note: "ID"
range: 1-10000
prefix: ""
postfix: ""
loop: 0
format: ""
- field: product
note: "产品"
range: 1-100{5}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: branch
note: "平台/分支"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: parent
note: "父计划"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: title
note: "名称"
range: 1-10000
prefix: "产品计划"
postfix: ""
loop: 0
format: ""
- field: desc
note: "描述"
range: 1-10000
prefix: "这里是描述"
postfix: ""
loop: 0
format: ""
- field: begin
note: "开始日期"
from: common.date.v1.yaml
use: dateB
prefix: ""
postfix: ""
loop: 0
format: ""
- field: end
note: "结束日期"
from: common.date.v1.yaml
use: dateB
prefix: ""
postfix: ""
loop: 0
format: ""
- field: order
note: "排序"
range: 10-10000:5
prefix: ""
postfix: ""
loop: 0
format: ""
- field: deleted
note: "是否删除"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
-363
View File
@@ -1,363 +0,0 @@
title: table zt_project
desc: "项目"
author: automated export
version: "1.0"
fields:
- field: id
note: "ID"
range: 1-10000
prefix: ""
postfix: ""
loop: 0
format: ""
- field: isCat
note: ""
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: catID
note: ""
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: template
note: "模块"
range: waterfall,scrum
prefix: ""
postfix: ""
loop: 0
format: ""
- field: category
note: "项目分类"
range: multiple
prefix: ""
postfix: ""
loop: 0
format: ""
- field: program
note: "所属项目"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: budget
note: "项目预算"
range: 1-100000:R
prefix: ""
postfix: ""
loop: 0
format: ""
- field: budgetUnit
note: "预算单位"
range: yuan
prefix: ""
postfix: ""
loop: 0
format: ""
- field: percent
note: "工作占比"
range: 1-100:R
prefix: ""
postfix: ""
loop: 0
format: ""
- field: privway
note: "私有的"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: milestone
note: "是否里程碑"
range: 0,1
prefix: ""
postfix: ""
loop: 0
format: ""
- field: attribute
note: "阶段属性"
range: story,design,dev,qa,release,review,other
prefix: ""
postfix: ""
loop: 0
format: ""
- field: output
note: "输出文档"
range: 1-100:R
prefix: ""
postfix: ""
loop: 0
format: ""
- field: type
note: "项目类型"
range: sprint
prefix: ""
postfix: ""
loop: 0
format: ""
- field: parent
note: "父级ID"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: path
note: "路径"
range: "0"
prefix: ""
postfix: ""
loop: 0
format: ""
- field: grade
note: "等级"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: name
note: "项目名称"
range: 1-10000
prefix: "项目"
postfix: ""
loop: 0
format: ""
- field: code
note: "项目代号"
range: 1-10000
prefix: "project"
postfix: ""
loop: 0
format: ""
- field: begin
note: "开始日期"
from: common.date.v1.yaml
use: dateB
prefix: ""
postfix: ""
loop: 0
format: ""
- field: end
note: "结束日期"
from: common.date.v1.yaml
use: dateB
prefix: ""
postfix: ""
loop: 0
format: ""
- field: realStarted
note: "实际开始日期"
from: common.date.v1.yaml
use: dateB
prefix: ""
postfix: ""
loop: 0
format: ""
- field: realFinished
note: "实际完成日期"
from: common.date.v1.yaml
use: dateB
prefix: ""
postfix: ""
loop: 0
format: ""
- field: days
note: "可用工作日"
range: 1-365:R
prefix: ""
postfix: ""
loop: 0
format: ""
- field: status
note: "状态"
range: doing,wait,suspended,closed
prefix: ""
postfix: ""
loop: 0
format: ""
- field: subStatus
note: "子状态"
range: 1
prefix: ""
postfix: ""
loop: 0
format: ""
- field: statge
note: "阶段"
range: 1
prefix: ""
postfix: ""
loop: 0
format: ""
- field: pri
note: "优先级"
range: 1-4
prefix: ""
postfix: ""
loop: 0
format: ""
- field: desc
note: "项目描述"
range: 1-10000
prefix: "这是一个项目的描述"
postfix: ""
loop: 0
format: ""
- field: version
note: "项目版本"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: parentVersion
note: "父级项目版本"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: realDuration
note: ""
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: planDuration
note: ""
range: 1-10000
prefix: ""
postfix: ""
loop: 0
format: ""
- field: openedBy
note: "创建者"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: openedDate
note: "创建日期"
from: common.date.v1.yaml
use: dateA
prefix: ""
postfix: ""
loop: 0
format: ""
- field: openedVersion
note: "创建版本"
from: common.version.v1.yaml
use: version
prefix: ""
postfix: ""
loop: 0
format: ""
- field: closedBy
note: "关闭者"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: closedDate
note: "关闭日期"
from: common.date.v1.yaml
use: dateA
prefix: ""
postfix: ""
loop: 0
format: ""
- field: canceledBy
note: "取消者"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: canceledDate
note: "取消日期"
from: common.date.v1.yaml
use: dateA
prefix: ""
postfix: ""
loop: 0
format: ""
- field: PO
note: "产品负责人"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: PM
note: "项目负责人"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: QD
note: "测试负责人"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: RD
note: "发布负责人"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: team
note: "团队名称"
range: 1-10000
prefix: "团队名称"
postfix: ""
loop: 0
format: ""
- field: acl
note: "访问权限"
range: open
prefix: ""
postfix: ""
loop: 0
format: ""
- field: whitelist
note: "分组白名单"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: order
note: "项目排序"
range: 5-10000:5
prefix: ""
postfix: ""
loop: 0
format: ""
- field: deleted
note: "是否删除"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
-135
View File
@@ -1,135 +0,0 @@
title: table zt_story
desc: "需求"
author: automated export
version: "1.0"
fields:
- field: id
note: "ID"
range: 1-100000
prefix: ""
postfix: ""
loop: 0
format: ""
- field: program
note: "项目ID"
range: 1-100{100}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: parent
note: "父需求ID"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: product
note: "所属产品"
range: 1-100{100}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: branch
note: "分支/平台"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: module
note: "所属模块"
range: 1-1000{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: plan
note: "所属计划"
range: 1-500{20}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: source
note: "需求来源"
range: customer,user,po,market,service,operation,support,competitor,partner,dev,tester,bug,forum,other
prefix: ""
postfix: ""
loop: 0
format: ""
- field: sourceNote
note: "来源备注"
range: 1-100000
prefix: "这里是需求来源备注"
postfix: ""
loop: 0
format: ""
- field: fromBug
note: "来源Bug"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: title
note: "需求名称"
fields:
- field: field1
range: 用户需求,软件需求
- field: field2
range: 1-100000
prefix: ""
postfix: ""
loop: 0
format: ""
- field: keywords
note: "关键词"
range: 1-100000
prefix: "关键词"
postfix: ""
loop: 0
format: ""
- field: type
note: "需求类型"
range: requirement,story
prefix: ""
postfix: ""
loop: 0
format: ""
- field: pri
note: "优先级"
range: 1-4:R
prefix: ""
postfix: ""
loop: 0
format: ""
- field: estimate
note: "预计工时"
range: 0-20:R
prefix: ""
postfix: ""
loop: 0
format: ""
- field: status
note: "当前状态"
range: active
prefix: ""
postfix: ""
loop: 0
format: ""
- field: subStatus
note: "子状态"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: stage
note: "所处阶段"
range: wait
prefix: ""
postfix: ""
loop: 0
format: ""
-44
View File
@@ -1,44 +0,0 @@
title: table zt_storyspec
desc: "需求描述"
author: automated export
version: "1.0"
fields:
- field: story
note: "需求ID"
range: 1-10000
prefix: ""
postfix: ""
loop: 0
format: ""
- field: version
note: "版本"
range: 1
prefix: ""
postfix: ""
loop: 0
format: ""
- field: title
note: "标题"
fields:
- field: field1
range: 用户需求,软件需求
- field: field2
range: 1-100000
prefix: ""
postfix: ""
loop: 0
format: ""
- field: spec
note: "需求描述"
range: 1-10000
prefix: "这是一个软件需求描述"
postfix: ""
loop: 0
format: ""
- field: verify
note: "验收标准"
range: 1-10000
prefix: "这是一个需求验收"
postfix: ""
loop: 0
format: ""
-133
View File
@@ -1,133 +0,0 @@
No set yet ZDATA:
zt_asset.yaml
zt_attendstat.yaml
zt_attend.yaml
zt_baseline.yaml
zt_basicmeas.yaml
zt_compile.yaml
zt_config.yaml
zt_deployproduct.yaml
zt_deployscope.yaml
zt_deploystep.yaml
zt_deploy.yaml
zt_derivemeas.yaml
zt_durationestimation.yaml
zt_faq.yaml
zt_feedbackview.yaml
zt_feedback.yaml
zt_flow_reviewlist.yaml
zt_flow_workloadbudget.yaml
zt_host.yaml
zt_leave.yaml
zt_lieu.yaml
zt_measqueue.yaml
zt_measrecords.yaml
zt_meastemplate.yaml
zt_nc.yaml
zt_oauth.yaml
zt_overtime.yaml
zt_programplan.yaml
zt_programprocess.yaml
zt_programreport.yaml
zt_relationoftasks.yaml
zt_service.yaml
zt_sqlview.yaml
zt_storystage.yaml
zt_suitecase.yaml
zt_trip.yaml
zt_webhook.yaml
zt_weeklyreport.yaml
zt_workestimation.yaml
zt_workflowaction.yaml
zt_workflowdatasource.yaml
zt_workflowfield.yaml
zt_workflowlabel.yaml
zt_workflowlayout.yaml
zt_workflowlinkdata.yaml
zt_workflowrelationlayout.yaml
zt_workflowrelation.yaml
zt_workflowrule.yaml
zt_workflowsql.yaml
zt_workflowversion.yaml
zt_workflow.yaml
====================================================
set ZDATA:
zt_action.yaml
zt_branch.yaml
zt_block.yaml
zt_budget.yaml
zt_bug.yaml
zt_build.yaml
zt_burn.yaml
zt_casestep.yaml
zt_case.yaml
zt_company.yaml
zt_cron.yaml
zt_dept.yaml
zt_doccontent.yaml
zt_doclib.yaml
zt_doc.yaml
zt_effort.yaml
zt_entry.yaml
zt_extension.yaml
zt_file.yaml
zt_flow_audit.yaml
zt_flow_auditcl.yaml
zt_flow_auditplan.yaml
zt_flow_auditresult.yaml
zt_flow_cmcl.yaml
zt_flow_design.yaml
zt_flow_designspec.yaml
zt_flow_issue.yaml
zt_flow_output.yaml
zt_flow_process.yaml
zt_flow_reviewcl.yaml
zt_flow_risk.yaml
zt_flow_stage.yaml
zt_grouppriv.yaml
zt_group.yaml
zt_history.yaml
zt_jenkins.yaml
zt_job.yaml
zt_lang.yaml
zt_log.yaml
zt_module.yaml
zt_notify.yaml
zt_object.yaml
zt_productplan.yaml
zt_project.yaml
zt_programactivity.yaml
zt_programoutput.yaml
zt_project.yaml
zt_projectproduct.yaml
zt_projectspec.yaml
zt_projectstory.yaml
zt_relation.yaml
zt_release.yaml
zt_repo.yaml
zt_repobranch.yaml
zt_repofiles.yaml
zt_repohistory.yaml
zt_report.yaml
zt_review.yaml
zt_reviewissue.yaml
zt_reviewresult.yaml
zt_score.yaml
zt_searchindex.yaml
zt_serverroom.yaml
zt_solutions.yaml
zt_storyspec.yaml
zt_story.yaml
zt_taskspec.yaml
zt_task.yaml
zt_team.yaml
zt_testreport.yaml
zt_testresult.yaml
zt_testrun.yaml
zt_testsuite.yaml
zt_todo.yaml
zt_usercontact.yaml
zt_userquery.yaml
zt_userview.yaml
zt_user.yaml
+69
View File
@@ -0,0 +1,69 @@
title: table zt_project
author: Zhu Jinyong
version: "1.0"
fields:
- field: id
range: 1-10000
- field: project
range: 1-10000
- field: model
range:
- field: type
range: project
- field: product
range: single
- field: lifetime
range:
- field: budget
range: 0
- field: budgetUnit
range: CNY,USD
- field: attribute
note: "Only stage has attribute"
range:
- field: percent
range: 1-100:R
- field: milestone
note: "Is it milestone"
range: 0
- field: output
note: "Output document"
range:
- field: auth
note: "Only project has auth"
range:
- field: parent
range: 1,2,3,4,2,1,[1-7]{2},[7-19]{3}
- field: path
prefix: ","
postfix: ","
range:
- field: grade
range:
- field: name
range: 1-10000
prefix: "测试项目"
- field: code
range: 1-10000
prefix: "project"
- field: begin
from: common.date.v1.yaml
use: date
- field: PO
range:
- field: PM
range:
- field: QD
range:
- field: RD
range:
- field: team
range:
- field: acl
range: open,private,custom
- field: whitelist
range:
- field: order
range: 5-10000:5
- field: deleted
range: 0
+6
View File
@@ -0,0 +1,6 @@
<?php
$builder = new stdclass();
$builder->programGrade1 = array('rows' => 10, 'data' => array('project', 'program', 'programgrade1'));
//$builder->programGrade2 = array('rows' => 10, 'data' => array('project', 'program', 'programgrade2'));
//$builder->programGrade3 = array('rows' => 10, 'data' => array('project', 'program', 'programgrade3'));
+22
View File
@@ -0,0 +1,22 @@
title: program
author: Zhu Jinyong
version: "1.0"
fields:
- field: id
range: 1-10000
- field: project
range: 1-10000
- field: model
range:
- field: type
range: program
- field: status
range: doing,wait,suspended,closed
- field: desc
range: 1-10000
prefix: "项目集描述"
- field: acl
range: open,private
- field: whitelist
from: common.user.v1.yaml
use: user
+10
View File
@@ -0,0 +1,10 @@
title: program
author: Zhu Jinyong
version: "1.0"
fields:
- field: grade
range: 1
- field: parent
range: 1
- field: path
range: 1
+10
View File
@@ -0,0 +1,10 @@
title: program
author: Zhu Jinyong
version: "1.0"
fields:
- field: grade
range: 1
- field: parent
range: 1
- field: path
range: 1
+10
View File
@@ -0,0 +1,10 @@
title: program
author: Zhu Jinyong
version: "1.0"
fields:
- field: grade
range: 1
- field: parent
range: 1
- field: path
range: 1
View File
-363
View File
@@ -1,363 +0,0 @@
title: table zt_project
desc: "项目"
author: automated export
version: "1.0"
fields:
- field: id
note: "ID"
range: 1-10000
prefix: ""
postfix: ""
loop: 0
format: ""
- field: isCat
note: ""
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: catID
note: ""
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: template
note: "模块"
range: waterfall,scrum
prefix: ""
postfix: ""
loop: 0
format: ""
- field: category
note: "项目分类"
range: multiple,single
prefix: ""
postfix: ""
loop: 0
format: ""
- field: program
note: "所属项目"
range: 1-10000
prefix: ""
postfix: ""
loop: 0
format: ""
- field: budget
note: "项目预算"
range: 1-100000:R
prefix: ""
postfix: ""
loop: 0
format: ""
- field: budgetUnit
note: "预算单位"
range: yuan,Dollars
prefix: ""
postfix: ""
loop: 0
format: ""
- field: percent
note: "工作占比"
range: 1-100:R
prefix: ""
postfix: ""
loop: 0
format: ""
- field: privway
note: "私有的"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: milestone
note: "是否里程碑"
range: 0,1
prefix: ""
postfix: ""
loop: 0
format: ""
- field: attribute
note: "阶段属性"
range: story,design,dev,qa,release,review,other
prefix: ""
postfix: ""
loop: 0
format: ""
- field: output
note: "输出文档"
range: 1-100:R
prefix: ""
postfix: ""
loop: 0
format: ""
- field: type
note: "项目类型"
range: waterfall,project
prefix: ""
postfix: ""
loop: 0
format: ""
- field: parent
note: "父级ID"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: path
note: "路径"
range: "0"
prefix: ""
postfix: ""
loop: 0
format: ""
- field: grade
note: "等级"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: name
note: "项目名称"
range: 1-10000
prefix: "这是一个项目名称"
postfix: ""
loop: 0
format: ""
- field: code
note: "项目代号"
range: 1-10000
prefix: "project"
postfix: ""
loop: 0
format: ""
- field: begin
note: "开始日期"
from: common.date.v1.yaml
use: dateB
prefix: ""
postfix: ""
loop: 0
format: ""
- field: end
note: "结束日期"
from: common.date.v1.yaml
use: dateB
prefix: ""
postfix: ""
loop: 0
format: ""
- field: realStarted
note: "实际开始日期"
from: common.date.v1.yaml
use: dateB
prefix: ""
postfix: ""
loop: 0
format: ""
- field: realFinished
note: "实际完成日期"
from: common.date.v1.yaml
use: dateB
prefix: ""
postfix: ""
loop: 0
format: ""
- field: days
note: "可用工作日"
range: 1-365:R
prefix: ""
postfix: ""
loop: 0
format: ""
- field: status
note: "状态"
range: doing,wait,suspended,closed
prefix: ""
postfix: ""
loop: 0
format: ""
- field: subStatus
note: "子状态"
range: 1
prefix: ""
postfix: ""
loop: 0
format: ""
- field: statge
note: "阶段"
range: 1
prefix: ""
postfix: ""
loop: 0
format: ""
- field: pri
note: "优先级"
range: 1-4
prefix: ""
postfix: ""
loop: 0
format: ""
- field: desc
note: "项目描述"
range: 1-10000
prefix: "这是一个项目的描述"
postfix: ""
loop: 0
format: ""
- field: version
note: "项目版本"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: parentVersion
note: "父级项目版本"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: realDuration
note: ""
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: planDuration
note: ""
range: 1-10000
prefix: ""
postfix: ""
loop: 0
format: ""
- field: openedBy
note: "创建者"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: openedDate
note: "创建日期"
from: common.date.v1.yaml
use: dateA
prefix: ""
postfix: ""
loop: 0
format: ""
- field: openedVersion
note: "创建版本"
from: common.version.v1.yaml
use: version
prefix: ""
postfix: ""
loop: 0
format: ""
- field: closedBy
note: "关闭者"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: closedDate
note: "关闭日期"
from: common.date.v1.yaml
use: dateA
prefix: ""
postfix: ""
loop: 0
format: ""
- field: canceledBy
note: "取消者"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: canceledDate
note: "取消日期"
from: common.date.v1.yaml
use: dateA
prefix: ""
postfix: ""
loop: 0
format: ""
- field: PO
note: "产品负责人"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: PM
note: "项目负责人"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: QD
note: "测试负责人"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: RD
note: "发布负责人"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: team
note: "团队名称"
range: 1-10000
prefix: "团队名称"
postfix: ""
loop: 0
format: ""
- field: acl
note: "访问权限"
range: open,private,custom
prefix: ""
postfix: ""
loop: 0
format: ""
- field: whitelist
note: "分组白名单"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
- field: order
note: "项目排序"
range: 5-10000:5
prefix: ""
postfix: ""
loop: 0
format: ""
- field: deleted
note: "是否删除"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
+1186
View File
File diff suppressed because it is too large Load Diff
+107 -29
View File
@@ -10,6 +10,27 @@
* @link http://www.zentao.net
*/
define('RUNTIME_ROOT', dirname(dirname(__FILE__)) . '/runtime/');
define('LIB_ROOT', dirname(dirname(__FILE__)) . '/lib/');
/**
* Get version type of ZenTaoPMS.
*
* @param $version
* @access public
* @return void
*/
function getVersionType($version)
{
global $config;
if(strpos($version, 'max') !== false) return 'max';
if(strpos($version, 'biz') !== false) return 'biz';
if(strpos($version, 'pro') !== false) return 'pro';
return 'zentao';
}
/**
* Run test cases of a directory using ztf.
*
@@ -21,70 +42,127 @@ function ztfRun($dir)
{
global $config;
$ztfPath = dirname(dirname(__FILE__)) . '/tools/ztf';
$ztfPath = RUNTIME_ROOT . 'ztf';
$command = "$ztfPath $dir";
system($command);
}
/**
* Run scripts of a directory using zendata.
* Extract comments to steps and expects.
*
* @param string $dir
* @access public
* @return void
*/
function zdRun($dir)
function ztfExtract($dir)
{
global $config;
$ztfPath = RUNTIME_ROOT . 'ztf';
$command = "$ztfPath extract $dir";
system($command);
}
/**
* Run yaml files of zendata.
*
* @access public
* @return void
*/
function zdRun()
{
$frameworkRoot = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'framework' . DIRECTORY_SEPARATOR;
include $frameworkRoot . 'helper.class.php';
include LIB_ROOT . 'spyc.php';
$zdRoot = dirname(dirname(__FILE__)) . '/' . $dir;
$zdPath = dirname(dirname(__FILE__)) . '/tools/zd';
$zdRoot = dirname(dirname(__FILE__)) . '/data/';
$zdPath = RUNTIME_ROOT . 'zd';
set_time_limit(0);
try
{
$config = new stdclass();
$config->db = new stdclass();
include dirname(dirname(dirname(__FILE__))) . '/config/config.php';
include $zdRoot . '/count.php';
include dirname(dirname(dirname(__FILE__))) . '/config/config.php';
$versionType = getVersionType($config->version);
$configRoot = $zdRoot . $versionType . '/';
include $configRoot . 'config.php';
/* Connect to MySQL. */
$dsn = "mysql:host={$config->db->host}:{$config->db->port};dbname={$config->db->name}";
$dbh = new PDO($dsn, $config->db->user, $config->db->password);
echo 'MySQL connect success' . PHP_EOL;
$command = "$zdPath -c $zdRoot/%s -n %s -o $zdRoot/sql/%s.sql -table %s";
$yamlFilePath = scandir($zdRoot);
foreach($yamlFilePath as $file)
{
if(!strpos($file, '.yaml')) continue;
$fileName = basename($file, '.yaml');
$count = isset($config->dataRows[$fileName]) ? $config->dataRows[$fileName] : 10;
$execYaml = sprintf($command, $file, $count, $fileName, $fileName);
exec($execYaml); // Create sql files.
echo 'Execute: ' . $file . PHP_EOL;
}
/* Export SQL files to mysql. */
$sqlDir = $zdRoot . '/sql/';
$sqlFilePath = scandir($sqlDir);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // 设置报错处理方式。
$dbh->exec("SET GLOBAL sql_mode = '';");
$dbh->exec("set names 'utf8'");
$dbh->beginTransaction();
$command = "$zdPath -c %s -d $zdRoot%s -n %s -o {$zdRoot}sql/%s.sql -table %s";
$tables = array();
foreach($builder as $key => $info)
{
/* Build zendata. */
$configData = array('fields' => array());
foreach($info['data'] as $fileKey => $fileName)
{
if($fileKey == 0) continue; // Skip default file.
$data = Spyc::YAMLLoad($configRoot . $fileName . '.yaml');
foreach($data['fields'] as $field)
{
$fieldName = $field['field'];
$fieldExist = false;
foreach($configData['fields'] as $key => $configField)
{
if($configField['field'] == $fieldName)
{
$configData['fields'][$key] = $field;
$fieldExist = true;
break;
}
}
if(!$fieldExist) $configData['fields'][] = $field;
}
}
/* Refresh runtime/tmp/config.yaml. */
$spyc = new Spyc();
$content = $spyc->dump($configData);
$yaml = fopen(RUNTIME_ROOT . 'tmp/config.yaml', 'w');
fwrite($yaml, $content);
fclose($yaml);
/* Create sql files. */
$defaultName = $info['data'][0];
$tableName = $config->db->prefix . $defaultName;
$execYaml = sprintf($command, RUNTIME_ROOT . 'tmp/config.yaml', $defaultName . '.yaml', $info['rows'], $fileName, $tableName);
system($execYaml);
echo 'Execute: ' . $fileName . PHP_EOL;
$tables[$tableName] = $tableName;
}
/* Truncate tables. */
foreach($tables as $table)
{
$dbh->exec('truncate table ' . $table);
}
/* Export SQL files to MySQL. */
$sqlDir = $zdRoot . '/sql/';
$sqlFilePath = scandir($sqlDir);
foreach($sqlFilePath as $file)
{
if(!strpos($file, '.sql')) continue;
$tableName = basename($file, '.sql');
$truncate = 'truncate table ' . $tableName;
$dbh->exec($truncate);
$sql = file_get_contents($sqlDir . $file);
$count = $dbh->exec($sql);
echo $tableName . ' insert rows ' . $count . PHP_EOL;
-14
View File
@@ -1,14 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 branchModel::getById();
cid=1
pid=1
*/
include dirname(dirname(__DIR__)) . '/lib/init.php';
$branch = $tester->loadModel('branch');
/* group: 1. */
r($branch->getByID(1)) && p('name') && e('A'); // step: 1.1 使用branchID获取一个存在的分支. >>
-28
View File
@@ -1,28 +0,0 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/init.php';
/**
[case]
title=测试 gapanalysisModel::getById();
cid=1
pid=1
[group]
1. 使用ID获取一个存在的能力差距分析 >> `\d,\d+,\w+\d`
2. 使用ID获取一个不存在的能力差距分析 >> ``
[esac]
*/
$gapanalysis = $tester->loadModel('gapanalysis');
$app->dbh->query("truncate zt_gapanalysis");
$id = rand(1,5);
zdImport(TABLE_GAPANALYSIS, "zendata/gapanalysis.yaml", 5);
$randGapAnalysis = $tester->dao->select('*,rand() as rand')->from(TABLE_GAPANALYSIS)->where('id')->eq($id)->orderBy('rand')->fetch();
if(!$randGapAnalysis) exit("Prepair data error.");
unset($randGapAnalysis->rand);
/* Step 1.*/
run($gapanalysis->getByID($randGapAnalysis->id, 'id')) and expect('id,project,account');
/* Step 2.*/
run($gapanalysis->getByID(null, 'id')) and expect('id');
-22
View File
@@ -1,22 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 trainplanModel::getById();
cid=1
pid=1
获取到的project是21,lecturer是hufangzhou >> `21,hufangzhou`
*/
include dirname(dirname(dirname(__FILE__))) . '/init.php';
$trainplan = $tester->loadModel('trainplan');
$app->dbh->query("truncate zt_trainplan");
zdImport(TABLE_TRAINPLAN, "zendata/trainplan.yaml", 10);
$randTrainPlan = $tester->dao->select('*,rand() as rand')->from(TABLE_TRAINPLAN)->orderBy('rand')->fetch();
if(!$randTrainPlan) exit("Prepair data error.");
unset($randTrainPlan->rand);
/* Step 1.*/
run($trainplan->getById($randTrainPlan->id)) and expect('project,lecturer');
+6 -7
View File
@@ -1,16 +1,15 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/init.php';
/**
[case]
title=测试 userModel::getById();
cid=1
pid=1
[group]
1. 使用ID获取一个存在的用户 >> `\d,\w+`
2. 使用account获取一个存在的用户 >> `\d`
3. 使用account获取一个存在的用户 >> ``
[esac]
*/
$user = $tester->loadModel('user');
@@ -28,4 +27,4 @@ run($user->getByID($randUser->id, 'id')) and expect('id,account');
run($user->getByID($randUser->account, 'account')) and expect('id');
/* Step 3.*/
run($user->getByID(null, 'id')) and expect('id');
run($user->getByID(null, 'id')) and expect('id');
+10
View File
@@ -9,10 +9,20 @@ switch($argv[1])
case 'init':
zdRun('data');
break;
case 'extract':
ztfExtract('model');
break;
case 'api':
ztfExtract('api');
ztfRun('api');
break;
case 'control':
ztfRun('control');
break;
case 'model':
ztfRun('model');
break;
default:
ztfExtract($argv[1]);
system("php " . $argv[1]);
}