Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
cf8fae32
Z
zendata
项目概览
易企天创
/
zendata
9 个月 前同步成功
通知
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 搜索 >>
提交
cf8fae32
编写于
8月 27, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change to union multiple from, not combine them as sub-fields
上级
d3f28461
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
8 deletion
+14
-8
demo/test/test.yaml
demo/test/test.yaml
+8
-0
src/gen/generator.go
src/gen/generator.go
+4
-6
src/gen/res.go
src/gen/res.go
+2
-2
未找到文件。
demo/test/test.yaml
浏览文件 @
cf8fae32
...
@@ -10,4 +10,12 @@ fields:
...
@@ -10,4 +10,12 @@ fields:
-
field
:
test1
-
field
:
test1
range
:
[
userA
,
a-z
,
1-9
,
1-10000
]
# 字面常量及列表
range
:
[
userA
,
a-z
,
1-9
,
1-10000
]
# 字面常量及列表
postfix
:
"
\t
"
-
field
:
field_use_instance
froms
:
-
from
:
ip.v1.yaml
use
:
privateC,privateB
-
from
:
ip.v1.yaml
use
:
privateC,privateB
postfix
:
"
\t
"
postfix
:
"
\t
"
\ No newline at end of file
src/gen/generator.go
浏览文件 @
cf8fae32
...
@@ -84,23 +84,21 @@ func GenerateForField(field *model.DefField, withFix bool) (values []string) {
...
@@ -84,23 +84,21 @@ func GenerateForField(field *model.DefField, withFix bool) (values []string) {
values
=
loopFieldValues
(
field
,
values
,
count
,
true
)
values
=
loopFieldValues
(
field
,
values
,
count
,
true
)
}
else
if
len
(
field
.
Froms
)
>
0
{
// from muti items
}
else
if
len
(
field
.
Froms
)
>
0
{
// from muti items
arrOfArr
:=
make
([]
[]
string
,
0
)
// 2 dimension arr for child, [ [a,b,c], [1,2,3] ]
unionValues
:=
make
(
[]
string
,
0
)
// 2 dimension arr for child, [ [a,b,c], [1,2,3] ]
for
_
,
child
:=
range
field
.
Froms
{
for
_
,
child
:=
range
field
.
Froms
{
if
child
.
From
==
""
{
if
child
.
From
==
""
{
child
.
From
=
field
.
From
child
.
From
=
field
.
From
}
}
childValues
:=
GenerateForField
(
&
child
,
withFix
)
childValues
:=
GenerateForField
(
&
child
,
withFix
)
arrOfArr
=
append
(
arrOfArr
,
childValues
)
unionValues
=
append
(
unionValues
,
childValues
...
)
}
}
count
:=
vari
.
Total
count
:=
len
(
unionValues
)
count
=
getRecordCount
(
arrOfArr
)
if
count
>
vari
.
Total
{
if
count
>
vari
.
Total
{
count
=
vari
.
Total
count
=
vari
.
Total
}
}
values
=
combineChildrenValues
(
arrOfArr
,
count
)
values
=
loopFieldValues
(
field
,
unionValues
,
count
,
true
)
values
=
loopFieldValues
(
field
,
values
,
count
,
true
)
}
else
if
field
.
From
!=
""
{
// refer to res
}
else
if
field
.
From
!=
""
{
// refer to res
...
...
src/gen/res.go
浏览文件 @
cf8fae32
...
@@ -155,7 +155,7 @@ func prepareNestedInstanceRes(insts model.ResInsts, inst model.ResInst, instFiel
...
@@ -155,7 +155,7 @@ func prepareNestedInstanceRes(insts model.ResInsts, inst model.ResInst, instFiel
if
instField
.
Use
!=
""
{
// refer to another instances or ranges
if
instField
.
Use
!=
""
{
// refer to another instances or ranges
if
vari
.
Res
[
instField
.
From
]
==
nil
{
if
vari
.
Res
[
instField
.
From
]
==
nil
{
referencedRanges
,
referencedInstants
:=
get
Root
RangeOrInstant
(
instField
)
referencedRanges
,
referencedInstants
:=
get
referenced
RangeOrInstant
(
instField
)
groupedValueReferenced
:=
map
[
string
][]
string
{}
groupedValueReferenced
:=
map
[
string
][]
string
{}
if
len
(
referencedRanges
.
Ranges
)
>
0
{
// refer to ranges
if
len
(
referencedRanges
.
Ranges
)
>
0
{
// refer to ranges
...
@@ -184,7 +184,7 @@ func prepareNestedInstanceRes(insts model.ResInsts, inst model.ResInst, instFiel
...
@@ -184,7 +184,7 @@ func prepareNestedInstanceRes(insts model.ResInsts, inst model.ResInst, instFiel
}
}
}
}
func
get
Root
RangeOrInstant
(
inst
model
.
DefField
)
(
referencedRanges
model
.
ResRanges
,
referencedInsts
model
.
ResInsts
)
{
func
get
referenced
RangeOrInstant
(
inst
model
.
DefField
)
(
referencedRanges
model
.
ResRanges
,
referencedInsts
model
.
ResInsts
)
{
resFile
,
_
,
_
:=
fileUtils
.
GetResProp
(
inst
.
From
)
resFile
,
_
,
_
:=
fileUtils
.
GetResProp
(
inst
.
From
)
yamlContent
,
err
:=
ioutil
.
ReadFile
(
resFile
)
yamlContent
,
err
:=
ioutil
.
ReadFile
(
resFile
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录