Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
da0ae3ae
Z
zendata
项目概览
易企天创
/
zendata
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
da0ae3ae
编写于
4月 17, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
gen int
上级
50a0b0a7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
42 addition
and
19 deletion
+42
-19
src/action/generator.go
src/action/generator.go
+0
-1
src/gen/generator.go
src/gen/generator.go
+37
-17
src/model/definition.go
src/model/definition.go
+2
-0
xdoc/data.yaml
xdoc/data.yaml
+3
-1
未找到文件。
src/action/generator.go
浏览文件 @
da0ae3ae
...
@@ -30,7 +30,6 @@ func Generate(file string, total int, fields string, out string, table string) {
...
@@ -30,7 +30,6 @@ func Generate(file string, total int, fields string, out string, table string) {
Print
(
rows
)
Print
(
rows
)
}
}
func
Print
(
rows
[][]
string
)
{
func
Print
(
rows
[][]
string
)
{
width
:=
stringUtils
.
GetNumbWidth
(
len
(
rows
))
width
:=
stringUtils
.
GetNumbWidth
(
len
(
rows
))
...
...
src/gen/generator.go
浏览文件 @
da0ae3ae
...
@@ -27,35 +27,55 @@ func Generate(def *model.Definition, total int, fields string, out string, table
...
@@ -27,35 +27,55 @@ func Generate(def *model.Definition, total int, fields string, out string, table
continue
continue
}
}
if
field
.
Loop
==
0
{
field
.
Loop
=
1
}
prefix
:=
field
.
Prefix
prefix
:=
field
.
Prefix
postfix
:=
field
.
Postfix
postfix
:=
field
.
Postfix
indexOfRow
=
i
%
len
(
fieldMap
[
field
.
Name
])
if
len
(
rows
)
==
i
{
rows
=
append
(
rows
,
make
([]
string
,
0
))
}
if
len
(
rows
)
==
i
{
rows
=
append
(
rows
,
make
([]
string
,
0
))
}
str
:=
"n/a"
loopStr
:=
""
val
:=
fieldMap
[
field
.
Name
][
indexOfRow
]
for
j
:=
0
;
j
<
field
.
Loop
;
j
++
{
switch
val
.
(
type
)
{
if
loopStr
!=
""
{
case
int64
:
loopStr
=
loopStr
+
field
.
Loopfix
str
=
strconv
.
FormatInt
(
val
.
(
int64
),
10
)
}
case
float64
:
str
:=
GetFieldStr
(
field
,
fieldMap
,
indexOfRow
)
precision
:=
0
loopStr
=
loopStr
+
str
if
field
.
Precision
>
0
{
precision
=
field
.
Precision
indexOfRow
++
}
if
indexOfRow
==
len
(
fieldMap
[
field
.
Name
])
{
// no enough
str
=
strconv
.
FormatFloat
(
val
.
(
float64
),
'f'
,
precision
,
64
)
indexOfRow
=
0
case
byte
:
}
str
=
string
(
val
.
(
byte
))
default
:
}
}
rows
[
i
]
=
append
(
rows
[
i
],
prefix
+
s
tr
+
postfix
)
rows
[
i
]
=
append
(
rows
[
i
],
prefix
+
loopS
tr
+
postfix
)
}
}
}
}
return
rows
return
rows
}
}
func
GetFieldStr
(
field
model
.
Field
,
fieldMap
map
[
string
][]
interface
{},
indexOfRow
int
)
string
{
str
:=
"n/a"
val
:=
fieldMap
[
field
.
Name
][
indexOfRow
]
switch
val
.
(
type
)
{
case
int64
:
str
=
strconv
.
FormatInt
(
val
.
(
int64
),
10
)
case
float64
:
precision
:=
0
if
field
.
Precision
>
0
{
precision
=
field
.
Precision
}
str
=
strconv
.
FormatFloat
(
val
.
(
float64
),
'f'
,
precision
,
64
)
case
byte
:
str
=
string
(
val
.
(
byte
))
default
:
}
return
str
}
func
GenerateFieldArr
(
field
*
model
.
Field
,
total
int
,
fieldMap
map
[
string
][]
interface
{})
{
func
GenerateFieldArr
(
field
*
model
.
Field
,
total
int
,
fieldMap
map
[
string
][]
interface
{})
{
datatype
:=
strings
.
TrimSpace
(
field
.
Type
)
datatype
:=
strings
.
TrimSpace
(
field
.
Type
)
if
datatype
==
""
{
datatype
=
"list"
}
if
datatype
==
""
{
datatype
=
"list"
}
...
...
src/model/definition.go
浏览文件 @
da0ae3ae
...
@@ -16,6 +16,8 @@ type Field struct {
...
@@ -16,6 +16,8 @@ type Field struct {
Range
string
`yaml:"range"`
Range
string
`yaml:"range"`
Prefix
string
`yaml:"prefix"`
Prefix
string
`yaml:"prefix"`
Postfix
string
`yaml:"postfix"`
Postfix
string
`yaml:"postfix"`
Loop
int
`yaml:"loop"`
Loopfix
string
`yaml:"loopfix"`
Expect
string
`yaml:"expect"`
Expect
string
`yaml:"expect"`
Fields
[]
Field
`yaml:"fields,flow"`
Fields
[]
Field
`yaml:"fields,flow"`
...
...
xdoc/data.yaml
浏览文件 @
da0ae3ae
...
@@ -7,9 +7,11 @@ fields:
...
@@ -7,9 +7,11 @@ fields:
-
name
:
field1
-
name
:
field1
note
:
默认的列表类型,通过逗号隔成若干区段。
note
:
默认的列表类型,通过逗号隔成若干区段。
type
:
list
type
:
list
range
:
1-3,x-z:R,10.01-19.20:
R,101,102
range
:
1-3,x-z:R,10.01-19.20:
3,101,102,103
prefix
:
prefix
:
postfix
:
postfix
:
loop
:
3
loopfix
:
"
|"
expect
:
1,2,3...,10,20,21,22...,25,27,29.30
expect
:
1,2,3...,10,20,21,22...,25,27,29.30
-
name
:
field2
-
name
:
field2
note
:
区间可以指定步长。
note
:
区间可以指定步长。
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录