Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
f982c222
Z
zendata
项目概览
易企天创
/
zendata
10 个月 前同步成功
通知
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 搜索 >>
提交
f982c222
编写于
12月 08, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
close task#8568
上级
f619bc2f
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
66 addition
and
33 deletion
+66
-33
Makefile
Makefile
+3
-4
src/gen/res.go
src/gen/res.go
+13
-6
src/server/service/preview.go
src/server/service/preview.go
+38
-10
src/server/utils/gen.go
src/server/utils/gen.go
+7
-7
src/zd.go
src/zd.go
+2
-2
tmp/cache/.data.db
tmp/cache/.data.db
+0
-0
ui/src/api/manage.js
ui/src/api/manage.js
+2
-3
ui/src/components/Design.vue
ui/src/components/Design.vue
+1
-1
未找到文件。
Makefile
浏览文件 @
f982c222
...
...
@@ -44,8 +44,9 @@ compile_mac:
copy_files
:
@
echo
'start copy files'
@
cp
-r
{
data,yaml,users,demo,tmp
}
bin
&&
rm
-rf
${BIN_DIR}
/demo/output
@
rm
-rf
${BIN_DIR}
/tmp/cache/.data.db-shm
&&
rm
-rf
${BIN_DIR}
/tmp/cache/.data.db-wal
@
cp
-r
{
data,yaml,users,demo
}
bin
&&
rm
-rf
${BIN_DIR}
/demo/output
@mkdir
-p
${BIN_DIR}/tmp/cache
&&
sqlite3
tmp/cache/.data.db
".backup '${BIN_DIR}/tmp/cache/.data.db'"
@for
subdir
in
`ls
${BIN_OUT}`;
do
cp
-r
{bin/data,bin/yaml,bin/users,bin/demo,bin/tmp}
"${BIN_OUT}$${subdir}/zd"
;
done
...
...
@@ -56,5 +57,3 @@ package:
@cd
${BIN_OUT}
&&
\
for
subdir
in
`ls
./`;
do
cd
$${subdir}
&&
zip
-r
${BIN_ZIP_RELAT}$${subdir}/${BINARY}.zip
"${BINARY}"
&&
cd
..;
done
#@cd ${BIN_ZIP_DIR} && zip -r ${PACKAGE}.zip ./
#@cd ${BIN_DIR} && rm -rf ${PROJECT}
src/gen/res.go
浏览文件 @
f982c222
...
...
@@ -18,7 +18,9 @@ func LoadResDef(fieldsToExport []string) map[string]map[string][]string {
res
:=
map
[
string
]
map
[
string
][]
string
{}
for
index
,
field
:=
range
vari
.
Def
.
Fields
{
if
!
stringUtils
.
StrInArr
(
field
.
Field
,
fieldsToExport
)
{
continue
}
if
!
stringUtils
.
StrInArr
(
field
.
Field
,
fieldsToExport
)
{
continue
}
if
(
field
.
Use
!=
""
||
field
.
Select
!=
""
)
&&
field
.
From
==
""
{
field
.
From
=
vari
.
Def
.
From
...
...
@@ -89,7 +91,7 @@ func getLastDuplicateVal(preMap map[string][]string, key string) (valMap map[str
}
func
removeKeyNumber
(
key
string
)
string
{
arr
:=
strings
.
Split
(
key
,
"_"
)
ret
:=
strings
.
Join
(
arr
[
:
len
(
arr
)
-
1
],
"_"
)
ret
:=
strings
.
Join
(
arr
[
:
len
(
arr
)
-
1
],
"_"
)
return
ret
}
...
...
@@ -106,7 +108,7 @@ func getResValue(resFile, resType, sheet string, field *model.DefField) (map[str
return
groupedValues
,
resName
}
func
getResFromExcel
(
resFile
,
sheet
string
,
field
*
model
.
DefField
)
(
map
[
string
][]
string
)
{
// , string) {
func
getResFromExcel
(
resFile
,
sheet
string
,
field
*
model
.
DefField
)
map
[
string
][]
string
{
// , string) {
valueMap
:=
GenerateFieldValuesFromExcel
(
resFile
,
sheet
,
field
)
return
valueMap
...
...
@@ -141,7 +143,7 @@ func getResFromYaml(resFile string) (valueMap map[string][]string) { // , resNam
}
else
{
configRes
:=
model
.
DefField
{}
err
=
yaml
.
Unmarshal
(
yamlContent
,
&
configRes
)
if
err
==
nil
{
// config
if
err
==
nil
{
// config
valueMap
=
getResForConfig
(
configRes
)
//resName = configRes.Field
}
...
...
@@ -187,8 +189,12 @@ func getResFromRanges(ranges model.ResRanges) map[string][]string {
func
prepareNestedInstanceRes
(
insts
model
.
ResInstances
,
inst
model
.
ResInstancesItem
,
instField
model
.
DefField
)
{
// set "from" val from parent if needed
if
instField
.
From
==
""
{
if
insts
.
From
!=
""
{
instField
.
From
=
insts
.
From
}
if
inst
.
From
!=
""
{
instField
.
From
=
inst
.
From
}
if
insts
.
From
!=
""
{
instField
.
From
=
insts
.
From
}
if
inst
.
From
!=
""
{
instField
.
From
=
inst
.
From
}
}
if
instField
.
Use
!=
""
{
// refer to another instances or ranges
...
...
@@ -252,6 +258,7 @@ func convertInstantToField(insts model.ResInstances, inst model.ResInstancesItem
child
:=
model
.
DefField
{}
child
.
Field
=
inst
.
Instance
// some props are from parent instances
if
child
.
From
==
""
&&
inst
.
From
!=
""
{
child
.
From
=
inst
.
From
}
else
if
child
.
From
==
""
&&
insts
.
From
!=
""
{
...
...
src/server/service/preview.go
浏览文件 @
f982c222
...
...
@@ -3,14 +3,20 @@ package serverService
import
(
"fmt"
"github.com/easysoft/zendata/src/action"
"github.com/easysoft/zendata/src/model"
"github.com/easysoft/zendata/src/server/repo"
constant
"github.com/easysoft/zendata/src/utils/const"
fileUtils
"github.com/easysoft/zendata/src/utils/file"
"github.com/easysoft/zendata/src/utils/vari"
"github.com/jinzhu/copier"
"gopkg.in/yaml.v3"
)
type
PreviewService
struct
{
defRepo
*
serverRepo
.
DefRepo
fieldRepo
*
serverRepo
.
FieldRepo
referRepo
*
serverRepo
.
ReferRepo
defRepo
*
serverRepo
.
DefRepo
fieldRepo
*
serverRepo
.
FieldRepo
referRepo
*
serverRepo
.
ReferRepo
instancesRepo
*
serverRepo
.
InstancesRepo
}
func
(
s
*
PreviewService
)
PreviewDefData
(
defId
uint
)
(
data
string
)
{
...
...
@@ -21,12 +27,33 @@ func (s *PreviewService) PreviewDefData(defId uint) (data string) {
return
}
func
(
s
*
PreviewService
)
PreviewFieldData
(
fieldId
uint
)
(
data
string
)
{
field
,
_
:=
s
.
fieldRepo
.
Get
(
fieldId
)
fields
:=
field
.
Field
def
,
_
:=
s
.
defRepo
.
Get
(
field
.
DefID
)
func
(
s
*
PreviewService
)
PreviewFieldData
(
fieldId
uint
,
fieldType
string
)
(
data
string
)
{
var
field
model
.
ZdField
lines
:=
action
.
Generate
(
""
,
def
.
Path
,
fields
,
constant
.
FormatData
,
""
)
if
fieldType
==
constant
.
ResTypeDef
{
field
,
_
=
s
.
fieldRepo
.
Get
(
fieldId
)
}
else
if
fieldType
==
constant
.
ResTypeInstances
{
instItem
,
_
:=
s
.
instancesRepo
.
GetItem
(
fieldId
)
field
.
From
=
instItem
.
From
copier
.
Copy
(
&
field
,
instItem
)
}
ref
:=
model
.
ZdRefer
{}
if
!
field
.
IsRange
{
ref
,
_
=
s
.
referRepo
.
GetByOwnerId
(
field
.
ID
)
}
fld
:=
model
.
DefField
{}
genFieldFromZdField
(
field
,
ref
,
&
fld
)
def
:=
model
.
DefData
{}
def
.
Fields
=
append
(
def
.
Fields
,
fld
)
defContent
,
_
:=
yaml
.
Marshal
(
def
)
configFile
:=
vari
.
WorkDir
+
"tmp"
+
constant
.
PthSep
+
".temp.yaml"
fileUtils
.
WriteFile
(
configFile
,
string
(
defContent
))
lines
:=
action
.
Generate
(
""
,
configFile
,
field
.
Field
,
constant
.
FormatData
,
""
)
data
=
s
.
linesToStr
(
lines
)
return
...
...
@@ -42,6 +69,7 @@ func (s *PreviewService) linesToStr(lines []interface{}) (data string) {
return
}
func
NewPreviewService
(
defRepo
*
serverRepo
.
DefRepo
,
fieldRepo
*
serverRepo
.
FieldRepo
)
*
PreviewService
{
return
&
PreviewService
{
defRepo
:
defRepo
,
fieldRepo
:
fieldRepo
}
func
NewPreviewService
(
defRepo
*
serverRepo
.
DefRepo
,
fieldRepo
*
serverRepo
.
FieldRepo
,
instancesRepo
*
serverRepo
.
InstancesRepo
)
*
PreviewService
{
return
&
PreviewService
{
defRepo
:
defRepo
,
fieldRepo
:
fieldRepo
,
instancesRepo
:
instancesRepo
}
}
src/server/utils/gen.go
浏览文件 @
f982c222
...
...
@@ -9,17 +9,17 @@ import (
)
func
ParseGenParams
(
req
*
http
.
Request
)
(
defaultFile
,
configFile
,
fields
string
,
count
int
,
format
,
table
string
,
decode
bool
,
input
,
output
string
)
{
format
,
table
string
,
decode
bool
,
input
,
output
string
)
{
query
:=
req
.
URL
.
Query
()
defaultFile
=
ParserGetParams
(
query
,
"default"
,
"d"
)
configFile
=
ParserGetParams
(
query
,
"config"
,
"c"
)
countStr
:=
ParserGetParams
(
query
,
"lines"
,
"n"
)
defaultFile
=
ParserGetParams
(
query
,
"default"
,
"d"
)
configFile
=
ParserGetParams
(
query
,
"config"
,
"c"
)
countStr
:=
ParserGetParams
(
query
,
"lines"
,
"n"
)
if
countStr
==
""
{
countStr
=
"10"
}
fields
=
ParserGetParams
(
query
,
"field"
,
"F"
)
fields
=
ParserGetParams
(
query
,
"field"
,
"F"
)
format
=
constant
.
FormatJson
table
=
""
...
...
@@ -32,11 +32,11 @@ func ParseGenParams(req *http.Request) (defaultFile, configFile, fields string,
configDefContent
:=
ParserPostParams
(
req
,
"config"
,
"c"
,
""
,
true
)
if
defaultDefContent
!=
""
{
defaultFile
=
vari
.
WorkDir
+
"
._
default.yaml"
defaultFile
=
vari
.
WorkDir
+
"
tmp"
+
constant
.
PthSep
+
".
default.yaml"
fileUtils
.
WriteFile
(
defaultFile
,
defaultDefContent
)
}
if
configDefContent
!=
""
{
configFile
=
vari
.
WorkDir
+
"
._
config.yaml"
configFile
=
vari
.
WorkDir
+
"
tmp"
+
constant
.
PthSep
+
".
config.yaml"
fileUtils
.
WriteFile
(
configFile
,
configDefContent
)
}
}
...
...
src/zd.go
浏览文件 @
f982c222
...
...
@@ -324,7 +324,7 @@ func Init() (err error) {
syncService
:=
serverService
.
NewSyncService
(
defService
,
fieldService
,
rangesService
,
instancesService
,
configService
,
excelService
,
textService
,
referService
,
resService
)
previewService
:=
serverService
.
NewPreviewService
(
defRepo
,
fieldRepo
)
previewService
:=
serverService
.
NewPreviewService
(
defRepo
,
fieldRepo
,
instancesRepo
)
server
:=
NewServer
(
config
,
defService
,
fieldService
,
sectionService
,
referService
,
rangesService
,
instancesService
,
textService
,
excelService
,
configService
,
resService
,
...
...
@@ -418,7 +418,7 @@ func (s *Server) admin(writer http.ResponseWriter, req *http.Request) {
case
"previewDefData"
:
ret
.
Data
=
s
.
previewService
.
PreviewDefData
(
uint
(
reqData
.
Id
))
case
"previewFieldData"
:
ret
.
Data
=
s
.
previewService
.
PreviewFieldData
(
uint
(
reqData
.
Id
))
ret
.
Data
=
s
.
previewService
.
PreviewFieldData
(
uint
(
reqData
.
Id
)
,
reqData
.
Mode
)
// field or instances section
case
"listSection"
:
...
...
tmp/cache/.data.db
浏览文件 @
f982c222
无法预览此类型文件
ui/src/api/manage.js
浏览文件 @
f982c222
...
...
@@ -118,9 +118,8 @@ export function previewDefData (defId) {
data
:
data
})
}
export
function
previewFieldData
(
fieldId
)
{
const
data
=
{
'
action
'
:
'
previewFieldData
'
,
id
:
fieldId
}
export
function
previewFieldData
(
fieldId
,
type
)
{
const
data
=
{
'
action
'
:
'
previewFieldData
'
,
id
:
fieldId
,
mode
:
type
}
return
request
({
url
:
api
.
admin
,
method
:
'
post
'
,
...
...
ui/src/components/Design.vue
浏览文件 @
f982c222
...
...
@@ -476,7 +476,7 @@ export default {
this
.
tabKey
=
activeKey
if
(
this
.
tabKey
===
'
preview
'
)
{
previewFieldData
(
this
.
modelData
.
id
).
then
(
json
=>
{
previewFieldData
(
this
.
modelData
.
id
,
this
.
type
).
then
(
json
=>
{
console
.
log
(
'
previewFieldData
'
,
json
)
this
.
previewData
=
json
.
data
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录