Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
5786ed8a
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 搜索 >>
提交
5786ed8a
编写于
8月 20, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refer to other yaml file's data
上级
20940883
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
27 addition
and
14 deletion
+27
-14
demo/advanced.yaml
demo/advanced.yaml
+6
-1
src/gen/list.go
src/gen/list.go
+5
-5
src/gen/parser.go
src/gen/parser.go
+9
-8
src/utils/string/string.go
src/utils/string/string.go
+7
-0
tmp/cache/.data.db
tmp/cache/.data.db
+0
-0
未找到文件。
demo/advanced.yaml
浏览文件 @
5786ed8a
...
...
@@ -38,6 +38,11 @@ fields:
-
from
:
custom.test.number.v1.yaml
use
:
large{3}
-
field
:
field_use_yaml
range
:
test.yaml{2},1-9
postfix
:
"
\t
"
-
field
:
field_literal
range
:
"
`0000-00`,`AA[2,a-z]`,[1-3]:2{3},`[1-3]:2{3}`"
type
:
text
\ No newline at end of file
type
:
text
src/gen/list.go
浏览文件 @
5786ed8a
...
...
@@ -39,19 +39,19 @@ func CreateFieldValues(field *model.DefField, fieldValue *model.FieldWithValues)
func
CreateFieldValuesFromList
(
field
*
model
.
DefField
,
fieldValue
*
model
.
FieldWithValues
)
{
rang
:=
field
.
Range
range
Items
:=
ParseRange
(
rang
)
// 1
range
Sections
:=
ParseRangeProperty
(
rang
)
// 1
index
:=
0
for
_
,
range
Item
:=
range
rangeItem
s
{
for
_
,
range
Section
:=
range
rangeSection
s
{
if
index
>=
constant
.
MaxNumb
{
break
}
if
range
Item
==
""
{
continue
}
if
range
Section
==
""
{
continue
}
descStr
,
stepStr
,
repeat
:=
ParseRange
Item
(
rangeItem
)
// 2
descStr
,
stepStr
,
repeat
:=
ParseRange
Section
(
rangeSection
)
// 2
if
strings
.
ToLower
(
stepStr
)
==
"r"
{
(
*
field
)
.
IsRand
=
true
}
typ
,
desc
:=
Parse
Entry
(
descStr
)
// 3
typ
,
desc
:=
Parse
RangeSectionDesc
(
descStr
)
// 3
items
:=
make
([]
interface
{},
0
)
if
typ
==
"literal"
{
...
...
src/gen/parser.go
浏览文件 @
5786ed8a
...
...
@@ -3,18 +3,14 @@ package gen
import
(
"fmt"
"github.com/easysoft/zendata/src/utils/const"
stringUtils
"github.com/easysoft/zendata/src/utils/string"
"regexp"
"strconv"
"strings"
"unicode"
)
/**
split field range string with comma to a array, ignore the comma in []
1-2:R,[user1,user2]{2} -> 1-2:R
[user1,user2]{2}
*/
func
ParseRange
(
rang
string
)
[]
string
{
func
ParseRangeProperty
(
rang
string
)
[]
string
{
items
:=
make
([]
string
,
0
)
bracketsOpen
:=
false
...
...
@@ -79,7 +75,7 @@ func ParseDesc(desc string) (items []string) {
step =>1
repeat =>2
*/
func
ParseRange
Item
(
item
string
)
(
entry
string
,
step
string
,
repeat
int
)
{
func
ParseRange
Section
(
item
string
)
(
entry
string
,
step
string
,
repeat
int
)
{
item
=
strings
.
TrimSpace
(
item
)
runeArr
:=
[]
rune
(
item
)
if
(
runeArr
[
0
]
==
constant
.
Backtick
&&
runeArr
[
len
(
runeArr
)
-
1
]
==
constant
.
Backtick
)
||
// `xxx`
...
...
@@ -117,9 +113,14 @@ func ParseRangeItem(item string) (entry string, step string, repeat int) {
[user1,user2] -> type => literal
desc => user2,user3
*/
func
Parse
Entry
(
str
string
)
(
typ
string
,
desc
string
)
{
func
Parse
RangeSectionDesc
(
str
string
)
(
typ
string
,
desc
string
)
{
desc
=
strings
.
TrimSpace
(
str
)
if
stringUtils
.
EndWith
(
desc
,
".yaml"
)
{
// refer to another yaml file
typ
=
"yaml"
return
}
if
strings
.
Contains
(
desc
,
","
)
||
strings
.
Contains
(
desc
,
"`"
)
||
!
strings
.
Contains
(
desc
,
"-"
)
{
typ
=
"literal"
}
else
{
...
...
src/utils/string/string.go
浏览文件 @
5786ed8a
...
...
@@ -130,6 +130,13 @@ func AddPad(str string, field model.DefField) string {
return
str
}
func
StartWith
(
str
,
sub
string
)
bool
{
return
strings
.
Index
(
str
,
sub
)
==
0
}
func
EndWith
(
str
,
sub
string
)
bool
{
return
strings
.
LastIndex
(
str
,
sub
)
==
len
(
str
)
-
len
(
sub
)
}
func
ConvertForSql
(
str
string
)
(
ret
string
)
{
arr
:=
[]
rune
(
str
)
...
...
tmp/cache/.data.db
浏览文件 @
5786ed8a
无法预览此类型文件
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录