Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
dd1cb5f7
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 搜索 >>
提交
dd1cb5f7
编写于
10月 19, 2022
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix issues
上级
817d708f
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
53 addition
and
32 deletion
+53
-32
.gitignore
.gitignore
+1
-0
.zd.conf
.zd.conf
+1
-1
cmd/command/main.go
cmd/command/main.go
+3
-3
demo/default.yaml
demo/default.yaml
+3
-3
demo/t.yaml
demo/t.yaml
+26
-9
internal/agent/agent.go
internal/agent/agent.go
+6
-4
internal/pkg/action/generator.go
internal/pkg/action/generator.go
+3
-3
internal/pkg/gen/list.go
internal/pkg/gen/list.go
+1
-1
internal/pkg/gen/printer.go
internal/pkg/gen/printer.go
+1
-1
internal/pkg/model/domain.go
internal/pkg/model/domain.go
+1
-0
pkg/utils/log/print.go
pkg/utils/log/print.go
+1
-1
res/en/usage.txt
res/en/usage.txt
+3
-3
res/zh/usage.txt
res/zh/usage.txt
+3
-3
未找到文件。
.gitignore
浏览文件 @
dd1cb5f7
...
...
@@ -30,3 +30,4 @@
/runtime/protobuf/out/
/users/common/
*.exe
/tmp/cache/.data.db
.zd.conf
浏览文件 @
dd1cb5f7
Version
=
2
.
2
Version
=
2
.
2
Language
=
zh
cmd/command/main.go
浏览文件 @
dd1cb5f7
...
...
@@ -114,9 +114,6 @@ func main() {
flagSet
.
BoolVar
(
&
example
,
"e"
,
false
,
""
)
flagSet
.
BoolVar
(
&
example
,
"example"
,
false
,
""
)
flagSet
.
BoolVar
(
&
help
,
"h"
,
false
,
""
)
flagSet
.
BoolVar
(
&
help
,
"help"
,
false
,
""
)
flagSet
.
BoolVar
(
&
set
,
"S"
,
false
,
""
)
flagSet
.
BoolVar
(
&
set
,
"set"
,
false
,
""
)
...
...
@@ -131,6 +128,9 @@ func main() {
flagSet
.
BoolVar
(
&
vari
.
Verbose
,
"verbose"
,
false
,
""
)
flagSet
.
BoolVar
(
&
help
,
"h"
,
false
,
""
)
flagSet
.
BoolVar
(
&
help
,
"help"
,
false
,
""
)
if
len
(
os
.
Args
)
==
1
{
os
.
Args
=
append
(
os
.
Args
,
"-help"
)
}
...
...
demo/default.yaml
浏览文件 @
dd1cb5f7
...
...
@@ -104,9 +104,9 @@ fields:
range
:
user.txt:R
# 相对当前文件路径。
postfix
:
"
\t
"
#
- field: field_yaml # 引用其他的定义文件整体内容。
#
range: 01_range.yaml{3} # 相对当前文件路径。
#
postfix: "\t"
-
field
:
field_yaml
# 引用其他的定义文件整体内容。
range
:
01_range.yaml{3}
# 相对当前文件路径。
postfix
:
"
\t
"
-
field
:
field_use_config
# 引用其他的config定义文件。
config
:
number.yaml
# 相对当前文件路径,config内包含单个字段。
...
...
demo/t.yaml
浏览文件 @
dd1cb5f7
title
:
zendata数据配置语法说明
desc
:
author
:
zentao
title
:
range
desc
:
描述
version
:
1.0
fields
:
-
field
:
f1
from
:
uuid.v1.yaml
use
:
by_format
range
:
1-6
postfix
:
"
\t
"
-
field
:
nesting1
postfix
:
"
\t
"
union
:
true
fields
:
-
field
:
child1
range
:
A-C
prefix
:
part1_
postfix
:
'
|
'
-
field
:
child2
range
:
1-9
prefix
:
part2_
-
field
:
nesting2
fields
:
-
field
:
child1
range
:
A-C
prefix
:
part1_
postfix
:
'
|
'
-
field
:
f2
from
:
ulid.v1.yaml
use
:
ulid{3}
\ No newline at end of file
-
field
:
child2
range
:
1-9
prefix
:
part2_
\ No newline at end of file
internal/agent/agent.go
浏览文件 @
dd1cb5f7
...
...
@@ -14,9 +14,9 @@ import (
)
var
(
configs
[]
string
defaultFile
string
configFile
string
configs
[]
string
defaultFile
string
configFile
string
defaultDefContent
[]
byte
configDefContent
[]
byte
...
...
@@ -61,6 +61,8 @@ func DataHandler(writer http.ResponseWriter, req *http.Request) {
defaultFile
=
""
configFile
=
""
}
//writer.WriteHeader(http.StatusAccepted)
}
func
genData
()
{
...
...
@@ -85,4 +87,4 @@ func genData() {
dur
:=
tmEnd
.
Unix
()
-
tmStart
.
Unix
()
logUtils
.
PrintTo
(
fmt
.
Sprintf
(
"Duriation %d sec."
,
dur
))
}
}
\ No newline at end of file
}
internal/pkg/action/generator.go
浏览文件 @
dd1cb5f7
...
...
@@ -13,7 +13,7 @@ import (
"time"
)
func
Generate
(
files
[]
string
,
fieldsToExportStr
,
format
,
table
string
)
{
func
Generate
(
files
[]
string
,
fieldsToExportStr
,
format
,
table
string
)
(
lines
[]
interface
{})
{
startTime
:=
time
.
Now
()
.
Unix
()
if
len
(
files
)
==
0
{
return
...
...
@@ -28,7 +28,7 @@ func Generate(files []string, fieldsToExportStr, format, table string) {
vari
.
ConfigFileDir
=
fileUtils
.
GetAbsDir
(
files
[
1
])
}
contents
:=
gen
.
LoadFilesContents
(
files
)
GenerateByContent
(
contents
,
fieldsToExportStr
,
format
,
table
)
lines
=
GenerateByContent
(
contents
,
fieldsToExportStr
,
format
,
table
)
}
else
{
// gen from protobuf
buf
,
pth
:=
gen
.
GenerateFromProtobuf
(
files
[
0
])
...
...
@@ -94,7 +94,7 @@ func GenerateByContent(contents [][]byte, fieldsToExportStr, format, table strin
}
if
!
isFromExcel
(
format
)
{
// returned is for preview, sql exec and article writing
lines
=
gen
.
Print
(
rows
,
format
,
table
,
colIsNumArr
,
fieldsToExport
)
lines
=
gen
.
Print
Lines
(
rows
,
format
,
table
,
colIsNumArr
,
fieldsToExport
)
}
else
{
// for Excel and cvs
gen
.
Write
(
rows
,
table
,
colIsNumArr
,
fieldsToExport
)
}
...
...
internal/pkg/gen/list.go
浏览文件 @
dd1cb5f7
...
...
@@ -349,7 +349,7 @@ func CreateValuesFromYaml(field *model.DefField, yamlFile, stepStr string, repea
rows
=
randomValuesArr
(
rows
)
}
items
=
Print
(
rows
,
constant
.
FormatData
,
""
,
colIsNumArr
,
fieldsToExport
)
items
=
Print
Lines
(
rows
,
constant
.
FormatData
,
""
,
colIsNumArr
,
fieldsToExport
)
if
repeat
>
0
{
if
repeat
>
len
(
items
)
{
...
...
internal/pkg/gen/printer.go
浏览文件 @
dd1cb5f7
...
...
@@ -14,7 +14,7 @@ import (
"github.com/easysoft/zendata/pkg/utils/vari"
)
func
Print
(
rows
[][]
string
,
format
string
,
table
string
,
colIsNumArr
[]
bool
,
func
Print
Lines
(
rows
[][]
string
,
format
string
,
table
string
,
colIsNumArr
[]
bool
,
fields
[]
string
)
(
lines
[]
interface
{})
{
var
sqlHeader
string
...
...
internal/pkg/model/domain.go
浏览文件 @
dd1cb5f7
...
...
@@ -55,6 +55,7 @@ type DefField struct {
RightPad
string
`yaml:"rightpad,omitempty"`
Path
string
`yaml:"path,omitempty"`
FileDir
string
`yaml:"fileDir,omitempty"`
Union
bool
`yaml:"union,omitempty"`
Froms
[]
DefField
`yaml:"froms,flow,omitempty"`
}
...
...
pkg/utils/log/print.go
浏览文件 @
dd1cb5f7
...
...
@@ -51,7 +51,7 @@ func PrintUsage() {
regx
,
_
=
regexp
.
Compile
(
`zd.exe`
)
usage
=
regx
.
ReplaceAllString
(
usage
,
"zd"
)
regx
,
_
=
regexp
.
Compile
(
`d:
/zd/
config `
)
regx
,
_
=
regexp
.
Compile
(
`d:
\zd\
config `
)
usage
=
regx
.
ReplaceAllString
(
usage
,
"/home/user/zd/config"
)
}
fmt
.
Printf
(
"%s
\n
"
,
usage
)
...
...
res/en/usage.txt
浏览文件 @
dd1cb5f7
...
...
@@ -67,6 +67,6 @@ $zd.exe -p 80 -R d:\zd\config # Listen port 80. Use d:\zd\config as th
Client Call:
$curl http:
\\localhost:8848\?d=demo\default.yaml&c=demo\
config.yaml&n=100&T=true # Specify the server config file via GET.
$curl http:
\\localhost:8848\?default=demo\
default.yaml&output=test.sql&table=user # Parameter names can be full.
$curl -i -X POST http:
\\localhost:8848?lines=3 -F default=@demo\default.yaml
# The config can be uploaded via POST.
$curl http:
//localhost:8848/data?d=demo/default.yaml&c=demo/
config.yaml&n=100&T=true # Specify the server config file via GET.
$curl http:
//localhost:8848/data?default=demo/
default.yaml&output=test.sql&table=user # Parameter names can be full.
$curl -i -X POST http:
//localhost:8848/data?lines=3 -F default=@demo/default.yaml
# The config can be uploaded via POST.
res/zh/usage.txt
浏览文件 @
dd1cb5f7
...
...
@@ -62,6 +62,6 @@ $zd.exe -p 80 -R d:\zd\config # 监听80
客户端调用:
$curl http://localhost:8848/?d=demo/default.yaml&c=demo/config.yaml&n=100&T=true # 通过GET方式指定服务器端配置文件。
$curl http://localhost:8848/?default=demo/default.yaml&output=test.sql&table=user # 参数名可以用全拼。
$curl -i -X POST http://localhost:8848
?lines=3 -F default=@demo/default.yaml
# 可以通过POST方式上传配置文件。
$curl http://localhost:8848/
data
?d=demo/default.yaml&c=demo/config.yaml&n=100&T=true # 通过GET方式指定服务器端配置文件。
$curl http://localhost:8848/
data
?default=demo/default.yaml&output=test.sql&table=user # 参数名可以用全拼。
$curl -i -X POST http://localhost:8848
/data?lines=3 -F default=@demo/default.yaml
# 可以通过POST方式上传配置文件。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录