Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
89e192e3
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,发现更多精彩内容 >>
提交
89e192e3
编写于
5月 18, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
new definition format
上级
2892549e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
96 addition
and
36 deletion
+96
-36
src/action/generator.go
src/action/generator.go
+4
-1
src/gen/cls.go
src/gen/cls.go
+89
-0
src/gen/definition.go
src/gen/definition.go
+3
-35
未找到文件。
src/action/generator.go
浏览文件 @
89e192e3
...
...
@@ -22,7 +22,10 @@ func Generate(def string, total int, fieldsToExportStr string, out string, forma
fieldsToExport
:=
strings
.
Split
(
fieldsToExportStr
,
","
)
gen
.
LoadRootDef
(
def
,
fieldsToExport
)
rangeClsFields
,
instClsFields
:=
gen
.
LoadClsDef
(
def
,
fieldsToExport
)
rangeClsFields
=
rangeClsFields
instClsFields
=
instClsFields
rows
,
colTypes
:=
gen
.
GenerateForDefinition
(
total
,
fieldsToExport
)
content
:=
Print
(
rows
,
format
,
table
,
colTypes
,
fieldsToExport
)
...
...
src/gen/cls.go
0 → 100644
浏览文件 @
89e192e3
package
gen
import
(
"github.com/easysoft/zendata/src/model"
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.v2"
"io/ioutil"
"os"
"strings"
)
func
LoadClsDef
(
file
string
,
fieldsToExport
[]
string
)
[]
model
.
FieldValue
{
referFieldValues
:=
make
([]
model
.
FieldValue
,
0
)
yamlContent
,
err
:=
ioutil
.
ReadFile
(
file
)
if
err
!=
nil
{
logUtils
.
Screen
(
"fail to read "
+
file
)
return
referFieldValues
}
def
:=
model
.
DefData
{}
err
=
yaml
.
Unmarshal
(
yamlContent
,
&
def
)
if
err
!=
nil
{
logUtils
.
Screen
(
"fail to parse "
+
file
)
return
referFieldValues
}
constant
.
RootDef
=
def
for
_
,
field
:=
range
def
.
Fields
{
if
!
stringUtils
.
FindInArr
(
field
.
Field
,
fieldsToExport
)
{
continue
}
loadClsField
(
&
field
,
&
referFieldValues
)
}
return
referFieldValues
}
func
loadClsField
(
field
*
model
.
DefField
,
referFieldValues
*
[]
model
.
FieldValue
)
{
if
len
(
field
.
Fields
)
>
0
{
for
_
,
child
:=
range
field
.
Fields
{
loadClsField
(
&
child
,
referFieldValues
)
}
}
else
if
field
.
From
!=
""
{
referFile
,
referType
,
tableName
:=
getReferProp
(
field
.
From
)
fieldValue
:=
getReferFieldValue
(
referFile
,
referType
,
tableName
)
*
referFieldValues
=
append
(
*
referFieldValues
,
fieldValue
)
}
}
func
getReferProp
(
from
string
)
(
string
,
string
,
string
)
{
referFile
:=
""
referType
:=
""
tableName
:=
""
sep
:=
string
(
os
.
PathSeparator
)
index
:=
strings
.
LastIndex
(
from
,
".yaml"
)
if
index
>
-
1
{
// yaml, system.nubmer.yaml
left
:=
from
[
:
index
]
left
=
strings
.
ReplaceAll
(
left
,
"."
,
sep
)
referFile
=
left
+
".yaml"
}
else
{
// excel, system.address.china
index
=
strings
.
LastIndex
(
from
,
"."
)
left
:=
from
[
:
index
]
left
=
strings
.
ReplaceAll
(
left
,
"."
,
sep
)
referFile
=
left
+
".xlsx"
tableName
=
from
[
index
:
]
}
if
strings
.
Index
(
referFile
,
"system"
)
>
-
1
{
referFile
=
constant
.
ResDir
+
referFile
}
return
referFile
,
referType
,
tableName
}
func
getReferFieldValue
(
referFile
string
,
referType
string
,
tableName
string
)
model
.
FieldValue
{
fieldValue
:=
model
.
FieldValue
{}
return
fieldValue
}
\ No newline at end of file
src/gen/definition.go
浏览文件 @
89e192e3
...
...
@@ -7,12 +7,10 @@ import (
stringUtils
"github.com/easysoft/zendata/src/utils/string"
"gopkg.in/yaml.v2"
"io/ioutil"
"os"
"strings"
)
func
LoadRootDef
(
file
string
,
fieldsToExport
[]
string
)
([]
model
.
ClsRange
,
[]
model
.
ClsInst
)
{
referRangeFields
:=
make
([]
model
.
ClsRange
,
0
)
func
LoadRootDef
(
file
string
,
fieldsToExport
[]
string
)
([]
model
.
ClsRange
s
,
[]
model
.
ClsInst
)
{
referRangeFields
:=
make
([]
model
.
ClsRange
s
,
0
)
referInstFields
:=
make
([]
model
.
ClsInst
,
0
)
yamlContent
,
err
:=
ioutil
.
ReadFile
(
file
)
...
...
@@ -38,7 +36,7 @@ func LoadRootDef(file string, fieldsToExport []string) ([]model.ClsRange, []mode
if
field
.
Select
!=
""
{
// excel
}
else
if
field
.
Use
!=
""
{
// range or instance format
//referFile, referType := getReferP
ath
(field.From)
//referFile, referType := getReferP
rop
(field.From)
// init const.ResMap
}
...
...
@@ -49,33 +47,3 @@ func LoadRootDef(file string, fieldsToExport []string) ([]model.ClsRange, []mode
return
referRangeFields
,
referInstFields
}
func
getReferPath
(
from
string
)
(
string
,
string
,
string
)
{
referFile
:=
""
referType
:=
""
tableName
:=
""
sep
:=
string
(
os
.
PathSeparator
)
index
:=
strings
.
LastIndex
(
from
,
".yaml"
)
if
index
>
-
1
{
// system.nubmer.yaml
left
:=
from
[
:
index
]
left
=
strings
.
ReplaceAll
(
left
,
"."
,
sep
)
referFile
=
left
+
".yaml"
}
else
{
// system.address.china
index
=
strings
.
LastIndex
(
from
,
"."
)
left
:=
from
[
:
index
]
left
=
strings
.
ReplaceAll
(
left
,
"."
,
sep
)
referFile
=
left
+
".xlsx"
tableName
=
from
[
index
:
]
}
if
strings
.
Index
(
referFile
,
"system"
)
>
-
1
{
referFile
=
constant
.
ResDir
+
referFile
}
return
referFile
,
referType
,
tableName
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录