Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
zendata
提交
52a434f8
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,发现更多精彩内容 >>
提交
52a434f8
编写于
7月 27, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
close task #7492
上级
6f15ecf5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
44 addition
and
11 deletion
+44
-11
demo/smoke.yaml
demo/smoke.yaml
+3
-1
src/gen/definition.go
src/gen/definition.go
+1
-1
src/gen/generator.go
src/gen/generator.go
+35
-8
src/model/definition.go
src/model/definition.go
+5
-1
未找到文件。
demo/smoke.yaml
浏览文件 @
52a434f8
...
...
@@ -21,5 +21,7 @@ fields:
postfix
:
"
\t
"
-
field
:
test5
range
:
[
user-2
,
user3
,
user4
,
user6
]
:R{2}
range
:
[
user-2
,
user3
,
user4
,
user6
]{
2
}
loop
:
2-9
loopfix
:
"
|"
postfix
:
"
\t
"
src/gen/definition.go
浏览文件 @
52a434f8
...
...
@@ -146,7 +146,7 @@ func CopyField(child model.DefField, parent *model.DefField) {
if
child
.
Postfix
!=
""
{
(
*
parent
)
.
Postfix
=
child
.
Postfix
}
if
child
.
Loop
!=
0
{
if
child
.
Loop
!=
""
{
(
*
parent
)
.
Loop
=
child
.
Loop
}
if
child
.
Loopfix
!=
""
{
...
...
src/gen/generator.go
浏览文件 @
52a434f8
...
...
@@ -113,7 +113,7 @@ func GenerateForField(field *model.DefField, total int, withFix bool) []string {
}
func
GenerateFieldItemsFromDefinition
(
field
*
model
.
DefField
)
[]
string
{
if
field
.
Loop
==
0
{
field
.
Loop
=
1
}
//if field.Loop == "" {field.Loop = "1"
}
values
:=
make
([]
string
,
0
)
...
...
@@ -123,7 +123,7 @@ func GenerateFieldItemsFromDefinition(field *model.DefField) []string {
count
:=
0
for
{
// 处理格式、前后缀、loop等
str
:=
GenerateFieldValWithFix
(
*
field
,
fieldValue
,
&
index
,
true
)
str
:=
GenerateFieldValWithFix
(
field
,
fieldValue
,
&
index
,
true
)
values
=
append
(
values
,
str
)
count
++
...
...
@@ -187,7 +187,7 @@ func GetFieldValStr(field model.DefField, val interface{}) string {
}
func
LoopSubFields
(
field
*
model
.
DefField
,
oldValues
[]
string
,
total
int
,
withFix
bool
)
[]
string
{
if
field
.
Loop
==
0
{
field
.
Loop
=
1
}
//if field.Loop == "" {field.Loop = "1"
}
values
:=
make
([]
string
,
0
)
fieldValue
:=
model
.
FieldValue
{}
...
...
@@ -200,7 +200,7 @@ func LoopSubFields(field *model.DefField, oldValues []string, total int, withFix
count
:=
0
for
{
// 处理格式、前后缀、loop等
str
:=
GenerateFieldValWithFix
(
*
field
,
fieldValue
,
&
index
,
withFix
)
str
:=
GenerateFieldValWithFix
(
field
,
fieldValue
,
&
index
,
withFix
)
values
=
append
(
values
,
str
)
count
++
...
...
@@ -212,17 +212,18 @@ func LoopSubFields(field *model.DefField, oldValues []string, total int, withFix
return
values
}
func
GenerateFieldValWithFix
(
field
model
.
DefField
,
fieldValue
model
.
FieldValue
,
indexOfRow
*
int
,
withFix
bool
)
string
{
func
GenerateFieldValWithFix
(
field
*
model
.
DefField
,
fieldValue
model
.
FieldValue
,
indexOfRow
*
int
,
withFix
bool
)
string
{
prefix
:=
field
.
Prefix
postfix
:=
field
.
Postfix
computerLoop
(
field
)
loopStr
:=
""
for
j
:=
0
;
j
<
field
.
Loop
;
j
++
{
for
j
:=
0
;
j
<
(
*
field
)
.
LoopIndex
;
j
++
{
if
loopStr
!=
""
{
loopStr
=
loopStr
+
field
.
Loopfix
}
str
:=
GenerateFieldVal
(
field
,
fieldValue
,
indexOfRow
)
str
:=
GenerateFieldVal
(
*
field
,
fieldValue
,
indexOfRow
)
loopStr
=
loopStr
+
str
*
indexOfRow
++
...
...
@@ -233,8 +234,34 @@ func GenerateFieldValWithFix(field model.DefField, fieldValue model.FieldValue,
}
if
field
.
Width
>
runewidth
.
StringWidth
(
loopStr
)
{
loopStr
=
stringUtils
.
AddPad
(
loopStr
,
field
)
loopStr
=
stringUtils
.
AddPad
(
loopStr
,
*
field
)
}
(
*
field
)
.
LoopIndex
=
(
*
field
)
.
LoopIndex
+
1
if
(
*
field
)
.
LoopIndex
>
(
*
field
)
.
LoopEnd
{
(
*
field
)
.
LoopIndex
=
(
*
field
)
.
LoopStart
}
return
loopStr
}
func
computerLoop
(
field
*
model
.
DefField
)
{
if
(
*
field
)
.
LoopIndex
!=
0
{
return
}
arr
:=
strings
.
Split
(
field
.
Loop
,
"-"
)
(
*
field
)
.
LoopStart
,
_
=
strconv
.
Atoi
(
arr
[
0
])
if
len
(
arr
)
>
1
{
field
.
LoopEnd
,
_
=
strconv
.
Atoi
(
arr
[
1
])
}
if
(
*
field
)
.
LoopStart
==
0
{
(
*
field
)
.
LoopStart
=
1
}
if
(
*
field
)
.
LoopEnd
==
0
{
(
*
field
)
.
LoopEnd
=
1
}
(
*
field
)
.
LoopIndex
=
(
*
field
)
.
LoopStart
}
\ No newline at end of file
src/model/definition.go
浏览文件 @
52a434f8
...
...
@@ -65,9 +65,13 @@ type FieldSimple struct {
Range
string
`yaml:"range"`
Prefix
string
`yaml:"prefix"`
Postfix
string
`yaml:"postfix"`
Loop
int
`yaml:"loop"`
Loop
string
`yaml:"loop"`
Loopfix
string
`yaml:"loopfix"`
Format
string
`yaml:"format"`
LoopStart
int
LoopEnd
int
LoopIndex
int
}
type
FieldValue
struct
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录