Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
zendata
提交
48054864
Z
zendata
项目概览
LinuxSuRen
/
zendata
与 Fork 源项目一致
Fork自
易企天创 / zendata
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zendata
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
48054864
编写于
6月 19, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update build script for windows
上级
9a897af0
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
51 addition
and
8 deletion
+51
-8
res/doc/sample.txt
res/doc/sample.txt
+3
-0
res/doc/usage.txt
res/doc/usage.txt
+2
-1
res/messages_en.json
res/messages_en.json
+4
-0
res/messages_zh.json
res/messages_zh.json
+4
-0
src/action/generator.go
src/action/generator.go
+33
-7
src/utils/vari/var.go
src/utils/vari/var.go
+3
-0
src/zd.go
src/zd.go
+2
-0
未找到文件。
res/doc/sample.txt
浏览文件 @
48054864
...
...
@@ -3,6 +3,9 @@
$>zd.exe -y demo/test.yaml -c 15 -field field1 -o demo/output.txt -f text
执行数据生成命令。使用配置文件demo/test.yaml,生成15行数据,以text格式的输出到demo/output.txt文件中。
$>zd.exe -y demo/test.yaml -c 15 -s
执行数据生成命令。使用配置文件demo/test.yaml,生成15行数据,以行列的json形式输出到http://<ip_address/data接口。
$>zd.exe -y demo/test.yaml -c 15 -field field1 -o demo/insert.sql -f sql -t table_name
执行数据生成命令。以SQL语句形式输出到demo/insert.sql文件中,表名为table_name。
...
...
res/doc/usage.txt
浏览文件 @
48054864
...
...
@@ -7,8 +7,9 @@
-c --count 指定生成数据的条数
--field 需要输出的字段,用逗号分隔。未指定时,默认输出-yaml文件中的所有字段。
-o --out 指定输出文件
-f --format
输出格式,支持text、json、xml和sql语句,默认为text。
-f --format 输出格式,支持text、json、xml和sql语句,默认为text。
-t --table 输出格式为table时,用于指定insert语句的表名
-s --service 启动http服务,用户可从http://<ip_address/data接口获取json格式的行列数据。
--verbose 增加此参数,显示详细调试信息。
为了方便在任意目录中执行%s命令,建议将其加入环境变量中,具体方法参照以下地址。
...
...
res/messages_en.json
浏览文件 @
48054864
...
...
@@ -84,6 +84,10 @@
{
"id"
:
"generate_yaml"
,
"translation"
:
"Generate %d yaml files in %s, spend %d secs."
},
{
"id"
:
"press_to_exist"
,
"translation"
:
"Press ctrl+c to exist."
}
]
}
\ No newline at end of file
res/messages_zh.json
浏览文件 @
48054864
...
...
@@ -75,6 +75,10 @@
{
"id"
:
"generate_yaml"
,
"translation"
:
"生成%d个yaml文件于目录%s中, 耗时%d秒。"
},
{
"id"
:
"press_to_exist"
,
"translation"
:
"按ctrl+c键推出。"
}
]
}
\ No newline at end of file
src/action/generator.go
浏览文件 @
48054864
...
...
@@ -7,8 +7,11 @@ import (
"github.com/easysoft/zendata/src/gen"
"github.com/easysoft/zendata/src/model"
constant
"github.com/easysoft/zendata/src/utils/const"
i118Utils
"github.com/easysoft/zendata/src/utils/i118"
logUtils
"github.com/easysoft/zendata/src/utils/log"
"github.com/easysoft/zendata/src/utils/vari"
"github.com/fatih/color"
"net/http"
"os"
"path/filepath"
"strings"
...
...
@@ -31,17 +34,30 @@ func Generate(deflt string, yml string, total int, fieldsToExportStr string, out
constant
.
Total
=
total
rows
,
colTypes
:=
gen
.
GenerateForDefinition
(
deflt
,
yml
,
&
fieldsToExport
,
total
)
content
:=
Print
(
rows
,
format
,
table
,
colTypes
,
fieldsToExport
)
var
content
string
content
,
vari
.
JsonResp
=
Print
(
rows
,
format
,
table
,
colTypes
,
fieldsToExport
)
if
out
!=
""
{
WriteToFile
(
out
,
content
)
}
if
out
!=
""
{
WriteToFile
(
out
,
content
)
}
if
vari
.
HttpService
{
logUtils
.
PrintToWithColor
(
i118Utils
.
I118Prt
.
Sprintf
(
"press_to_exist"
),
color
.
FgCyan
)
http
.
HandleFunc
(
"/"
,
DataHandler
)
http
.
HandleFunc
(
"/data"
,
DataHandler
)
http
.
ListenAndServe
(
":58848"
,
nil
)
}
//entTime := time.Now().Unix()
//logUtils.Screen(i118Utils.I118Prt.Sprintf("generate_records", len(rows), out, entTime - startTime ))
}
func
Print
(
rows
[][]
string
,
format
string
,
table
string
,
colTypes
[]
bool
,
fields
[]
string
)
string
{
func
Print
(
rows
[][]
string
,
format
string
,
table
string
,
colTypes
[]
bool
,
fields
[]
string
)
(
string
,
string
)
{
content
:=
""
sql
:=
""
...
...
@@ -86,15 +102,25 @@ func Print(rows [][]string, format string, table string, colTypes []bool, fields
}
}
if
format
==
"json"
{
json
,
_
:=
json
.
Marshal
(
rows
)
content
=
string
(
json
)
}
else
if
format
==
"xml"
{
jsonStr
:=
"[]"
if
format
==
"json"
||
vari
.
HttpService
{
jsonObj
,
_
:=
json
.
Marshal
(
rows
)
content
=
string
(
jsonObj
)
if
vari
.
HttpService
{
jsonStr
=
content
}
}
if
format
==
"xml"
{
xml
,
_
:=
xml
.
Marshal
(
testData
)
content
=
string
(
xml
)
}
else
if
format
==
"sql"
{
content
=
sql
}
return
content
return
content
,
jsonStr
}
func
DataHandler
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
fmt
.
Fprintln
(
w
,
vari
.
JsonResp
)
}
\ No newline at end of file
src/utils/vari/var
i
.go
→
src/utils/vari/var.go
浏览文件 @
48054864
...
...
@@ -21,4 +21,7 @@ var (
RequestType
string
Verbose
bool
Interpreter
string
HttpService
bool
JsonResp
string
=
"[]"
)
src/zd.go
浏览文件 @
48054864
...
...
@@ -69,6 +69,8 @@ func main() {
flagSet
.
StringVar
(
&
viewRes
,
"v"
,
""
,
""
)
flagSet
.
StringVar
(
&
viewDetail
,
"vv"
,
""
,
""
)
flagSet
.
BoolVar
(
&
vari
.
HttpService
,
"s"
,
false
,
""
)
flagSet
.
BoolVar
(
&
vari
.
Verbose
,
"verbose"
,
false
,
""
)
if
len
(
os
.
Args
)
==
1
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录