Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
af1d0cd5
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,体验更适合开发者的 AI 搜索 >>
提交
af1d0cd5
编写于
11月 25, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
parse refer to res
上级
0d0006ce
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
58 addition
and
42 deletion
+58
-42
demo/advanced.yaml
demo/advanced.yaml
+2
-2
src/model/model.go
src/model/model.go
+1
-0
src/server/service/common.go
src/server/service/common.go
+2
-2
src/server/service/def.go
src/server/service/def.go
+30
-17
tmp/cache/.data.db
tmp/cache/.data.db
+0
-0
users/test/_test-data.yaml
users/test/_test-data.yaml
+18
-18
users/test/dir/users.txt
users/test/dir/users.txt
+5
-3
未找到文件。
demo/advanced.yaml
浏览文件 @
af1d0cd5
...
...
@@ -52,8 +52,8 @@ fields:
postfix
:
"
]
\t
"
froms
:
-
from
:
zentao.number.v1.yaml
use
:
small{2}
# 指定引用个数
use
:
small{2}
# 指定引用个数
postfix
:
"
-"
-
from
:
zentao.number.v1.yaml
use
:
large{3}
# 指定引用个数
use
:
large{3}
# 指定引用个数
src/model/model.go
浏览文件 @
af1d0cd5
...
...
@@ -112,6 +112,7 @@ type ZdRefer struct {
ColIndex
int
`gorm:"column:colIndex" json:"colIndex"`
Condition
string
`gorm:"column:condition" json:"condition"`
Count
int
`gorm:"column:count" json:"count"`
Step
int
`gorm:"column:step" json:"step"`
Rand
bool
`gorm:"column:rand" json:"rand"`
HasTitle
bool
`gorm:"column:hasTitle" json:"hasTitle"`
}
...
...
src/server/service/common.go
浏览文件 @
af1d0cd5
...
...
@@ -69,7 +69,7 @@ func genFieldFromZdField(treeNode model.ZdField, field *model.DefField) () {
field
.
Limit
=
treeNode
.
Limit
}
func
Fil
eToPath
(
f
,
currFile
string
)
(
path
string
)
{
func
ConvertReferRang
eToPath
(
f
,
currFile
string
)
(
path
string
)
{
path
=
fileUtils
.
ConvertResYamlPath
(
f
)
if
path
==
""
{
resPath
:=
fileUtils
.
GetAbsDir
(
currFile
)
+
f
...
...
@@ -85,7 +85,7 @@ func FileToPath(f, currFile string) (path string) {
return
}
func
Get
PathRelated
WithResDir
(
p
string
)
(
ret
string
)
{
func
Get
RelatedPath
WithResDir
(
p
string
)
(
ret
string
)
{
rpl
:=
vari
.
WorkDir
+
constant
.
ResDirYaml
+
constant
.
PthSep
ret
=
strings
.
Replace
(
p
,
rpl
,
""
,
1
)
...
...
src/server/service/def.go
浏览文件 @
af1d0cd5
...
...
@@ -14,6 +14,7 @@ import (
"gopkg.in/yaml.v3"
"io/ioutil"
"path"
"strconv"
"strings"
)
...
...
@@ -188,44 +189,56 @@ func (s *DefService) saveFieldToDB(item *model.ZdField, currPath string, parentI
refer
.
File
=
item
.
From
refer
.
Sheet
=
sheet
}
else
if
item
.
Use
!=
""
{
// refer to ranges or instances
refer
.
File
=
item
.
From
refer
.
ColName
,
_
,
refer
.
Count
=
gen
.
ParseRangeSection
(
item
.
Use
)
}
else
if
item
.
Use
!=
""
{
// refer to ranges or instances, need to read yaml to get the type
rangeSections
:=
gen
.
ParseRangeProperty
(
item
.
Use
)
if
len
(
rangeSections
)
>
0
{
// only get the first one
rangeSection
:=
rangeSections
[
0
]
desc
,
_
,
count
:=
gen
.
ParseRangeSection
(
rangeSection
)
// medium{2}
refer
.
ColName
=
desc
refer
.
Count
=
count
}
path
:=
Fil
eToPath
(
item
.
From
,
currPath
)
path
:=
ConvertReferRang
eToPath
(
item
.
From
,
currPath
)
_
,
_
,
refer
.
Type
=
service
.
ReadYamlInfo
(
path
)
refer
.
File
=
item
.
From
}
else
if
item
.
Config
!=
""
{
// refer to config
refer
.
Type
=
constant
.
ResTypeConfig
item
.
Config
=
strings
.
TrimSpace
(
item
.
Config
)
rangeSections
:=
gen
.
ParseRangeProperty
(
item
.
Config
)
if
len
(
rangeSections
)
==
1
{
rangeSections
:=
gen
.
ParseRangeProperty
(
item
.
Config
)
// dir/config.yaml
if
len
(
rangeSections
)
>
0
{
// only get the first one
rangeSection
:=
rangeSections
[
0
]
desc
,
_
,
count
:=
gen
.
ParseRangeSection
(
rangeSection
)
refer
.
Count
=
count
path
:=
Fil
eToPath
(
desc
,
currPath
)
refer
.
File
=
Get
PathRelated
WithResDir
(
path
)
path
:=
ConvertReferRang
eToPath
(
desc
,
currPath
)
refer
.
File
=
Get
RelatedPath
WithResDir
(
path
)
}
}
else
if
item
.
Range
!=
""
{
// deal with yaml and text refer using range prop
item
.
Range
=
strings
.
TrimSpace
(
item
.
Range
)
rangeSections
:=
gen
.
ParseRangeProperty
(
item
.
Range
)
if
len
(
rangeSections
)
==
1
{
if
len
(
rangeSections
)
>
0
{
// only get the first one
rangeSection
:=
rangeSections
[
0
]
desc
,
_
,
count
:=
gen
.
ParseRangeSection
(
rangeSection
)
desc
,
step
,
count
:=
gen
.
ParseRangeSection
(
rangeSection
)
// dir/users.txt:R{3}
if
path
.
Ext
(
desc
)
==
".txt"
{
if
path
.
Ext
(
desc
)
==
".txt"
{
// dir/users.txt:2
refer
.
Type
=
constant
.
ResTypeText
}
else
if
path
.
Ext
(
desc
)
==
".yaml"
{
if
strings
.
ToLower
(
step
)
==
"r"
{
refer
.
Rand
=
true
}
else
{
refer
.
Step
,
_
=
strconv
.
Atoi
(
step
)
}
}
else
if
path
.
Ext
(
desc
)
==
".yaml"
{
// dir/content.yaml{3}
refer
.
Type
=
constant
.
ResTypeYaml
refer
.
Count
=
count
}
if
path
.
Ext
(
desc
)
==
".txt"
||
path
.
Ext
(
desc
)
==
".yaml"
{
refer
.
Count
=
count
path
:=
FileToPath
(
desc
,
currPath
)
refer
.
File
=
GetPathRelatedWithResDir
(
path
)
path
:=
ConvertReferRangeToPath
(
desc
,
currPath
)
refer
.
File
=
GetRelatedPathWithResDir
(
path
)
}
}
}
...
...
tmp/cache/.data.db
浏览文件 @
af1d0cd5
无法预览此类型文件
users/test/_test-data.yaml
浏览文件 @
af1d0cd5
...
...
@@ -4,7 +4,7 @@ fields:
-
field
:
field_with_children
fields
:
# - field: child1
# range: a-z
# range: a-z
:2
# prefix: "part1_\t"
# postfix: '|'
# loop: "3"
...
...
@@ -18,31 +18,31 @@ fields:
# - field: field_grandson
# range: 10-20
# prefix: int_
-
field
:
field_text
# 从一个文件中随机读取。
range
:
dir/users.txt:
R
# 相对当前文件路径。
-
field
:
field_text
range
:
dir/users.txt:
2
postfix
:
"
\t
"
-
field
:
field_yaml
# 引用其他的定义文件整体内容。
range
:
dir/content.yaml{3}
# 相对当前文件路径。
-
field
:
field_yaml
range
:
dir/content.yaml{3}
postfix
:
"
\t
"
-
field
:
field_use_config
# 引用其他的config定义文件。
config
:
dir/config.yaml
{2}
# 相对当前文件路径,config内包含单个字段。
-
field
:
field_use_config
config
:
dir/config.yaml
postfix
:
"
\t
"
-
field
:
field_use_ranges
# 引用內置的定义文件,该文件定义了多个range,他们共享了一些field层面的属性。
from
:
zentao.number.v1.yaml
# 引用yaml/zentao/number/v1.yaml文件里面的ranges定义。
use
:
medium{2}
# 使用该文件中定义的medium分组。
-
field
:
field_use_ranges
from
:
zentao.number.v1.yaml
use
:
medium{2}
postfix
:
"
\t
"
-
field
:
field_use_instance
# 引用其他的定义文件,该文件定义了多个实例。
from
:
ip.v1.yaml
# yaml/ip/v1.yaml
use
:
privateC{
1},privateB{2}
# 使用该文件中定义的privateC和privateB两个实例。
-
field
:
field_use_instance
from
:
ip.v1.yaml
use
:
privateC{
2}
postfix
:
"
\t
"
-
field
:
field_use_excel
# 从excel数据源里面取数据。
from
:
address.cn.v1.china
# 从data/address/v1.xlsx文件中读取名为china的工作簿。
select
:
city
# 查询city字段。
where
:
state like '%山东%'
# 条件是省份包含山东。
rand
:
true
# 随机取数据
-
field
:
field_use_excel
from
:
address.cn.v1.china
select
:
city
where
:
state like '%山东%'
rand
:
true
postfix
:
"
\t
"
users/test/dir/users.txt
浏览文件 @
af1d0cd5
aaron
ben
carl
1aaron
2ben
3carl
4
5
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录