Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
f90920fb
Z
zendata
项目概览
易企天创
/
zendata
接近 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
f90920fb
编写于
5月 13, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
select data from temp table
上级
5472ee5e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
5 deletion
+32
-5
src/gen/excel.go
src/gen/excel.go
+30
-5
src/gen/generator.go
src/gen/generator.go
+1
-0
src/model/definition.go
src/model/definition.go
+1
-0
未找到文件。
src/gen/excel.go
浏览文件 @
f90920fb
...
@@ -25,7 +25,7 @@ func GenerateFieldValuesFromExcel(field *model.Field, fieldValue *model.FieldVal
...
@@ -25,7 +25,7 @@ func GenerateFieldValuesFromExcel(field *model.Field, fieldValue *model.FieldVal
path
:=
constant
.
DataDir
+
file
path
:=
constant
.
DataDir
+
file
ConvertExcelToSQLite
(
*
field
,
path
)
ConvertExcelToSQLite
(
*
field
,
path
)
list
=
strings
.
Split
(
"str"
+
path
,
"
\n
"
)
list
=
ReadDataSQLite
(
*
field
)
// get step and rand
// get step and rand
rand
:=
false
rand
:=
false
...
@@ -120,9 +120,10 @@ func ConvertExcelToSQLite(field model.Field, path string) {
...
@@ -120,9 +120,10 @@ func ConvertExcelToSQLite(field model.Field, path string) {
valList
=
valList
+
")"
valList
=
valList
+
")"
}
}
dropSql
:=
fmt
.
Sprintf
(
dropTemplate
,
field
.
Name
)
tableName
:=
field
.
Name
+
"_"
+
sheet
ddl
:=
fmt
.
Sprintf
(
ddlTemplate
,
field
.
Name
,
colDefine
)
dropSql
:=
fmt
.
Sprintf
(
dropTemplate
,
tableName
)
insertSql
:=
fmt
.
Sprintf
(
insertTemplate
,
field
.
Name
,
colList
,
valList
)
ddl
:=
fmt
.
Sprintf
(
ddlTemplate
,
tableName
,
colDefine
)
insertSql
:=
fmt
.
Sprintf
(
insertTemplate
,
tableName
,
colList
,
valList
)
db
,
err
:=
sql
.
Open
(
"sqlite3"
,
constant
.
SqliteSource
)
db
,
err
:=
sql
.
Open
(
"sqlite3"
,
constant
.
SqliteSource
)
_
,
err
=
db
.
Exec
(
dropSql
)
_
,
err
=
db
.
Exec
(
dropSql
)
...
@@ -141,8 +142,32 @@ func ConvertExcelToSQLite(field model.Field, path string) {
...
@@ -141,8 +142,32 @@ func ConvertExcelToSQLite(field model.Field, path string) {
}
}
}
}
func
ReadDataSQLite
(
table
string
)
[]
string
{
func
ReadDataSQLite
(
field
model
.
Field
)
[]
string
{
list
:=
make
([]
string
,
0
)
list
:=
make
([]
string
,
0
)
db
,
err
:=
sql
.
Open
(
constant
.
SqliteDriver
,
constant
.
SqliteSource
)
if
err
!=
nil
{
logUtils
.
Screen
(
"fail to open "
+
constant
.
SqliteSource
+
": "
+
err
.
Error
())
return
list
}
rows
,
err
:=
db
.
Query
(
field
.
Filter
)
if
err
!=
nil
{
logUtils
.
Screen
(
"fail to exec query "
+
err
.
Error
())
return
list
}
for
rows
.
Next
()
{
var
val
string
err
=
rows
.
Scan
(
&
val
)
if
err
!=
nil
{
logUtils
.
Screen
(
"fail to get sqlite3 row: "
+
err
.
Error
())
return
list
}
list
=
append
(
list
,
val
)
}
return
list
return
list
}
}
src/gen/generator.go
浏览文件 @
f90920fb
...
@@ -83,6 +83,7 @@ func GenerateForField(field *model.Field, total int) []string {
...
@@ -83,6 +83,7 @@ func GenerateForField(field *model.Field, total int) []string {
}
else
{
// other type like address.city
}
else
{
// other type like address.city
arr
:=
strings
.
Split
(
field
.
Type
,
"."
)
arr
:=
strings
.
Split
(
field
.
Type
,
"."
)
referField
:=
constant
.
LoadedFields
[
arr
[
0
]]
referField
:=
constant
.
LoadedFields
[
arr
[
0
]]
referField
.
Filter
=
field
.
Range
values
=
GenerateFieldItemsFromDefinition
(
&
referField
,
total
)
values
=
GenerateFieldItemsFromDefinition
(
&
referField
,
total
)
}
}
...
...
src/model/definition.go
浏览文件 @
f90920fb
...
@@ -14,6 +14,7 @@ type Field struct {
...
@@ -14,6 +14,7 @@ type Field struct {
Note
string
`yaml:"note"`
Note
string
`yaml:"note"`
Type
string
`yaml:"type"`
Type
string
`yaml:"type"`
Range
string
`yaml:"range"`
Range
string
`yaml:"range"`
Filter
string
`yaml:"filter"`
Prefix
string
`yaml:"prefix"`
Prefix
string
`yaml:"prefix"`
Postfix
string
`yaml:"postfix"`
Postfix
string
`yaml:"postfix"`
Loop
int
`yaml:"loop"`
Loop
int
`yaml:"loop"`
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录