Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
2b5c5548
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,发现更多精彩内容 >>
提交
2b5c5548
编写于
11月 20, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
gen def yaml from DB
上级
1854a924
变更
19
显示空白变更内容
内联
并排
Showing
19 changed file
with
34 addition
and
84 deletion
+34
-84
src/model/request.go
src/model/request.go
+2
-2
src/server/repo/config.go
src/server/repo/config.go
+1
-1
src/server/repo/def.go
src/server/repo/def.go
+1
-1
src/server/repo/excel.go
src/server/repo/excel.go
+1
-1
src/server/repo/instances.go
src/server/repo/instances.go
+1
-1
src/server/repo/ranges.go
src/server/repo/ranges.go
+1
-1
src/server/repo/text.go
src/server/repo/text.go
+1
-1
src/server/service/config.go
src/server/service/config.go
+0
-5
src/server/service/def.go
src/server/service/def.go
+12
-14
src/server/service/excel.go
src/server/service/excel.go
+0
-5
src/server/service/instances.go
src/server/service/instances.go
+0
-5
src/server/service/ranges.go
src/server/service/ranges.go
+0
-5
src/server/service/sync.go
src/server/service/sync.go
+0
-1
src/server/service/text.go
src/server/service/text.go
+0
-4
src/service/article.go
src/service/article.go
+2
-7
src/service/list.go
src/service/list.go
+1
-1
src/utils/string/string.go
src/utils/string/string.go
+10
-0
ui/src/layout/MainLayout.less
ui/src/layout/MainLayout.less
+1
-1
users/test/_test-data.yaml
users/test/_test-data.yaml
+0
-28
未找到文件。
src/model/request.go
浏览文件 @
2b5c5548
...
...
@@ -30,8 +30,8 @@ type ResData struct {
type
Model
struct
{
ID
uint
`gorm:"column:id;primary_key" json:"id"`
CreatedAt
time
.
Time
`gorm:"column:create
Time" json:"createTime
" yaml:"-"`
UpdatedAt
time
.
Time
`gorm:"column:update
Time" json:"updateTime
" yaml:"-"`
CreatedAt
time
.
Time
`gorm:"column:create
dAt" json:"createdAt
" yaml:"-"`
UpdatedAt
time
.
Time
`gorm:"column:update
dAt" json:"updatedAt
" yaml:"-"`
Disabled
bool
`gorm:"column:disabled;default:false" json:"disabled" yaml:"-"`
Deleted
bool
`gorm:"column:deleted;default:false" json:"deleted" yaml:"-"`
...
...
src/server/repo/config.go
浏览文件 @
2b5c5548
...
...
@@ -11,7 +11,7 @@ type ConfigRepo struct {
}
func
(
r
*
ConfigRepo
)
ListAll
()
(
models
[]
*
model
.
ZdConfig
)
{
r
.
db
.
Find
(
&
models
)
r
.
db
.
Select
(
"id,title,folder,path,updatedAt"
)
.
Find
(
&
models
)
return
}
...
...
src/server/repo/def.go
浏览文件 @
2b5c5548
...
...
@@ -11,7 +11,7 @@ type DefRepo struct {
}
func
(
r
*
DefRepo
)
ListAll
()
(
models
[]
*
model
.
ZdDef
)
{
r
.
db
.
Find
(
&
models
)
r
.
db
.
Select
(
"id,title,folder,path,updatedAt"
)
.
Find
(
&
models
)
return
}
...
...
src/server/repo/excel.go
浏览文件 @
2b5c5548
...
...
@@ -11,7 +11,7 @@ type ExcelRepo struct {
}
func
(
r
*
ExcelRepo
)
ListAll
()
(
models
[]
*
model
.
ZdExcel
)
{
r
.
db
.
Find
(
&
models
)
r
.
db
.
Select
(
"id,title,folder,path,updatedAt"
)
.
Find
(
&
models
)
return
}
...
...
src/server/repo/instances.go
浏览文件 @
2b5c5548
...
...
@@ -11,7 +11,7 @@ type InstancesRepo struct {
}
func
(
r
*
InstancesRepo
)
ListAll
()
(
models
[]
*
model
.
ZdInstances
)
{
r
.
db
.
Find
(
&
models
)
r
.
db
.
Select
(
"id,title,folder,path,updatedAt"
)
.
Find
(
&
models
)
return
}
...
...
src/server/repo/ranges.go
浏览文件 @
2b5c5548
...
...
@@ -11,7 +11,7 @@ type RangesRepo struct {
}
func
(
r
*
RangesRepo
)
ListAll
()
(
models
[]
*
model
.
ZdRanges
)
{
r
.
db
.
Find
(
&
models
)
r
.
db
.
Select
(
"id,title,folder,path,updatedAt"
)
.
Find
(
&
models
)
return
}
...
...
src/server/repo/text.go
浏览文件 @
2b5c5548
...
...
@@ -11,7 +11,7 @@ type TextRepo struct {
}
func
(
r
*
TextRepo
)
ListAll
()
(
models
[]
*
model
.
ZdText
)
{
r
.
db
.
Find
(
&
models
)
r
.
db
.
Select
(
"id,title,folder,path,updatedAt"
)
.
Find
(
&
models
)
return
}
...
...
src/server/service/config.go
浏览文件 @
2b5c5548
...
...
@@ -21,12 +21,7 @@ type ConfigService struct {
}
func
(
s
*
ConfigService
)
List
(
keywords
string
,
page
int
)
(
list
[]
*
model
.
ZdConfig
,
total
int
)
{
config
:=
s
.
resService
.
LoadRes
(
"config"
)
list
,
_
,
_
=
s
.
configRepo
.
List
(
""
,
-
1
)
s
.
importResToDB
(
config
,
list
)
list
,
total
,
_
=
s
.
configRepo
.
List
(
strings
.
TrimSpace
(
keywords
),
page
)
return
}
...
...
src/server/service/def.go
浏览文件 @
2b5c5548
...
...
@@ -52,9 +52,8 @@ func (s *DefService) Create(def *model.ZdDef) (err error) {
rootField
,
err
:=
s
.
fieldRepo
.
CreateTreeNode
(
def
.
ID
,
0
,
"字段"
,
"root"
)
s
.
referRepo
.
CreateDefault
(
rootField
.
ID
,
constant
.
ResTypeDef
)
s
.
dataToYaml
(
def
)
err
=
s
.
defRepo
.
Update
(
def
)
s
.
updateYaml
(
def
.
ID
)
return
}
...
...
@@ -69,8 +68,8 @@ func (s *DefService) Update(def *model.ZdDef) (err error) {
fileUtils
.
RemoveExist
(
old
.
Path
)
}
s
.
dataToYaml
(
def
)
err
=
s
.
defRepo
.
Update
(
def
)
s
.
updateYaml
(
def
.
ID
)
return
}
...
...
@@ -87,17 +86,18 @@ func (s *DefService) Remove(id int) (err error) {
return
}
func
(
s
*
DefService
)
U
pdateYaml
(
defId
uint
)
(
err
error
)
{
func
(
s
*
DefService
)
u
pdateYaml
(
defId
uint
)
(
err
error
)
{
var
def
model
.
ZdDef
def
,
_
=
s
.
defRepo
.
Get
(
defId
)
s
.
dataTo
Yaml
(
&
def
)
s
.
gen
Yaml
(
&
def
)
err
=
s
.
defRepo
.
UpdateYaml
(
def
)
fileUtils
.
WriteFile
(
def
.
Path
,
def
.
Yaml
)
return
}
func
(
s
*
DefService
)
dataTo
Yaml
(
def
*
model
.
ZdDef
)
(
str
string
)
{
func
(
s
*
DefService
)
gen
Yaml
(
def
*
model
.
ZdDef
)
(
str
string
)
{
root
,
err
:=
s
.
fieldRepo
.
GetDefFieldTree
(
def
.
ID
)
if
err
!=
nil
{
return
...
...
@@ -114,7 +114,7 @@ func (s *DefService) dataToYaml(def *model.ZdDef) (str string) {
}
bytes
,
err
:=
yaml
.
Marshal
(
defData
)
def
.
Yaml
=
string
(
bytes
)
def
.
Yaml
=
string
Utils
.
ConvertYamlStringToMapFormat
(
bytes
)
return
}
...
...
@@ -129,11 +129,13 @@ func (s *DefService) Sync(files []model.ResFile) (err error) {
for
_
,
fi
:=
range
files
{
_
,
found
:=
defMap
[
fi
.
Path
]
if
found
{
if
!
found
{
// no record
s
.
SyncToDB
(
fi
)
}
else
if
fi
.
UpdatedAt
.
Unix
()
>
defMap
[
fi
.
Path
]
.
UpdatedAt
.
Unix
()
{
// db is old
s
.
defRepo
.
Remove
(
defMap
[
fi
.
Path
]
.
ID
)
}
if
!
found
||
fi
.
UpdatedAt
.
Unix
()
>
defMap
[
fi
.
Path
]
.
UpdatedAt
.
Unix
()
{
s
.
SyncToDB
(
fi
)
}
else
{
// db is new
}
}
...
...
@@ -172,10 +174,6 @@ func (s *DefService) SyncToDB(fi model.ResFile) (err error) {
return
}
func
(
s
*
DefService
)
SyncFromDB
(
files
[]
model
.
ResFile
)
(
err
error
)
{
return
}
func
NewDefService
(
defRepo
*
serverRepo
.
DefRepo
,
fieldRepo
*
serverRepo
.
FieldRepo
,
referRepo
*
serverRepo
.
ReferRepo
)
*
DefService
{
...
...
src/server/service/excel.go
浏览文件 @
2b5c5548
...
...
@@ -19,12 +19,7 @@ type ExcelService struct {
}
func
(
s
*
ExcelService
)
List
(
keywords
string
,
page
int
)
(
list
[]
*
model
.
ZdExcel
,
total
int
)
{
excel
:=
s
.
resService
.
LoadRes
(
"excel"
)
list
,
_
,
_
=
s
.
excelRepo
.
List
(
""
,
-
1
)
s
.
importResToDB
(
excel
,
list
)
list
,
total
,
_
=
s
.
excelRepo
.
List
(
strings
.
TrimSpace
(
keywords
),
page
)
return
}
...
...
src/server/service/instances.go
浏览文件 @
2b5c5548
...
...
@@ -22,12 +22,7 @@ type InstancesService struct {
}
func
(
s
*
InstancesService
)
List
(
keywords
string
,
page
int
)
(
list
[]
*
model
.
ZdInstances
,
total
int
)
{
instances
:=
s
.
resService
.
LoadRes
(
"instances"
)
list
,
_
,
_
=
s
.
instancesRepo
.
List
(
""
,
-
1
)
s
.
importResToDB
(
instances
,
list
)
list
,
total
,
_
=
s
.
instancesRepo
.
List
(
strings
.
TrimSpace
(
keywords
),
page
)
return
}
...
...
src/server/service/ranges.go
浏览文件 @
2b5c5548
...
...
@@ -21,12 +21,7 @@ type RangesService struct {
}
func
(
s
*
RangesService
)
List
(
keywords
string
,
page
int
)
(
list
[]
*
model
.
ZdRanges
,
total
int
)
{
ranges
:=
s
.
resService
.
LoadRes
(
"ranges"
)
list
,
_
,
_
=
s
.
rangesRepo
.
List
(
""
,
-
1
)
s
.
importResToDB
(
ranges
,
list
)
list
,
total
,
_
=
s
.
rangesRepo
.
List
(
strings
.
TrimSpace
(
keywords
),
page
)
return
}
...
...
src/server/service/sync.go
浏览文件 @
2b5c5548
...
...
@@ -26,7 +26,6 @@ func (s *SyncService) SyncData(mode string) { // TODO: overwrite or not
}
defs
:=
fileMap
[
"yaml"
]
s
.
defService
.
Sync
(
defs
)
}
...
...
src/server/service/text.go
浏览文件 @
2b5c5548
...
...
@@ -19,10 +19,6 @@ type TextService struct {
}
func
(
s
*
TextService
)
List
(
keywords
string
,
page
int
)
(
list
[]
*
model
.
ZdText
,
total
int
)
{
texts
:=
s
.
resService
.
LoadRes
(
"text"
)
list
,
_
,
_
=
s
.
textRepo
.
List
(
""
,
-
1
)
s
.
importResToDB
(
texts
,
list
)
list
,
total
,
_
=
s
.
textRepo
.
List
(
strings
.
TrimSpace
(
keywords
),
page
)
return
...
...
src/service/article.go
浏览文件 @
2b5c5548
...
...
@@ -5,6 +5,7 @@ import (
"github.com/easysoft/zendata/src/model"
constant
"github.com/easysoft/zendata/src/utils/const"
fileUtils
"github.com/easysoft/zendata/src/utils/file"
stringUtils
"github.com/easysoft/zendata/src/utils/string"
_
"github.com/mattn/go-sqlite3"
"gopkg.in/yaml.v3"
"path"
...
...
@@ -76,13 +77,7 @@ func convertSentYaml(filePath, dist string) (yamlPaths []string) {
}
bytes
,
_
:=
yaml
.
Marshal
(
&
conf
)
content
:=
string
(
bytes
)
// convert yaml format by using a map
m
:=
make
(
map
[
string
]
interface
{})
yaml
.
Unmarshal
([]
byte
(
content
),
&
m
)
bytes
,
_
=
yaml
.
Marshal
(
&
m
)
content
=
string
(
bytes
)
content
:=
stringUtils
.
ConvertYamlStringToMapFormat
(
bytes
)
content
=
strings
.
Replace
(
content
,
"xfields"
,
"
\n
fields"
,
-
1
)
yamlPath
:=
fileUtils
.
AddSepIfNeeded
(
dist
)
+
...
...
src/service/list.go
浏览文件 @
2b5c5548
...
...
@@ -149,7 +149,7 @@ func GetFilesAndDirs(pth, typ string, res *map[string][]model.ResFile) {
continue
}
file
:=
model
.
ResFile
{
Path
:
pth
+
constant
.
PthSep
+
name
}
file
:=
model
.
ResFile
{
Path
:
pth
+
constant
.
PthSep
+
name
,
UpdatedAt
:
fi
.
ModTime
()
}
(
*
res
)[
typ
]
=
append
((
*
res
)[
typ
],
file
)
}
}
...
...
src/utils/string/string.go
浏览文件 @
2b5c5548
...
...
@@ -12,6 +12,7 @@ import (
"github.com/easysoft/zendata/src/model"
constant
"github.com/easysoft/zendata/src/utils/const"
"github.com/mattn/go-runewidth"
"gopkg.in/yaml.v2"
"strconv"
"strings"
"unicode"
...
...
@@ -268,3 +269,12 @@ func ReplaceSpecialChars(bytes []byte) []byte {
return
[]
byte
(
ret
)
}
func
ConvertYamlStringToMapFormat
(
bytes
[]
byte
)
(
ret
string
)
{
m
:=
yaml
.
MapSlice
{}
yaml
.
Unmarshal
(
bytes
,
&
m
)
bytesReturn
,
_
:=
yaml
.
Marshal
(
&
m
)
ret
=
string
(
bytesReturn
)
return
}
ui/src/layout/MainLayout.less
浏览文件 @
2b5c5548
...
...
@@ -15,7 +15,7 @@ h1, h2, h3, h4, h5, h6 {
.head {
display: flex;
.title {
width:
2
00px;
width:
3
00px;
margin-bottom: 15px;
padding: 3px 5px;
line-height: 32px;
...
...
users/test/_test-data.yaml
已删除
100644 → 0
浏览文件 @
1854a924
title
:
数据测试
desc
:
author
:
zentao
version
:
1.0
fields
:
-
field
:
field_with_children
# 字段多层嵌套
fields
:
-
field
:
child1
range
:
a-z
prefix
:
part1_
postfix
:
'
|'
-
field
:
child2
range
:
A-Z
prefix
:
part2_
postfix
:
'
|'
-
field
:
child_with_child
prefix
:
part3_
postfix
:
fields
:
-
field
:
field_grandson
prefix
:
int_
range
:
10-20
postfix
:
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录