Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
zendata
提交
8c5cfc87
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 搜索 >>
提交
8c5cfc87
编写于
7月 28, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
close task#7494
上级
a33c0a47
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
10 deletion
+32
-10
demo/smoke.yaml
demo/smoke.yaml
+3
-3
src/action/generator.go
src/action/generator.go
+6
-7
src/utils/string/string.go
src/utils/string/string.go
+23
-0
未找到文件。
demo/smoke.yaml
浏览文件 @
8c5cfc87
...
...
@@ -26,12 +26,12 @@ fields:
loopfix
:
"
|"
postfix
:
"
\t
"
-
field
:
field
6
-
field
:
test
6
fields
:
-
field
:
child1
range
:
X-Z
prefix
:
postfix
:
"
\t
"
prefix
:
"
a'b"
postfix
:
"
\t
<:
\"
(`[]{}
"
-
field
:
child2
prefix
:
"
["
...
...
src/action/generator.go
浏览文件 @
8c5cfc87
...
...
@@ -9,6 +9,7 @@ import (
constant
"github.com/easysoft/zendata/src/utils/const"
i118Utils
"github.com/easysoft/zendata/src/utils/i118"
logUtils
"github.com/easysoft/zendata/src/utils/log"
stringUtils
"github.com/easysoft/zendata/src/utils/string"
"github.com/easysoft/zendata/src/utils/vari"
"net/http"
"os"
...
...
@@ -59,27 +60,24 @@ func Print(rows [][]string, format string, out string, table string, colTypes []
for
i
,
cols
:=
range
rows
{
row
:=
make
([]
string
,
0
)
rowXml
:=
model
.
XmlRow
{}
valuesForSql
:=
make
([]
string
,
0
)
lineForText
:=
""
valuesForSql
:=
""
for
j
,
col
:=
range
cols
{
if
j
>
0
&&
format
==
constant
.
FormatSql
{
valuesForSql
=
valuesForSql
+
", "
}
lineForText
=
lineForText
+
col
row
=
append
(
row
,
col
)
rowXml
.
Cols
=
append
(
rowXml
.
Cols
,
col
)
colVal
:=
col
colVal
:=
stringUtils
.
ConvertForSql
(
col
)
if
!
colTypes
[
j
]
{
colVal
=
"'"
+
colVal
+
"'"
}
valuesForSql
=
valuesForSql
+
colVal
valuesForSql
=
append
(
valuesForSql
,
colVal
)
}
if
format
==
constant
.
FormatText
{
printLine
(
lineForText
)
}
else
if
format
==
constant
.
FormatSql
{
printLine
(
genSqlLine
(
valuesForSql
,
i
,
len
(
rows
)))
printLine
(
genSqlLine
(
strings
.
Join
(
valuesForSql
,
", "
)
,
i
,
len
(
rows
)))
}
else
if
format
==
constant
.
FormatJson
{
printLine
(
genJsonLine
(
i
,
row
,
len
(
rows
),
fields
))
}
else
if
format
==
constant
.
FormatXml
{
...
...
@@ -132,6 +130,7 @@ func RowToJson(cols []string, fieldsToExport []string) string {
func
genSqlLine
(
valuesForSql
string
,
i
int
,
length
int
)
string
{
temp
:=
""
if
i
==
0
{
temp
=
fmt
.
Sprintf
(
" VALUES (%s)"
,
valuesForSql
)
...
...
src/utils/string/string.go
浏览文件 @
8c5cfc87
...
...
@@ -128,4 +128,27 @@ func AddPad(str string, field model.DefField) string {
}
return
str
}
func
ConvertForSql
(
str
string
)
(
ret
string
)
{
arr
:=
[]
rune
(
str
)
count
:=
0
for
_
,
item
:=
range
arr
{
if
count
%
2
==
1
&&
string
(
item
)
!=
"'"
{
ret
=
ret
+
"'"
}
if
string
(
item
)
!=
"'"
{
count
=
0
}
ret
=
ret
+
string
(
item
)
if
string
(
item
)
==
"'"
{
count
++
}
}
return
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录