Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
b980ed1d
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 搜索 >>
提交
b980ed1d
编写于
11月 20, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
close task#8435
上级
986da6a0
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
143 addition
and
159 deletion
+143
-159
src/model/model.go
src/model/model.go
+41
-46
src/server/repo/instances.go
src/server/repo/instances.go
+0
-1
src/server/service/common.go
src/server/service/common.go
+67
-67
src/server/service/instances.go
src/server/service/instances.go
+18
-14
src/server/service/instancesItem.go
src/server/service/instancesItem.go
+1
-1
src/zd.go
src/zd.go
+3
-3
yaml/test/_test-instacnes.yaml
yaml/test/_test-instacnes.yaml
+13
-27
未找到文件。
src/model/model.go
浏览文件 @
b980ed1d
...
...
@@ -145,16 +145,11 @@ func (*ZdRangesItem) TableName() string {
}
type
ZdInstances
struct
{
Model
Title
string
`gorm:"column:title" json:"title"`
Name
string
`gorm:"column:name" json:"name"`
Desc
string
`gorm:"column:desc" json:"desc"`
Field
string
`gorm:"column:field" json:"field"`
Note
string
`gorm:"column:note" json:"note"`
Prefix
string
`gorm:"column:prefix" json:"prefix"`
Postfix
string
`gorm:"column:postfix" json:"postfix"`
Format
string
`gorm:"column:format" json:"format"`
Instances
[]
ZdInstancesItem
`gorm:"ForeignKey:instancesID" json:"instances"`
Model
`yaml:"-"`
Title
string
`gorm:"column:title" json:"title" yaml:"title,omitempty"`
Name
string
`gorm:"column:name" json:"name" yaml:"-"`
Desc
string
`gorm:"column:desc" json:"desc" yaml:"desc,omitempty"`
Instances
[]
ZdInstancesItem
`gorm:"ForeignKey:instancesID" json:"instances" yaml:"instances"`
Yaml
string
`gorm:"yaml" json:"yaml" yaml:"-"`
Path
string
`gorm:"column:path" json:"path" yaml:"-"`
...
...
@@ -165,46 +160,46 @@ func (*ZdInstances) TableName() string {
}
type
ZdInstancesItem
struct
{
Model
InstancesID
uint
`gorm:"column:instancesID" json:"instancesID"`
ParentID
uint
`gorm:"column:parentID" json:"parentID"`
Field
string
`gorm:"column:field" json:"field"`
Note
string
`gorm:"column:note" json:"note"`
Instance
string
`gorm:"column:instance" json:"instance"`
Range
string
`gorm:"column:range" json:"range"`
Exp
string
`gorm:"column:exp" json:"exp"`
Prefix
string
`gorm:"column:prefix" json:"prefix"`
Postfix
string
`gorm:"column:postfix" json:"postfix"`
Loop
string
`gorm:"column:loop" json:"loop"`
Loopfix
string
`gorm:"column:loopfix" json:"loopfix"`
Format
string
`gorm:"column:format" json:"format"`
Type
string
`gorm:"column:type" json:"type"`
Mode
string
`gorm:"column:mode" json:"mode"`
Length
int
`gorm:"column:length" json:"length"`
LeftPad
string
`gorm:"column:leftPad" json:"leftPad"`
RightPad
string
`gorm:"column:rightPad" json:"rightPad"`
Rand
bool
`gorm:"column:rand" json:"rand"`
ConfigID
uint
`gorm:"column:configID" json:"configID"`
Config
string
`gorm:"column:config" json:"config"`
Use
string
`gorm:"column:use" json:"use"`
UseID
uint
`gorm:"column:useID" json:"useID"`
From
string
`gorm:"column:fromCol" json:"fromCol"`
Select
string
`gorm:"column:selectCol" json:"selectCol"`
Where
string
`gorm:"column:whereCol" json:"whereCol"`
Limit
int
`gorm:"column:limitCol" json:"limitCol"`
Ord
int
`gorm:"column:ord;default:1" json:"ord"`
Fields
[]
*
ZdInstancesItem
`gorm:"-" json:"fields"`
Froms
[]
*
ZdInstancesItem
`gorm:"-" json:"froms"`
Model
`yaml:"-"`
InstancesID
uint
`gorm:"column:instancesID" json:"instancesID"
yaml:"-"
`
ParentID
uint
`gorm:"column:parentID" json:"parentID"
yaml:"-"
`
Field
string
`gorm:"column:field" json:"field"
yaml:"field,omitempty"
`
Note
string
`gorm:"column:note" json:"note"
yaml:"note,omitempty"
`
Instance
string
`gorm:"column:instance" json:"instance"
yaml:"instance,omitempty"
`
Range
string
`gorm:"column:range" json:"range"
yaml:"range,omitempty"
`
Exp
string
`gorm:"column:exp" json:"exp"
yaml:"exp,omitempty"
`
Prefix
string
`gorm:"column:prefix" json:"prefix"
yaml:"prefix,omitempty"
`
Postfix
string
`gorm:"column:postfix" json:"postfix"
yaml:"postfix,omitempty"
`
Loop
string
`gorm:"column:loop" json:"loop"
yaml:"loop,omitempty"
`
Loopfix
string
`gorm:"column:loopfix" json:"loopfix"
yaml:"loopfix,omitempty"
`
Format
string
`gorm:"column:format" json:"format"
yaml:"format,omitempty"
`
Type
string
`gorm:"column:type" json:"type"
yaml:"type,omitempty"
`
Mode
string
`gorm:"column:mode" json:"mode"
yaml:"mode,omitempty"
`
Length
int
`gorm:"column:length" json:"length"
yaml:"length,omitempty"
`
LeftPad
string
`gorm:"column:leftPad" json:"leftPad"
yaml:"leftPad,omitempty"
`
RightPad
string
`gorm:"column:rightPad" json:"rightPad"
yaml:"rightPad,omitempty"
`
Rand
bool
`gorm:"column:rand" json:"rand"
yaml:"rand,omitempty"
`
ConfigID
uint
`gorm:"column:configID" json:"configID"
yaml:"-"
`
Config
string
`gorm:"column:config" json:"config"
yaml:"config,omitempty"
`
Use
string
`gorm:"column:use" json:"use"
yaml:"use,omitempty"
`
UseID
uint
`gorm:"column:useID" json:"useID"
yaml:"-"
`
From
string
`gorm:"column:fromCol" json:"fromCol"
yaml:"from,omitempty"
`
Select
string
`gorm:"column:selectCol" json:"selectCol"
yaml:"select,omitempty"
`
Where
string
`gorm:"column:whereCol" json:"whereCol"
yaml:"where,omitempty"
`
Limit
int
`gorm:"column:limitCol" json:"limitCol"
yaml:"limit,omitempty"
`
Ord
int
`gorm:"column:ord;default:1" json:"ord"
yaml:"-"
`
Fields
[]
*
ZdInstancesItem
`gorm:"-" json:"fields"
yaml:"fields,omitempty"
`
Froms
[]
*
ZdInstancesItem
`gorm:"-" json:"froms"
yaml:"froms,omitempty"
`
// for range edit
IsRange
bool
`gorm:"column:isRange;default:true" json:"isRange"`
Sections
[]
ZdSection
`gorm:"ForeignKey:fieldID" json:"sections"`
IsRange
bool
`gorm:"column:isRange;default:true" json:"isRange"
yaml:"-"
`
Sections
[]
ZdSection
`gorm:"ForeignKey:fieldID" json:"sections"
yaml:"-"
`
// for refer edit
Refer
ZdRefer
`gorm:"ForeignKey:fieldID" json:"refer"`
Refer
ZdRefer
`gorm:"ForeignKey:fieldID" json:"refer"
yaml:"-"
`
}
func
(
*
ZdInstancesItem
)
TableName
()
string
{
return
constant
.
TablePrefix
+
"instances_item"
...
...
src/server/repo/instances.go
浏览文件 @
b980ed1d
...
...
@@ -130,7 +130,6 @@ func (r *InstancesRepo) haveChild(Data []*model.ZdInstancesItem,
func
(
r
*
InstancesRepo
)
GenInst
(
po
model
.
ZdInstances
,
res
*
model
.
ResInsts
)
{
res
.
Title
=
po
.
Title
res
.
Desc
=
po
.
Desc
res
.
Field
=
po
.
Field
}
func
NewInstancesRepo
(
db
*
gorm
.
DB
)
*
InstancesRepo
{
...
...
src/server/service/common.go
浏览文件 @
b980ed1d
...
...
@@ -2,48 +2,6 @@ package serverService
import
"github.com/easysoft/zendata/src/model"
func
instancesItemToResInstForExport
(
item
model
.
ZdInstancesItem
)
(
inst
model
.
ResInst
)
{
inst
.
Note
=
item
.
Note
for
_
,
child
:=
range
item
.
Fields
{
childField
:=
model
.
DefField
{}
instancesItemToResFieldForExport
(
*
child
,
&
childField
)
inst
.
Fields
=
append
(
inst
.
Fields
,
childField
)
}
if
len
(
inst
.
Fields
)
==
0
{
inst
.
Fields
=
nil
}
if
len
(
inst
.
Froms
)
==
0
{
inst
.
Froms
=
nil
}
return
}
func
instancesItemToResFieldForExport
(
item
model
.
ZdInstancesItem
,
field
*
model
.
DefField
)
{
for
_
,
item
:=
range
item
.
Fields
{
childField
:=
model
.
DefField
{}
instancesItemToResFieldForExport
(
*
item
,
&
childField
)
field
.
Fields
=
append
(
field
.
Fields
,
childField
)
}
for
_
,
from
:=
range
item
.
Froms
{
// only one level
childField
:=
model
.
DefField
{}
genFieldFromZdInstancesItem
(
*
from
,
&
childField
)
field
.
Froms
=
append
(
field
.
Froms
,
childField
)
}
if
len
(
field
.
Fields
)
==
0
{
field
.
Fields
=
nil
}
if
len
(
field
.
Froms
)
==
0
{
field
.
Froms
=
nil
}
}
func
zdFieldToFieldForExport
(
treeNode
model
.
ZdField
,
field
*
model
.
DefField
)
{
genFieldFromZdField
(
treeNode
,
field
)
...
...
@@ -97,28 +55,70 @@ func genFieldFromZdField(treeNode model.ZdField, field *model.DefField) () {
field
.
Limit
=
treeNode
.
Limit
}
func
genFieldFromZdInstancesItem
(
item
model
.
ZdInstancesItem
,
field
*
model
.
DefField
)
()
{
field
.
Field
=
item
.
Field
field
.
Note
=
item
.
Note
field
.
Range
=
item
.
Range
field
.
Value
=
item
.
Exp
field
.
Prefix
=
item
.
Prefix
field
.
Postfix
=
item
.
Postfix
field
.
Loop
=
item
.
Loop
field
.
Loopfix
=
item
.
Loopfix
field
.
Format
=
item
.
Format
field
.
Type
=
item
.
Type
field
.
Mode
=
item
.
Mode
field
.
Length
=
item
.
Length
field
.
LeftPad
=
item
.
LeftPad
field
.
RightPad
=
item
.
RightPad
field
.
Rand
=
item
.
Rand
field
.
Config
=
item
.
Config
field
.
Use
=
item
.
Use
field
.
From
=
item
.
From
field
.
Select
=
item
.
Select
field
.
Where
=
item
.
Where
field
.
Limit
=
item
.
Limit
}
//func instancesItemToResInstForExport(item model.ZdInstancesItem) (inst model.ResInst) {
// inst.Note = item.Note
//
// for _, child := range item.Fields {
// childField := model.DefField{}
// instancesItemToResFieldForExport(*child, &childField)
//
// inst.Fields = append(inst.Fields, childField)
// }
//
// if len(inst.Fields) == 0 {
// inst.Fields = nil
// }
// if len(inst.Froms) == 0 {
// inst.Froms = nil
// }
//
// return
//}
//func instancesItemToResFieldForExport(item model.ZdInstancesItem, field *model.DefField) {
// for _, item := range item.Fields {
// childField := model.DefField{}
// instancesItemToResFieldForExport(*item, &childField)
//
// field.Fields = append(field.Fields, childField)
// }
//
// for _, from := range item.Froms { // only one level
// childField := model.DefField{}
// genFieldFromZdInstancesItem(*from, &childField)
//
// field.Froms = append(field.Froms, childField)
// }
//
// if len(field.Fields) == 0 {
// field.Fields = nil
// }
// if len(field.Froms) == 0 {
// field.Froms = nil
// }
//}
//}
//func genFieldFromZdInstancesItem(item model.ZdInstancesItem, field *model.DefField) () {
// field.Field = item.Field
// field.Note = item.Note
//
// field.Range = item.Range
// field.Value = item.Exp
// field.Prefix = item.Prefix
// field.Postfix = item.Postfix
// field.Loop = item.Loop
// field.Loopfix = item.Loopfix
// field.Format = item.Format
// field.Type = item.Type
// field.Mode = item.Mode
// field.Length = item.Length
// field.LeftPad = item.LeftPad
// field.RightPad = item.RightPad
// field.Rand = item.Rand
//
// field.Config = item.Config
// field.Use = item.Use
// field.From = item.From
// field.Select = item.Select
// field.Where = item.Where
// field.Limit = item.Limit
//}
src/server/service/instances.go
浏览文件 @
b980ed1d
...
...
@@ -90,21 +90,25 @@ func (s *InstancesService) updateYaml(id uint) (err error) {
return
}
func
(
s
*
InstancesService
)
genYaml
(
instances
*
model
.
ZdInstances
)
(
str
string
)
{
items
,
err
:=
s
.
instancesRepo
.
GetItems
(
instances
.
ID
)
if
err
!=
nil
{
return
}
yamlObj
:=
model
.
ResInsts
{}
s
.
instancesRepo
.
GenInst
(
*
instances
,
&
yamlObj
)
for
_
,
item
:=
range
items
{
inst
:=
instancesItemToResInstForExport
(
*
item
)
yamlObj
.
Instances
=
append
(
yamlObj
.
Instances
,
inst
)
//items, err := s.instancesRepo.GetItems(instances.ID)
//if err != nil {
// return
//}
//
//yamlObj := model.ResInsts{}
//s.instancesRepo.GenInst(*instances, &yamlObj)
//
//for _, item := range items {
// inst := instancesItemToResInstForExport(*item)
//
// yamlObj.Instances = append(yamlObj.Instances, inst)
//}
root
:=
s
.
GetItemTree
(
instances
.
ID
)
for
_
,
item
:=
range
root
.
Fields
{
instances
.
Instances
=
append
(
instances
.
Instances
,
*
item
)
}
bytes
,
err
:=
yaml
.
Marshal
(
yamlObj
)
bytes
,
_
:=
yaml
.
Marshal
(
instances
)
instances
.
Yaml
=
stringUtils
.
ConvertYamlStringToMapFormat
(
bytes
)
return
...
...
src/server/service/instancesItem.go
浏览文件 @
b980ed1d
...
...
@@ -5,7 +5,7 @@ import (
constant
"github.com/easysoft/zendata/src/utils/const"
)
func
(
s
*
InstancesService
)
GetItemTree
(
instancesId
int
)
(
root
model
.
ZdInstancesItem
)
{
func
(
s
*
InstancesService
)
GetItemTree
(
instancesId
u
int
)
(
root
model
.
ZdInstancesItem
)
{
root
=
s
.
instancesRepo
.
GetItemTree
(
uint
(
instancesId
))
return
}
...
...
src/zd.go
浏览文件 @
b980ed1d
...
...
@@ -475,7 +475,7 @@ func (s *Server) admin(writer http.ResponseWriter, req *http.Request) {
case
"removeInstances"
:
err
=
s
.
instancesService
.
Remove
(
reqData
.
Id
)
case
"getResInstancesItemTree"
:
ret
.
Data
=
s
.
instancesService
.
GetItemTree
(
reqData
.
Id
)
ret
.
Data
=
s
.
instancesService
.
GetItemTree
(
uint
(
reqData
.
Id
)
)
case
"getResInstancesItem"
:
ret
.
Data
=
s
.
instancesService
.
GetItem
(
reqData
.
Id
)
case
"createResInstancesItem"
:
...
...
@@ -483,14 +483,14 @@ func (s *Server) admin(writer http.ResponseWriter, req *http.Request) {
ownerId
:=
reqData
.
DomainId
item
,
err
=
s
.
instancesService
.
CreateItem
(
ownerId
,
reqData
.
Id
,
reqData
.
Mode
)
ret
.
Data
=
s
.
instancesService
.
GetItemTree
(
ownerId
)
ret
.
Data
=
s
.
instancesService
.
GetItemTree
(
uint
(
ownerId
)
)
ret
.
Model
=
item
case
"saveInstancesItem"
:
rangesItem
:=
serverUtils
.
ConvertInstancesItem
(
reqData
.
Data
)
ret
.
Data
=
s
.
instancesService
.
SaveItem
(
&
rangesItem
)
case
"removeResInstancesItem"
:
err
=
s
.
instancesService
.
RemoveItem
(
reqData
.
Id
)
ret
.
Data
=
s
.
instancesService
.
GetItemTree
(
reqData
.
DomainId
)
ret
.
Data
=
s
.
instancesService
.
GetItemTree
(
uint
(
reqData
.
DomainId
)
)
case
"listExcel"
:
ret
.
Data
,
ret
.
Total
=
s
.
excelService
.
List
(
reqData
.
Keywords
,
reqData
.
Page
)
...
...
yaml/test/_test-instacnes.yaml
浏览文件 @
b980ed1d
title
:
_test-instacnes
desc
:
实例测试
field
:
country
instances
:
-
field
:
"
"
-
field
:
instant1
note
:
测试
range
:
"
"
instance
:
"
"
fields
:
[]
froms
:
[]
-
field
:
"
"
note
:
测试
range
:
"
"
instance
:
"
"
fields
:
[]
froms
:
[]
-
field
:
"
"
range
:
"
"
instance
:
"
"
fields
:
[]
froms
:
[]
-
field
:
"
"
range
:
"
"
instance
:
"
"
fields
:
[]
froms
:
[]
-
field
:
"
"
range
:
"
"
instance
:
"
"
fields
:
[]
froms
:
[]
instance
:
instant1
fields
:
-
field
:
field1
note
:
测试
fields
:
-
field
:
field1-1
range
:
0-9
postfix
:
'
,'
-
field
:
field1-2
range
:
a-z
-
field
:
field2
range
:
A-Z
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录