Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
7f0f4d89
Z
zendata
项目概览
易企天创
/
zendata
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
7f0f4d89
编写于
11月 02, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
close task#8188
上级
12318e4f
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
38 addition
and
13 deletion
+38
-13
demo/advanced.yaml
demo/advanced.yaml
+7
-4
src/action/generator.go
src/action/generator.go
+1
-1
src/gen/printer.go
src/gen/printer.go
+1
-1
src/gen/writer.go
src/gen/writer.go
+28
-7
src/model/definition.go
src/model/definition.go
+1
-0
未找到文件。
demo/advanced.yaml
浏览文件 @
7f0f4d89
...
@@ -6,10 +6,8 @@ version: 1.0
...
@@ -6,10 +6,8 @@ version: 1.0
fields
:
fields
:
-
field
:
field_step_negative
# 区间指定步长。
-
field
:
field_step_negative
# 区间指定负数步长。
range
:
z-a:-2
# 9,7,5,4...
range
:
9-1:-2
# 9,7,5,4...
loop
:
1-3
loopfix
:
"
|"
prefix
:
"
["
prefix
:
"
["
postfix
:
"
]
\t
"
postfix
:
"
]
\t
"
...
@@ -25,6 +23,11 @@ fields:
...
@@ -25,6 +23,11 @@ fields:
prefix
:
"
["
prefix
:
"
["
postfix
:
"
]
\t
"
postfix
:
"
]
\t
"
-
field
:
field_value
# 引用同文件其他字段进行数学运算。
value
:
"
$field_step_negative
*
2
-
1"
prefix
:
"
["
postfix
:
"
]
\t
"
-
field
:
field_nested_range
-
field
:
field_nested_range
from
:
zentao.number.v1.yaml
# 引用用户自定义ranges,存于users目录下。
from
:
zentao.number.v1.yaml
# 引用用户自定义ranges,存于users目录下。
use
:
medium
use
:
medium
...
...
src/action/generator.go
浏览文件 @
7f0f4d89
...
@@ -28,7 +28,7 @@ func Generate(defaultFile string, configFile string, fieldsToExportStr, format,
...
@@ -28,7 +28,7 @@ func Generate(defaultFile string, configFile string, fieldsToExportStr, format,
return
return
}
}
if
format
==
constant
.
FormatExcel
{
if
format
==
constant
.
FormatExcel
||
format
==
constant
.
FormatCsv
{
gen
.
Write
(
rows
,
format
,
table
,
colIsNumArr
,
fieldsToExport
)
gen
.
Write
(
rows
,
format
,
table
,
colIsNumArr
,
fieldsToExport
)
}
else
{
}
else
{
gen
.
Print
(
rows
,
format
,
table
,
colIsNumArr
,
fieldsToExport
)
gen
.
Print
(
rows
,
format
,
table
,
colIsNumArr
,
fieldsToExport
)
...
...
src/gen/
output
.go
→
src/gen/
printer
.go
浏览文件 @
7f0f4d89
...
@@ -37,7 +37,7 @@ func Print(rows [][]string, format string, table string, colIsNumArr []bool,
...
@@ -37,7 +37,7 @@ func Print(rows [][]string, format string, table string, colIsNumArr []bool,
col
=
stringUtils
.
AddPad
(
col
,
field
)
col
=
stringUtils
.
AddPad
(
col
,
field
)
}
}
if
j
>
0
&&
vari
.
Human
{
if
j
>
0
&&
vari
.
Human
{
// use a tab
lineForText
=
strings
.
TrimRight
(
lineForText
,
"
\t
"
)
lineForText
=
strings
.
TrimRight
(
lineForText
,
"
\t
"
)
col
=
strings
.
TrimLeft
(
col
,
"
\t
"
)
col
=
strings
.
TrimLeft
(
col
,
"
\t
"
)
...
...
src/gen/write.go
→
src/gen/write
r
.go
浏览文件 @
7f0f4d89
package
gen
package
gen
import
(
import
(
"
fmt
"
"
encoding/csv
"
"github.com/360EntSecGroup-Skylar/excelize/v2"
"github.com/360EntSecGroup-Skylar/excelize/v2"
constant
"github.com/easysoft/zendata/src/utils/const"
constant
"github.com/easysoft/zendata/src/utils/const"
logUtils
"github.com/easysoft/zendata/src/utils/log"
logUtils
"github.com/easysoft/zendata/src/utils/log"
...
@@ -13,6 +13,9 @@ import (
...
@@ -13,6 +13,9 @@ import (
const
(
const
(
sheetName
=
"Sheet1"
sheetName
=
"Sheet1"
)
)
var
(
csvWriter
*
csv
.
Writer
)
func
Write
(
rows
[][]
string
,
format
string
,
table
string
,
colIsNumArr
[]
bool
,
func
Write
(
rows
[][]
string
,
format
string
,
table
string
,
colIsNumArr
[]
bool
,
fields
[]
string
)
(
lines
[]
interface
{})
{
fields
[]
string
)
(
lines
[]
interface
{})
{
...
@@ -23,23 +26,41 @@ func Write(rows [][]string, format string, table string, colIsNumArr []bool,
...
@@ -23,23 +26,41 @@ func Write(rows [][]string, format string, table string, colIsNumArr []bool,
if
format
==
constant
.
FormatExcel
{
if
format
==
constant
.
FormatExcel
{
printExcelHeader
(
fields
,
f
)
printExcelHeader
(
fields
,
f
)
}
else
if
format
==
constant
.
FormatCsv
{
csvWriter
=
csv
.
NewWriter
(
logUtils
.
FileWriter
)
}
}
for
i
,
row
:=
range
rows
{
csvData
:=
make
([][]
string
,
0
)
for
j
,
col
:=
range
row
{
for
i
,
cols
:=
range
rows
{
csvRow
:=
make
([]
string
,
0
)
for
j
,
col
:=
range
cols
{
col
=
replacePlaceholder
(
col
)
col
=
replacePlaceholder
(
col
)
field
:=
vari
.
TopFieldMap
[
fields
[
j
]]
field
:=
vari
.
TopFieldMap
[
fields
[
j
]]
if
field
.
Length
>
runewidth
.
StringWidth
(
col
)
{
if
field
.
Length
>
runewidth
.
StringWidth
(
col
)
{
col
=
stringUtils
.
AddPad
(
col
,
field
)
col
=
stringUtils
.
AddPad
(
col
,
field
)
}
}
if
format
==
constant
.
FormatExcel
{
colName
,
_
:=
excelize
.
CoordinatesToCellName
(
j
+
1
,
i
+
2
)
colName
,
_
:=
excelize
.
CoordinatesToCellName
(
j
+
1
,
i
+
2
)
f
.
SetCellValue
(
sheetName
,
colName
,
col
)
f
.
SetCellValue
(
sheetName
,
colName
,
col
)
}
else
if
format
==
constant
.
FormatCsv
{
csvRow
=
append
(
csvRow
,
col
)
}
}
}
}
csvData
=
append
(
csvData
,
csvRow
)
}
if
err
:=
f
.
SaveAs
(
logUtils
.
FilePath
);
err
!=
nil
{
var
err
error
fmt
.
Println
(
err
)
if
format
==
constant
.
FormatExcel
{
err
=
f
.
SaveAs
(
logUtils
.
FilePath
)
}
else
if
format
==
constant
.
FormatCsv
{
err
=
csvWriter
.
WriteAll
(
csvData
)
csvWriter
.
Flush
()
}
if
err
!=
nil
{
logUtils
.
PrintErrMsg
(
err
.
Error
())
}
}
return
return
...
...
src/model/definition.go
浏览文件 @
7f0f4d89
...
@@ -72,6 +72,7 @@ type FieldSimple struct {
...
@@ -72,6 +72,7 @@ type FieldSimple struct {
Field
string
`yaml:"field"`
Field
string
`yaml:"field"`
Note
string
`yaml:"note"`
Note
string
`yaml:"note"`
Range
string
`yaml:"range"`
Range
string
`yaml:"range"`
Value
string
`yaml:"value"`
Prefix
string
`yaml:"prefix"`
Prefix
string
`yaml:"prefix"`
Postfix
string
`yaml:"postfix"`
Postfix
string
`yaml:"postfix"`
Loop
string
`yaml:"loop"`
Loop
string
`yaml:"loop"`
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录