Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
fdd6a44b
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 搜索 >>
提交
fdd6a44b
编写于
11月 18, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
load instances yaml to db
上级
3ae2d730
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
12 deletion
+37
-12
demo/default.yaml
demo/default.yaml
+4
-4
src/model/model.go
src/model/model.go
+3
-3
src/server/service/instances.go
src/server/service/instances.go
+30
-5
tmp/cache/.data.db
tmp/cache/.data.db
+0
-0
未找到文件。
demo/default.yaml
浏览文件 @
fdd6a44b
...
...
@@ -81,7 +81,7 @@ fields:
-
field
:
field_loop
# 自循环的字段。
range
:
a-z
# a|b|c ...
loop
:
3
# 循环三次
loopfix
:
_
# 每次循环的连接符。
loopfix
:
"
|"
# 每次循环的连接符。
postfix
:
"
\t
"
-
field
:
field_repeat
# 通过{}定义重复的元素。
...
...
@@ -89,12 +89,12 @@ fields:
postfix
:
"
\t
"
-
field
:
field_format
# 通过格式化字符串输出。
range
:
1-10
# passwd
1,passwd 2,passwd
3 ... passwd10。
range
:
1-10
# passwd
01,passwd02,passwd0
3 ... passwd10。
format
:
"
passwd%02d"
# 用%02d补零,使密码整体保持8位。
postfix
:
"
\t
"
-
field
:
field_length
# 指定宽度。
range
:
1-99
# 0
1\t,02\t,03\t...,
99\t
range
:
1-99
# 0
01\t;002\t;003\t...;0
99\t
length
:
3
# 包含前后缀的宽度。
leftpad
:
0
# 宽度不够时,补充的字符。
postfix
:
"
\t
"
...
...
@@ -147,4 +147,4 @@ fields:
-
field
:
field_grandson
prefix
:
int_
range
:
10-20
postfix
:
\ No newline at end of file
postfix
:
src/model/model.go
浏览文件 @
fdd6a44b
...
...
@@ -197,9 +197,9 @@ type ZdInstancesItem struct {
Where
string
`gorm:"column:whereCol" json:"whereCol"`
Limit
int
`gorm:"column:limitCol" json:"limitCol"`
Ord
int
`gorm:"column:ord;default:1" json:"ord"`
Children
[]
*
ZdInstancesItem
`gorm:"-" json:"children
"`
Froms
[]
*
ZdInstancesItem
`gorm:"-" json:"froms"`
Ord
int
`gorm:"column:ord;default:1" json:"ord"`
Fields
[]
*
ZdInstancesItem
`gorm:"-" json:"fields
"`
Froms
[]
*
ZdInstancesItem
`gorm:"-" json:"froms"`
// for range edit
IsRange
bool
`gorm:"column:isRange;default:true" json:"isRange"`
...
...
src/server/service/instances.go
浏览文件 @
fdd6a44b
...
...
@@ -6,6 +6,8 @@ import (
constant
"github.com/easysoft/zendata/src/utils/const"
logUtils
"github.com/easysoft/zendata/src/utils/log"
stringUtils
"github.com/easysoft/zendata/src/utils/string"
"gopkg.in/yaml.v3"
"io/ioutil"
)
type
InstancesService
struct
{
...
...
@@ -56,7 +58,7 @@ func (s *InstancesService) GetItemTree(rangesId int) (root model.ZdInstancesItem
root
.
Field
=
"实例"
for
_
,
item
:=
range
items
{
item
.
ParentID
=
root
.
ID
root
.
Children
=
append
(
root
.
Children
,
item
)
root
.
Fields
=
append
(
root
.
Fields
,
item
)
}
return
...
...
@@ -91,15 +93,38 @@ func (s *InstancesService) saveResToDB(instances []model.ResFile, list []*model.
names
=
append
(
names
,
item
.
Path
)
}
for
_
,
item
:=
range
instances
{
if
!
stringUtils
.
FindInArrBool
(
item
.
Path
,
names
)
{
instances
:=
model
.
ZdInstances
{
Title
:
item
.
Title
,
Name
:
item
.
Name
,
Desc
:
item
.
Desc
,
Path
:
item
.
Path
}
s
.
instancesRepo
.
Save
(
&
instances
)
for
_
,
inst
:=
range
instances
{
if
!
stringUtils
.
FindInArrBool
(
inst
.
Path
,
names
)
{
//if strings.Contains(inst.Path, "aaa") {
content
,
_
:=
ioutil
.
ReadFile
(
inst
.
Path
)
yamlContent
:=
stringUtils
.
ReplaceSpecialChars
(
content
)
instPo
:=
model
.
ZdInstances
{}
err
=
yaml
.
Unmarshal
(
yamlContent
,
&
instPo
)
instPo
.
Title
=
inst
.
Title
instPo
.
Name
=
inst
.
Name
instPo
.
Desc
=
inst
.
Desc
instPo
.
Path
=
inst
.
Path
s
.
instancesRepo
.
Save
(
&
instPo
)
for
_
,
item
:=
range
instPo
.
Instances
{
s
.
saveItemToDB
(
&
item
,
0
,
instPo
.
ID
)
}
//}
}
}
return
}
func
(
s
*
InstancesService
)
saveItemToDB
(
item
*
model
.
ZdInstancesItem
,
parentID
,
instancesID
uint
)
{
item
.
InstancesID
=
instancesID
item
.
ParentID
=
parentID
s
.
instancesRepo
.
SaveItem
(
item
)
for
_
,
child
:=
range
item
.
Fields
{
s
.
saveItemToDB
(
child
,
item
.
ID
,
instancesID
)
}
}
func
NewInstancesService
(
instancesRepo
*
serverRepo
.
InstancesRepo
,
referRepo
*
serverRepo
.
ReferRepo
)
*
InstancesService
{
return
&
InstancesService
{
instancesRepo
:
instancesRepo
,
referRepo
:
referRepo
}
...
...
tmp/cache/.data.db
浏览文件 @
fdd6a44b
无法预览此类型文件
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录