Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
836b6195
Z
zendata
项目概览
易企天创
/
zendata
9 个月 前同步成功
通知
17
Star
2
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zendata
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
836b6195
编写于
6月 05, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support literal and interval field definition
上级
bd4aa329
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
126 addition
and
59 deletion
+126
-59
demo/roll.yaml
demo/roll.yaml
+3
-3
src/gen/charVal.go
src/gen/charVal.go
+40
-24
src/gen/floatVal.go
src/gen/floatVal.go
+39
-22
src/gen/intVal.go
src/gen/intVal.go
+2
-3
src/gen/list.go
src/gen/list.go
+42
-7
未找到文件。
demo/roll.yaml
浏览文件 @
836b6195
...
...
@@ -5,10 +5,10 @@ version: 1.0
fields
:
-
field
:
objectype
range
:
[
bug
,
task
]
:2{3},story
{2}
range
:
[
bug
,
task
,
story
]
:2{3},[testcase]
{2}
-
field
:
objectid
range
:
1
-3:1
{2}
range
:
1
.0-9.0:3
{2}
-
field
:
action
range
:
[
create
,
resolve
,
close
]{
10
}
,
[
create
,
finish
,
close
]{
10
}
\ No newline at end of file
range
:
[
create
,
resolve
,
close
]{
2
}
,
[
create
,
finish
,
close
]{
10
}
\ No newline at end of file
src/gen/charVal.go
浏览文件 @
836b6195
...
...
@@ -5,27 +5,37 @@ import (
"math/rand"
)
func
GenerateByteItems
(
start
byte
,
end
byte
,
step
interface
{},
rand
bool
,
limi
t
int
)
[]
interface
{}
{
func
GenerateByteItems
(
start
byte
,
end
byte
,
step
interface
{},
rand
bool
,
repea
t
int
)
[]
interface
{}
{
if
!
rand
{
return
GenerateByteItemsByStep
(
start
,
end
,
step
.
(
int
),
limi
t
)
return
GenerateByteItemsByStep
(
start
,
end
,
step
.
(
int
),
repea
t
)
}
else
{
return
GenerateByteItemsRand
(
start
,
end
,
step
.
(
int
),
limi
t
)
return
GenerateByteItemsRand
(
start
,
end
,
step
.
(
int
),
repea
t
)
}
}
func
GenerateByteItemsByStep
(
start
byte
,
end
byte
,
step
int
,
limi
t
int
)
[]
interface
{}
{
func
GenerateByteItemsByStep
(
start
byte
,
end
byte
,
step
int
,
repea
t
int
)
[]
interface
{}
{
arr
:=
make
([]
interface
{},
0
)
count
:=
constant
.
MaxNumb
for
i
:=
0
;
i
<
constant
.
MaxNumb
;
{
val
:=
start
+
byte
(
int
(
i
)
*
step
)
if
val
>
end
||
i
>
limit
{
break
total
:=
0
for
round
:=
0
;
round
<
repeat
;
round
++
{
for
i
:=
0
;
true
;
{
val
:=
start
+
byte
(
int
(
i
)
*
step
)
if
val
>
end
||
i
>
repeat
{
break
}
arr
=
append
(
arr
,
val
)
i
++
total
++
if
total
>
constant
.
MaxNumb
{
break
}
}
arr
=
append
(
arr
,
val
)
count
++
i
++
if
total
>
constant
.
MaxNumb
{
break
}
}
return
arr
...
...
@@ -34,20 +44,26 @@ func GenerateByteItemsByStep(start byte, end byte, step int, limit int) []interf
func
GenerateByteItemsRand
(
start
byte
,
end
byte
,
step
int
,
repeat
int
)
[]
interface
{}
{
arr
:=
make
([]
interface
{},
0
)
count
:=
int
(
end
-
start
)
/
step
+
1
if
count
>
repeat
{
count
=
repeat
}
if
count
>
constant
.
MaxNumb
{
count
=
constant
.
MaxNumb
}
countInRound
:=
int
(
end
-
start
)
/
step
+
1
total
:=
0
for
round
:=
0
;
round
<
repeat
;
round
++
{
for
i
:=
0
;
i
<
countInRound
;
{
ran
:=
rand
.
Intn
(
countInRound
)
val
:=
start
+
byte
(
ran
)
arr
=
append
(
arr
,
val
)
i
++
total
++
for
i
:=
0
;
i
<
count
;
{
ran
:=
rand
.
Intn
(
count
)
val
:=
start
+
byte
(
ran
)
if
total
>
constant
.
MaxNumb
{
break
}
}
arr
=
append
(
arr
,
val
)
i
++
if
total
>
constant
.
MaxNumb
{
break
}
}
return
arr
...
...
src/gen/floatVal.go
浏览文件 @
836b6195
...
...
@@ -7,26 +7,37 @@ import (
"strings"
)
func
GenerateFloatItems
(
start
float64
,
end
float64
,
step
interface
{},
rand
bool
,
limi
t
int
)
[]
interface
{}
{
func
GenerateFloatItems
(
start
float64
,
end
float64
,
step
interface
{},
rand
bool
,
repea
t
int
)
[]
interface
{}
{
if
!
rand
{
return
GenerateFloatItemsByStep
(
start
,
end
,
step
.
(
float64
),
limi
t
)
return
GenerateFloatItemsByStep
(
start
,
end
,
step
.
(
float64
),
repea
t
)
}
else
{
return
GenerateFloatItemsRand
(
start
,
end
,
step
.
(
float64
),
limi
t
)
return
GenerateFloatItemsRand
(
start
,
end
,
step
.
(
float64
),
repea
t
)
}
}
func
GenerateFloatItemsByStep
(
start
float64
,
end
float64
,
step
interface
{},
limi
t
int
)
[]
interface
{}
{
func
GenerateFloatItemsByStep
(
start
float64
,
end
float64
,
step
interface
{},
repea
t
int
)
[]
interface
{}
{
arr
:=
make
([]
interface
{},
0
)
for
i
:=
0
;
i
<
constant
.
MaxNumb
;
{
gap
:=
float64
(
i
)
*
step
.
(
float64
)
val
:=
start
+
gap
if
val
>
end
||
i
>
limit
{
total
:=
0
for
round
:=
0
;
round
<
repeat
;
round
++
{
for
i
:=
0
;
true
;
{
gap
:=
float64
(
i
)
*
step
.
(
float64
)
val
:=
start
+
gap
if
val
>
end
{
break
}
arr
=
append
(
arr
,
val
)
i
++
total
++
if
total
>
constant
.
MaxNumb
{
break
}
}
if
total
>
constant
.
MaxNumb
{
break
}
arr
=
append
(
arr
,
val
)
i
++
}
return
arr
...
...
@@ -35,19 +46,25 @@ func GenerateFloatItemsByStep(start float64, end float64, step interface{}, limi
func
GenerateFloatItemsRand
(
start
float64
,
end
float64
,
step
float64
,
repeat
int
)
[]
interface
{}
{
arr
:=
make
([]
interface
{},
0
)
count
:=
(
end
-
start
)
/
step
if
count
>
float64
(
repeat
)
{
count
=
float64
(
repeat
)
}
if
count
>
float64
(
constant
.
MaxNumb
)
{
count
=
float64
(
constant
.
MaxNumb
)
}
countInRound
:=
(
end
-
start
)
/
step
for
i
:=
float64
(
0
);
i
<
count
;
{
val
:=
start
+
float64
(
rand
.
Int63n
(
int64
(
count
)))
*
step
total
:=
0
for
round
:=
0
;
round
<
repeat
;
round
++
{
for
i
:=
float64
(
0
);
i
<
countInRound
;
{
val
:=
start
+
float64
(
rand
.
Int63n
(
int64
(
countInRound
)))
*
step
arr
=
append
(
arr
,
val
)
i
++
arr
=
append
(
arr
,
val
)
i
++
total
++
if
total
>
constant
.
MaxNumb
{
break
}
}
if
total
>
constant
.
MaxNumb
{
break
}
}
return
arr
...
...
src/gen/intVal.go
浏览文件 @
836b6195
...
...
@@ -33,7 +33,7 @@ func GenerateIntItemsByStep(start int64, end int64, step int, repeat int) []inte
}
}
if
total
>
constant
.
MaxNumb
{
if
total
>
=
constant
.
MaxNumb
{
break
}
}
...
...
@@ -44,8 +44,7 @@ func GenerateIntItemsByStep(start int64, end int64, step int, repeat int) []inte
func
GenerateIntItemsRand
(
start
int64
,
end
int64
,
step
int
,
repeat
int
)
[]
interface
{}
{
arr
:=
make
([]
interface
{},
0
)
mod
:=
(
end
-
start
)
%
int64
(
step
)
countInRound
:=
(
end
-
start
)
/
int64
(
step
)
countInRound
:=
(
end
-
start
)
/
int64
(
step
)
+
1
total
:=
0
for
round
:=
0
;
round
<
repeat
;
round
++
{
...
...
src/gen/list.go
浏览文件 @
836b6195
...
...
@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/easysoft/zendata/src/model"
constant
"github.com/easysoft/zendata/src/utils/const"
"math/rand"
"regexp"
"strconv"
"strings"
...
...
@@ -54,13 +55,9 @@ func GenerateFieldValuesFromList(field *model.DefField, fieldValue *model.FieldV
items
:=
make
([]
interface
{},
0
)
if
typ
==
"literal"
{
items
=
GenerateValuesFromLiteral
(
field
,
desc
,
stepStr
,
repeat
)
}
else
if
typ
==
"interval"
{
elemArr
:=
strings
.
Split
(
desc
,
"-"
)
startStr
:=
elemArr
[
0
]
endStr
:=
startStr
if
len
(
elemArr
)
>
1
{
endStr
=
elemArr
[
1
]
}
items
=
GenerateValuesFromInterval
(
field
,
startStr
,
endStr
,
stepStr
,
repeat
)
items
=
GenerateValuesFromInterval
(
field
,
desc
,
stepStr
,
repeat
)
}
fieldValue
.
Values
=
append
(
fieldValue
.
Values
,
items
...
)
...
...
@@ -176,7 +173,45 @@ func ParseRangeItem(item string) (string, string, int) {
return
entry
,
step
,
repeat
}
func
GenerateValuesFromInterval
(
field
*
model
.
DefField
,
startStr
string
,
endStr
string
,
stepStr
string
,
repeat
int
)
[]
interface
{}
{
func
GenerateValuesFromLiteral
(
field
*
model
.
DefField
,
desc
string
,
stepStr
string
,
repeat
int
)
[]
interface
{}
{
items
:=
make
([]
interface
{},
0
)
elemArr
:=
strings
.
Split
(
desc
,
","
)
stepStr
=
strings
.
ToLower
(
strings
.
TrimSpace
(
stepStr
))
step
,
_
:=
strconv
.
Atoi
(
stepStr
)
total
:=
0
for
round
:=
0
;
round
<
repeat
;
round
++
{
for
i
:=
0
;
i
<
len
(
elemArr
);
{
val
:=
""
if
stepStr
==
"r"
{
val
=
elemArr
[
rand
.
Intn
(
len
(
elemArr
))]
}
else
{
val
=
elemArr
[
i
]
}
items
=
append
(
items
,
val
)
i
+=
step
total
++
if
total
>
constant
.
MaxNumb
{
break
}
}
if
total
>=
constant
.
MaxNumb
{
break
}
}
return
items
}
func
GenerateValuesFromInterval
(
field
*
model
.
DefField
,
desc
string
,
stepStr
string
,
repeat
int
)
[]
interface
{}
{
elemArr
:=
strings
.
Split
(
desc
,
"-"
)
startStr
:=
elemArr
[
0
]
endStr
:=
startStr
if
len
(
elemArr
)
>
1
{
endStr
=
elemArr
[
1
]
}
items
:=
make
([]
interface
{},
0
)
dataType
,
step
,
precision
,
rand
:=
CheckRangeType
(
startStr
,
endStr
,
stepStr
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录