Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
4816fdca
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 搜索 >>
提交
4816fdca
编写于
9月 07, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
close task#7784,7787-7790
上级
742f2d04
变更
12
展开全部
隐藏空白更改
内联
并排
Showing
12 changed file
with
185 addition
and
24 deletion
+185
-24
demo/advanced.yaml
demo/advanced.yaml
+4
-0
demo/test.yaml
demo/test.yaml
+1
-1
res/res.go
res/res.go
+3
-3
src/gen/definition.go
src/gen/definition.go
+5
-1
src/gen/field.go
src/gen/field.go
+22
-0
src/gen/generator.go
src/gen/generator.go
+1
-1
src/gen/intVal.go
src/gen/intVal.go
+3
-3
src/gen/list.go
src/gen/list.go
+2
-9
src/gen/timestamp.go
src/gen/timestamp.go
+134
-0
src/model/definition.go
src/model/definition.go
+1
-0
src/utils/const/const.go
src/utils/const/const.go
+8
-5
src/utils/log/print.go
src/utils/log/print.go
+1
-1
未找到文件。
demo/advanced.yaml
浏览文件 @
4816fdca
...
@@ -57,3 +57,7 @@ fields:
...
@@ -57,3 +57,7 @@ fields:
range
:
"
`0000-00`,`AA[2,a-z]`,[1-3]:2{3},`[1-3]:2{3}`"
range
:
"
`0000-00`,`AA[2,a-z]`,[1-3]:2{3},`[1-3]:2{3}`"
type
:
text
type
:
text
-
field
:
field_timestamp
range
:
today-aa:10
type
:
timestamp
demo/test.yaml
浏览文件 @
4816fdca
...
@@ -3,7 +3,7 @@ desc:
...
@@ -3,7 +3,7 @@ desc:
author
:
zentao
author
:
zentao
version
:
1.0
version
:
1.0
from
:
custom
.ip.private.yaml
from
:
jenkins
.ip.private.yaml
fields
:
fields
:
-
field
:
field_use_instance
-
field
:
field_use_instance
...
...
res/res.go
浏览文件 @
4816fdca
此差异已折叠。
点击以展开。
src/gen/definition.go
浏览文件 @
4816fdca
...
@@ -85,7 +85,7 @@ func mergerDefine(defaultDef, configDef *model.DefData, fieldsToExport *[]string
...
@@ -85,7 +85,7 @@ func mergerDefine(defaultDef, configDef *model.DefData, fieldsToExport *[]string
}
else
if
defaultDef
.
Type
!=
""
{
}
else
if
defaultDef
.
Type
!=
""
{
vari
.
Type
=
defaultDef
.
Type
vari
.
Type
=
defaultDef
.
Type
}
else
{
}
else
{
vari
.
Type
=
constant
.
TypeText
vari
.
Type
=
constant
.
Config
TypeText
}
}
if
configDef
.
From
!=
""
&&
defaultDef
.
From
==
""
{
if
configDef
.
From
!=
""
&&
defaultDef
.
From
==
""
{
...
@@ -210,6 +210,10 @@ func CopyField(child model.DefField, parent *model.DefField) {
...
@@ -210,6 +210,10 @@ func CopyField(child model.DefField, parent *model.DefField) {
(
*
parent
)
.
From
=
child
.
From
(
*
parent
)
.
From
=
child
.
From
}
}
if
child
.
Type
!=
""
{
(
*
parent
)
.
Type
=
child
.
Type
}
if
child
.
Precision
!=
0
{
if
child
.
Precision
!=
0
{
(
*
parent
)
.
Precision
=
child
.
Precision
(
*
parent
)
.
Precision
=
child
.
Precision
}
}
...
...
src/gen/field.go
0 → 100644
浏览文件 @
4816fdca
package
gen
import
(
"github.com/easysoft/zendata/src/model"
constant
"github.com/easysoft/zendata/src/utils/const"
)
func
CreateField
(
field
*
model
.
DefField
)
model
.
FieldWithValues
{
fieldWithValue
:=
model
.
FieldWithValues
{}
if
field
.
Type
==
""
{
// set default
field
.
Type
=
constant
.
FieldTypeList
}
if
field
.
Type
==
constant
.
FieldTypeList
{
CreateListField
(
field
,
&
fieldWithValue
)
}
else
if
field
.
Type
==
constant
.
FieldTypeTimestamp
{
CreateTimestampField
(
field
,
&
fieldWithValue
)
}
return
fieldWithValue
}
\ No newline at end of file
src/gen/generator.go
浏览文件 @
4816fdca
...
@@ -171,7 +171,7 @@ func GenerateForField(field *model.DefField, withFix bool) (values []string) {
...
@@ -171,7 +171,7 @@ func GenerateForField(field *model.DefField, withFix bool) (values []string) {
func
GenerateFieldValuesForDef
(
field
*
model
.
DefField
)
[]
string
{
func
GenerateFieldValuesForDef
(
field
*
model
.
DefField
)
[]
string
{
values
:=
make
([]
string
,
0
)
values
:=
make
([]
string
,
0
)
fieldWithValues
:=
Create
List
(
field
)
fieldWithValues
:=
Create
Field
(
field
)
computerLoop
(
field
)
computerLoop
(
field
)
indexOfRow
:=
0
indexOfRow
:=
0
...
...
src/gen/intVal.go
浏览文件 @
4816fdca
...
@@ -5,11 +5,11 @@ import (
...
@@ -5,11 +5,11 @@ import (
constant
"github.com/easysoft/zendata/src/utils/const"
constant
"github.com/easysoft/zendata/src/utils/const"
)
)
func
GenerateIntItems
(
start
int64
,
end
int64
,
step
interface
{},
rand
bool
,
limi
t
int
)
[]
interface
{}
{
func
GenerateIntItems
(
start
int64
,
end
int64
,
step
interface
{},
rand
bool
,
repea
t
int
)
[]
interface
{}
{
if
!
rand
{
if
!
rand
{
return
GenerateIntItemsByStep
(
start
,
end
,
step
.
(
int
),
limi
t
)
return
GenerateIntItemsByStep
(
start
,
end
,
step
.
(
int
),
repea
t
)
}
else
{
}
else
{
return
GenerateIntItemsRand
(
start
,
end
,
step
.
(
int
),
limi
t
)
return
GenerateIntItemsRand
(
start
,
end
,
step
.
(
int
),
repea
t
)
}
}
}
}
...
...
src/gen/list.go
浏览文件 @
4816fdca
...
@@ -8,13 +8,6 @@ import (
...
@@ -8,13 +8,6 @@ import (
"strings"
"strings"
)
)
func
CreateList
(
field
*
model
.
DefField
)
model
.
FieldWithValues
{
fieldWithValue
:=
model
.
FieldWithValues
{}
CreateListField
(
field
,
&
fieldWithValue
)
return
fieldWithValue
}
func
CreateListField
(
field
*
model
.
DefField
,
fieldWithValue
*
model
.
FieldWithValues
)
{
func
CreateListField
(
field
*
model
.
DefField
,
fieldWithValue
*
model
.
FieldWithValues
)
{
fieldWithValue
.
Field
=
field
.
Field
fieldWithValue
.
Field
=
field
.
Field
fieldWithValue
.
Precision
=
field
.
Precision
fieldWithValue
.
Precision
=
field
.
Precision
...
@@ -25,11 +18,11 @@ func CreateListField(field *model.DefField, fieldWithValue *model.FieldWithValue
...
@@ -25,11 +18,11 @@ func CreateListField(field *model.DefField, fieldWithValue *model.FieldWithValue
CreateListField
(
&
child
,
&
childFieldWithValue
)
CreateListField
(
&
child
,
&
childFieldWithValue
)
}
}
}
else
{
}
else
{
CreateFieldValues
(
field
,
fieldWithValue
)
Create
List
FieldValues
(
field
,
fieldWithValue
)
}
}
}
}
func
CreateFieldValues
(
field
*
model
.
DefField
,
fieldValue
*
model
.
FieldWithValues
)
{
func
Create
List
FieldValues
(
field
*
model
.
DefField
,
fieldValue
*
model
.
FieldWithValues
)
{
if
strings
.
Index
(
field
.
Range
,
".txt"
)
>
-
1
{
if
strings
.
Index
(
field
.
Range
,
".txt"
)
>
-
1
{
CreateFieldValuesFromText
(
field
,
fieldValue
)
CreateFieldValuesFromText
(
field
,
fieldValue
)
}
else
{
}
else
{
...
...
src/gen/timestamp.go
0 → 100644
浏览文件 @
4816fdca
package
gen
import
(
"github.com/easysoft/zendata/src/model"
constant
"github.com/easysoft/zendata/src/utils/const"
"strconv"
"strings"
"time"
)
func
CreateTimestampField
(
field
*
model
.
DefField
,
fieldWithValue
*
model
.
FieldWithValues
)
{
fieldWithValue
.
Field
=
field
.
Field
rang
:=
strings
.
Trim
(
strings
.
TrimSpace
(
field
.
Range
),
","
)
rangeSections
:=
strings
.
Split
(
rang
,
","
)
values
:=
make
([]
interface
{},
0
)
for
_
,
section
:=
range
rangeSections
{
createTimestampSectionValue
(
section
,
&
values
)
}
if
len
(
values
)
==
0
{
values
=
append
(
values
,
"N/A"
)
}
fieldWithValue
.
Values
=
values
}
func
createTimestampSectionValue
(
section
string
,
values
*
[]
interface
{})
{
desc
,
step
:=
parseTsSection
(
section
)
start
,
end
:=
parseTsDesc
(
desc
)
if
step
>
0
&&
start
>
end
{
step
*=
-
1
}
// get index numbers for data retrieve
numbs
:=
GenerateIntItems
(
start
,
end
,
step
,
false
,
1
)
// generate data by index
index
:=
0
for
_
,
numb
:=
range
numbs
{
if
index
>=
constant
.
MaxNumb
{
break
}
*
values
=
append
(
*
values
,
numb
)
index
=
index
+
1
}
}
func
parseTsSection
(
section
string
)
(
desc
string
,
step
int
)
{
section
=
strings
.
TrimSpace
(
section
)
sectionArr
:=
strings
.
Split
(
section
,
":"
)
desc
=
sectionArr
[
0
]
step
=
1
if
len
(
sectionArr
)
>
1
{
stepStr
:=
sectionArr
[
1
]
stepTemp
,
err
:=
strconv
.
Atoi
(
stepStr
)
if
err
==
nil
{
step
=
stepTemp
}
}
return
}
func
parseTsDesc
(
desc
string
)
(
start
,
end
int64
)
{
desc
=
strings
.
TrimSpace
(
desc
)
if
desc
==
"today"
{
start
,
end
=
getTodayTs
()
return
}
arr
:=
strings
.
Split
(
desc
,
"-"
)
startStr
:=
arr
[
0
]
endStr
:=
""
if
len
(
arr
)
>
1
{
endStr
=
arr
[
1
]
}
if
endStr
==
""
{
endStr
=
startStr
}
start
=
parseTsValue
(
startStr
,
true
)
end
=
parseTsValue
(
endStr
,
false
)
return
}
func
parseTsValue
(
str
string
,
isStart
bool
)
(
value
int64
)
{
str
=
strings
.
TrimSpace
(
str
)
if
strings
.
Contains
(
str
,
"now"
)
{
value
=
time
.
Now
()
.
Unix
()
return
}
else
if
str
==
"today"
{
start
,
end
:=
getTodayTs
()
if
isStart
{
value
=
start
}
else
{
value
=
end
}
return
}
tm
,
err
:=
time
.
Parse
(
"20060102"
,
str
)
if
err
!=
nil
{
todayStart
,
todayEnd
:=
getTodayTs
()
if
isStart
{
value
=
todayStart
}
else
{
value
=
todayEnd
}
}
else
{
if
!
isStart
{
tm
=
time
.
Date
(
tm
.
Year
(),
tm
.
Month
(),
tm
.
Day
(),
23
,
59
,
59
,
0
,
tm
.
Location
())
}
value
=
tm
.
Unix
()
}
return
}
func
getTodayTs
()
(
start
,
end
int64
)
{
now
:=
time
.
Now
()
start
=
time
.
Date
(
now
.
Year
(),
now
.
Month
(),
now
.
Day
(),
0
,
0
,
0
,
0
,
now
.
Location
())
.
Unix
()
end
=
time
.
Date
(
now
.
Year
(),
now
.
Month
(),
now
.
Day
(),
23
,
59
,
59
,
0
,
now
.
Location
())
.
Unix
()
return
}
\ No newline at end of file
src/model/definition.go
浏览文件 @
4816fdca
...
@@ -78,6 +78,7 @@ type FieldSimple struct {
...
@@ -78,6 +78,7 @@ type FieldSimple struct {
Loopfix
string
`yaml:"loopfix"`
Loopfix
string
`yaml:"loopfix"`
Format
string
`yaml:"format"`
Format
string
`yaml:"format"`
Rand
bool
`yaml:"rand"`
Rand
bool
`yaml:"rand"`
Type
string
`yaml:"type"`
LoopStart
int
`yaml:"-"`
LoopStart
int
`yaml:"-"`
LoopEnd
int
`yaml:"-"`
LoopEnd
int
`yaml:"-"`
...
...
src/utils/const/const.go
浏览文件 @
4816fdca
...
@@ -38,11 +38,14 @@ var (
...
@@ -38,11 +38,14 @@ var (
FormatData
=
"data"
FormatData
=
"data"
Formats
=
[]
string
{
FormatText
,
FormatJson
,
FormatXml
,
FormatSql
}
Formats
=
[]
string
{
FormatText
,
FormatJson
,
FormatXml
,
FormatSql
}
TypeText
=
"text"
ConfigTypeText
=
"text"
TypeImage
=
"image"
ConfigTypeArticle
=
"article"
TypeVoice
=
"voice"
ConfigTypeImage
=
"image"
TypeVideo
=
"video"
ConfigTypeVoice
=
"voice"
TypeArticle
=
"article"
ConfigTypeVideo
=
"video"
FieldTypeList
=
"list"
FieldTypeTimestamp
=
"timestamp"
LeftBrackets
rune
=
'('
LeftBrackets
rune
=
'('
RightBrackets
rune
=
')'
RightBrackets
rune
=
')'
...
...
src/utils/log/print.go
浏览文件 @
4816fdca
...
@@ -80,7 +80,7 @@ func PrintErrMsg(msg string) {
...
@@ -80,7 +80,7 @@ func PrintErrMsg(msg string) {
}
}
func
PrintLine
(
line
string
)
{
func
PrintLine
(
line
string
)
{
if
vari
.
Type
==
constant
.
TypeText
{
if
vari
.
Type
==
constant
.
Config
TypeText
{
line
+=
"
\n
"
line
+=
"
\n
"
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录