Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
ca978548
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 搜索 >>
提交
ca978548
编写于
8月 20, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix res path issues
上级
7e46d91f
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
57 addition
and
64 deletion
+57
-64
demo/chinese.yaml
demo/chinese.yaml
+0
-22
demo/default.yaml
demo/default.yaml
+6
-7
src/gen/excel.go
src/gen/excel.go
+1
-1
src/gen/res.go
src/gen/res.go
+38
-23
src/service/list.go
src/service/list.go
+6
-4
src/utils/const/const.go
src/utils/const/const.go
+4
-1
users/jenkins/ip/private.yaml
users/jenkins/ip/private.yaml
+2
-6
未找到文件。
demo/chinese.yaml
已删除
100644 → 0
浏览文件 @
7e46d91f
title
:
zendata数据配置语法说明
desc
:
author
:
zentao
version
:
1.0
type
:
lines
# lines|media|binary|article
fields
:
-
field
:
subject
from
:
chinese.words.v1.cn
select
:
word
where
:
ming='y' and dong="n"
-
field
:
verb
from
:
chinese.words.v1.cn
select
:
word
where
:
dong='y'
-
field
:
object
from
:
chinese.words.v1.cn
select
:
word
where
:
ming='y'
demo/default.yaml
浏览文件 @
ca978548
...
...
@@ -102,25 +102,24 @@ fields:
postfix
:
"
\t
"
-
field
:
field_use_ranges
# 引用內置的定义文件,该文件定义了多个range,他们共享了一些field层面的属性。
from
:
custom.test.number.v1.yaml
# 引用data/custom/number/v1.yaml文件里面的ranges定义。
from
:
jenkins.number.v1.yaml
# 引用data/custom/number/v1.yaml文件里面的ranges定义。
use
:
medium
# 使用该文件中定义的medium分组。
postfix
:
"
\t
"
-
field
:
field_use_instance
# 引用其他的定义文件,该文件定义了多个实例。
from
:
system.ip.v1.yaml
# 引用data/system/ip/v1.yaml
from
:
ip.v1.yaml
# 引用data/system/ip/v1.yaml
use
:
privateC,privateB
# 使用该文件中定义的privateC和privateB两个实例。
postfix
:
"
\t
"
-
field
:
field_nested_instant
# 引用其他的定义文件,且该文件引用了其他实例。
from
:
custom.ip.private.yaml
# 引用data/custom/ip/private.yaml
from
:
jenkins.ip.private.yaml
# 引用data/custom/ip/private.yaml
use
:
all
# 使用该文件中的所有实例。
prefix
:
"
{"
postfix
:
"
}"
postfix
:
"
\t
"
-
field
:
field_use_excel
# 从excel数据源里面取数据。
from
:
system.address.v1.china
# 从data/system/address/v1.xlsx文件中读取名为china的工作簿。
from
:
address.cn.v1.china
# 从data/system/address/v1.xlsx文件中读取名为china的工作簿。
select
:
city
# 查询city字段。
where
:
state like '%山东%'
# 条件是省份包含山东。
where
:
state like '%山东%'
# 条件是省份包含山东。
postfix
:
"
\t
"
-
field
:
field_with_children
# 嵌套字段
...
...
src/gen/excel.go
浏览文件 @
ca978548
...
...
@@ -50,7 +50,7 @@ func GenerateFieldValuesFromExcel(path, sheet string, field *model.DefField) (ma
}
func
getDbName
(
path
string
)
(
dbName
string
)
{
dbName
=
strings
.
Replace
(
path
,
vari
.
WorkDir
+
constant
.
ResDir
,
""
,
-
1
)
dbName
=
strings
.
Replace
(
path
,
vari
.
WorkDir
+
constant
.
ResDir
Data
,
""
,
-
1
)
dbName
=
strings
.
Replace
(
dbName
,
constant
.
PthSep
,
"_"
,
-
1
)
dbName
=
strings
.
Replace
(
dbName
,
"."
,
"_"
,
-
1
)
...
...
src/gen/res.go
浏览文件 @
ca978548
...
...
@@ -11,7 +11,6 @@ import (
"github.com/jinzhu/copier"
"gopkg.in/yaml.v3"
"io/ioutil"
"path/filepath"
"strings"
)
...
...
@@ -50,6 +49,7 @@ func loadResField(field *model.DefField, res *map[string]map[string][]string) {
resFile
,
resType
,
sheet
:=
getResProp
(
field
.
From
)
values
,
_
:=
getResValue
(
resFile
,
resType
,
sheet
,
field
)
(
*
res
)[
field
.
From
]
=
values
}
else
if
field
.
Config
!=
""
{
resFile
,
resType
,
_
:=
getResProp
(
field
.
Config
)
values
,
_
:=
getResValue
(
resFile
,
resType
,
""
,
field
)
...
...
@@ -60,43 +60,58 @@ func loadResField(field *model.DefField, res *map[string]map[string][]string) {
func
getResProp
(
from
string
)
(
resFile
,
resType
,
sheet
string
)
{
// from resource
index
:=
strings
.
LastIndex
(
from
,
".yaml"
)
if
index
>
-
1
{
// yaml, system.ip.v1.yaml
left
:=
from
[
:
index
]
left
=
strings
.
ReplaceAll
(
left
,
"."
,
constant
.
PthSep
)
resFile
=
left
+
".yaml"
if
index
>
-
1
{
// yaml, ip.v1.yaml
resFile
=
convertYamlPath
(
from
)
resType
=
"yaml"
}
else
{
// excel, like address.cn.v1.china
resFile
,
sheet
=
convertExcelPath
(
from
)
resType
=
"excel"
}
if
strings
.
Index
(
resFile
,
"yaml"
)
==
0
||
strings
.
Index
(
resFile
,
"users"
)
==
0
{
// build-in resource
resFile
=
vari
.
WorkDir
+
resFile
}
else
{
resPath
:=
resFile
if
!
filepath
.
IsAbs
(
resPath
)
{
if
resFile
==
""
{
resPath
:=
vari
.
ConfigDir
+
resFile
if
!
fileUtils
.
FileExist
(
resPath
)
{
// in same folder with passed config file
resPath
=
vari
.
ConfigDir
+
resFile
if
!
fileUtils
.
FileExist
(
resPath
)
{
// in same folder with passed config file
resPath
=
vari
.
WorkDir
+
resFile
if
!
fileUtils
.
FileExist
(
resPath
)
{
// in res file
resPath
=
""
}
}
}
else
{
if
!
fileUtils
.
FileExist
(
resPath
)
{
resPath
=
vari
.
WorkDir
+
resFile
if
!
fileUtils
.
FileExist
(
resPath
)
{
// in res file
resPath
=
""
}
}
resFile
=
resPath
}
return
}
func
convertYamlPath
(
from
string
)
(
ret
string
)
{
arr
:=
strings
.
Split
(
from
,
"."
)
for
i
:=
0
;
i
<
len
(
arr
);
i
++
{
dir
:=
""
if
i
>
0
{
dir
=
strings
.
Join
(
arr
[
:
i
],
constant
.
PthSep
)
}
file
:=
strings
.
Join
(
arr
[
i
:
],
"."
)
if
dir
!=
""
{
ret
=
dir
+
constant
.
PthSep
+
file
}
else
{
ret
=
file
}
realPth1
:=
vari
.
WorkDir
+
constant
.
ResDirYaml
+
ret
realPth2
:=
vari
.
WorkDir
+
constant
.
ResDirUsers
+
ret
if
fileUtils
.
FileExist
(
realPth1
)
{
ret
=
realPth1
break
}
else
if
fileUtils
.
FileExist
(
realPth2
)
{
ret
=
realPth2
break
}
}
return
}
func
convertExcelPath
(
from
string
)
(
ret
,
sheet
string
)
{
path1
:=
from
// address.cn.v1
index
:=
strings
.
LastIndex
(
from
,
"."
)
...
...
@@ -119,7 +134,7 @@ func convertExcelPath(from string) (ret, sheet string) {
ret
=
file
}
realPth
:=
vari
.
WorkDir
+
constant
.
ResDir
+
ret
realPth
:=
vari
.
WorkDir
+
constant
.
ResDir
Data
+
ret
if
fileUtils
.
FileExist
(
realPth
)
{
if
index
==
1
{
sheet
=
from
[
strings
.
LastIndex
(
from
,
"."
)
+
1
:
]
...
...
src/service/list.go
浏览文件 @
ca978548
...
...
@@ -22,8 +22,10 @@ const (
func
ListRes
()
{
orderedKeys
:=
[
2
]
string
{
"yaml"
,
"excel"
}
res
:=
map
[
string
][][
size
]
string
{}
path
:=
vari
.
WorkDir
+
"data"
GetFilesAndDirs
(
path
,
&
res
)
GetFilesAndDirs
(
constant
.
ResDirData
,
&
res
)
GetFilesAndDirs
(
constant
.
ResDirYaml
,
&
res
)
GetFilesAndDirs
(
constant
.
ResDirUsers
,
&
res
)
names
:=
make
([]
string
,
0
)
nameWidth
:=
0
...
...
@@ -110,7 +112,7 @@ func ListRes() {
}
func
GetFilesAndDirs
(
path
string
,
res
*
map
[
string
][][
size
]
string
)
{
dir
,
err
:=
ioutil
.
ReadDir
(
path
)
dir
,
err
:=
ioutil
.
ReadDir
(
vari
.
WorkDir
+
path
)
if
err
!=
nil
{
return
}
...
...
@@ -123,7 +125,7 @@ func GetFilesAndDirs(path string, res *map[string][][size]string) {
arr
:=
[
size
]
string
{}
if
strings
.
HasSuffix
(
name
,
".yaml"
)
{
arr
[
0
]
=
path
+
constant
.
PthSep
+
name
arr
[
1
]
=
path
[
strings
.
LastIndex
(
path
,
"data"
)
:
]
+
constant
.
PthSep
+
name
arr
[
1
]
=
path
[
strings
.
LastIndex
(
path
,
path
)
:
]
+
constant
.
PthSep
+
name
arr
[
1
]
=
strings
.
Trim
(
arr
[
1
],
"data"
+
constant
.
PthSep
)
(
*
res
)[
"yaml"
]
=
append
((
*
res
)[
"yaml"
],
arr
)
...
...
src/utils/const/const.go
浏览文件 @
ca978548
...
...
@@ -50,7 +50,10 @@ var (
DefaultPort
=
8848
DefaultRoot
=
"./"
ResDir
=
"data/"
ResDirData
=
"data/"
ResDirYaml
=
"yaml/"
ResDirUsers
=
"users/"
TmpDir
=
"tmp/"
SqliteDriver
=
"sqlite3"
...
...
users/jenkins/ip/private.yaml
浏览文件 @
ca978548
...
...
@@ -3,22 +3,18 @@ desc: 引用系统IP定义
author
:
zentao
version
:
1.0
# from: system.ip.v1.yaml
field
:
privateIP
instances
:
-
instance
:
all
note
:
引用所有內置IP
# from: system.ip.v1.yaml
fields
:
-
field
:
part1
from
:
system.
ip.v1.yaml
from
:
ip.v1.yaml
use
:
privateA, privateB, privateC
prefix
:
"
"
postfix
:
"
/"
-
field
:
part2
from
:
custom.test
.number.v1.yaml
from
:
jenkins
.number.v1.yaml
use
:
netmask
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录