Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
f7614b73
Z
zendata
项目概览
易企天创
/
zendata
8 个月 前同步成功
通知
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 搜索 >>
提交
f7614b73
编写于
8月 04, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test post request
上级
5524be68
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
22 addition
and
21 deletion
+22
-21
res/en/usage.txt
res/en/usage.txt
+1
-1
res/zh/usage.txt
res/zh/usage.txt
+1
-1
src/gen/definition.go
src/gen/definition.go
+17
-8
src/service/request.go
src/service/request.go
+1
-0
src/utils/http/http.go
src/utils/http/http.go
+2
-11
未找到文件。
res/en/usage.txt
浏览文件 @
f7614b73
...
...
@@ -41,7 +41,7 @@ $>zd.exe -d demo/default.yaml -c demo/test.yaml -n 100 # Using the parameter of
$>zd.exe -d demo/default.yaml -c demo/test.yaml -n 100 -o test.txt # Output data in original format.
$>zd.exe -d demo/default.yaml -c demo/test.yaml -n 100 -o test.json # Output data in JSON.
$>zd.exe -d demo/default.yaml -c demo/test.yaml -n 100 -o test.xml # Output data in XML.
$>zd.exe -d demo/default.yaml -n 100 -o test.sql -t user
-s mysql
# Output the sql inserted into the table user.
$>zd.exe -d demo/default.yaml -n 100 -o test.sql -t user
# Output the sql inserted into the table user.
$>zd.exe -d demo/default.yaml -o test.sql -t user -s mysql --trim # Remove the prefix and postfix of every field.
$>zd.exe -i db.sql -o db # Generate YAML files for each table by parsing db.sql and store them in the db directory.
...
...
res/zh/usage.txt
浏览文件 @
f7614b73
...
...
@@ -35,7 +35,7 @@ $>zd.exe -d demo\default.yaml -c demo\test.yaml -n 100 -c和-d两个文件的
$>zd.exe -d demo\default.yaml -c demo\test.yaml -n 100 -o test.txt 输出原始格式的数据。
$>zd.exe -d demo\default.yaml -c demo\test.yaml -n 100 -o test.json 输出json格式的数据。
$>zd.exe -d demo\default.yaml -c demo\test.yaml -n 100 -o test.xml 输出xml格式的数据。
$>zd.exe -d demo\default.yaml -n 100 -o test.sql -t user
-s mysql
输出插入到user表里面的sql。
$>zd.exe -d demo\default.yaml -n 100 -o test.sql -t user
输出插入到user表里面的sql。
$>zd.exe -i db.sql -o db 根据db.sql的定义生成每个表的yaml文件,存储到db目录里面。
$>zd.exe -c demo\default.yaml -i test.txt --decode 将-i指定的文件根据-d参数的配置进行解析。
...
...
src/gen/definition.go
浏览文件 @
f7614b73
...
...
@@ -3,6 +3,7 @@ package gen
import
(
"github.com/easysoft/zendata/src/model"
constant
"github.com/easysoft/zendata/src/utils/const"
fileUtils
"github.com/easysoft/zendata/src/utils/file"
i118Utils
"github.com/easysoft/zendata/src/utils/i118"
logUtils
"github.com/easysoft/zendata/src/utils/log"
"github.com/easysoft/zendata/src/utils/vari"
...
...
@@ -17,32 +18,40 @@ func LoadConfigDef(defaultFile, configFile string, fieldsToExport *[]string) mod
configDef
:=
model
.
DefData
{}
// load defaultDef
path
:=
vari
.
ExeDir
+
defaultFile
if
defaultFile
!=
""
{
defaultContent
,
err
:=
ioutil
.
ReadFile
(
path
)
pathDefaultFile
:=
defaultFile
if
!
fileUtils
.
IsAbosutePath
(
pathDefaultFile
)
{
pathDefaultFile
=
vari
.
ExeDir
+
pathDefaultFile
}
defaultContent
,
err
:=
ioutil
.
ReadFile
(
pathDefaultFile
)
defaultContent
=
ReplaceSpecialChars
(
defaultContent
)
if
err
!=
nil
{
logUtils
.
PrintToWithColor
(
i118Utils
.
I118Prt
.
Sprintf
(
"fail_to_read_file"
,
path
),
color
.
FgCyan
)
logUtils
.
PrintToWithColor
(
i118Utils
.
I118Prt
.
Sprintf
(
"fail_to_read_file"
,
path
DefaultFile
),
color
.
FgCyan
)
return
defaultDef
}
err
=
yaml
.
Unmarshal
(
defaultContent
,
&
defaultDef
)
if
err
!=
nil
{
logUtils
.
PrintToWithColor
(
i118Utils
.
I118Prt
.
Sprintf
(
"fail_to_read_file"
,
path
),
color
.
FgCyan
)
logUtils
.
PrintToWithColor
(
i118Utils
.
I118Prt
.
Sprintf
(
"fail_to_read_file"
,
path
DefaultFile
),
color
.
FgCyan
)
return
defaultDef
}
}
// load configDef
path
=
vari
.
ExeDir
+
configFile
yamlContent
,
err
:=
ioutil
.
ReadFile
(
path
)
pathConfigFile
:=
configFile
if
!
fileUtils
.
IsAbosutePath
(
pathConfigFile
)
{
pathConfigFile
=
vari
.
ExeDir
+
pathConfigFile
}
yamlContent
,
err
:=
ioutil
.
ReadFile
(
pathConfigFile
)
yamlContent
=
ReplaceSpecialChars
(
yamlContent
)
if
err
!=
nil
{
logUtils
.
PrintToWithColor
(
i118Utils
.
I118Prt
.
Sprintf
(
"fail_to_read_file"
,
path
),
color
.
FgCyan
)
logUtils
.
PrintToWithColor
(
i118Utils
.
I118Prt
.
Sprintf
(
"fail_to_read_file"
,
path
ConfigFile
),
color
.
FgCyan
)
return
configDef
}
err
=
yaml
.
Unmarshal
(
yamlContent
,
&
configDef
)
if
err
!=
nil
{
logUtils
.
PrintToWithColor
(
i118Utils
.
I118Prt
.
Sprintf
(
"fail_to_parse_file"
,
path
),
color
.
FgCyan
)
logUtils
.
PrintToWithColor
(
i118Utils
.
I118Prt
.
Sprintf
(
"fail_to_parse_file"
,
path
ConfigFile
),
color
.
FgCyan
)
return
configDef
}
...
...
src/service/request.go
浏览文件 @
f7614b73
...
...
@@ -28,6 +28,7 @@ func ParseRequestParams(req *http.Request) (defaultFile, yamlFile, fields string
human
=
GetRequestParams
(
query
,
"human"
,
"H"
)
if
req
.
Method
==
http
.
MethodPost
{
// save to files
req
.
ParseForm
()
defaultDefContent
:=
req
.
FormValue
(
"default"
)
configDefContent
:=
req
.
FormValue
(
"config"
)
...
...
src/utils/http/http.go
浏览文件 @
f7614b73
...
...
@@ -7,7 +7,6 @@ import (
"log"
"net/http"
"net/url"
"strings"
)
func
PostForm
(
urlStr
string
,
data
url
.
Values
)
(
interface
{},
bool
)
{
...
...
@@ -33,15 +32,7 @@ func PostForm(urlStr string, data url.Values) (interface{}, bool) {
return
body
,
true
}
func
GenUrl
(
server
string
,
path
string
)
string
{
server
=
UpdateUrl
(
server
)
url
:=
fmt
.
Sprintf
(
"%s%s"
,
server
,
path
)
return
url
}
func
UpdateUrl
(
url
string
)
string
{
if
strings
.
LastIndex
(
url
,
"/"
)
<
len
(
url
)
-
1
{
url
+=
"/"
}
func
GenUrl
(
server
string
,
port
int
,
path
string
)
string
{
url
:=
fmt
.
Sprintf
(
"http://%s:%d/%s"
,
server
,
port
,
path
)
return
url
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录