Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
8e7f2a44
Z
zendata
项目概览
易企天创
/
zendata
9 个月 前同步成功
通知
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 搜索 >>
提交
8e7f2a44
编写于
12月 13, 2022
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
import data
上级
7f1b383d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
95 addition
and
3 deletion
+95
-3
cmd/test/comm/dao.go
cmd/test/comm/dao.go
+2
-0
cmd/test/import/advert.go
cmd/test/import/advert.go
+1
-3
cmd/test/import/joke.go
cmd/test/import/joke.go
+39
-0
cmd/test/import/medicine.go
cmd/test/import/medicine.go
+35
-0
cmd/test/model/model.go
cmd/test/model/model.go
+18
-0
未找到文件。
cmd/test/comm/dao.go
浏览文件 @
8e7f2a44
...
...
@@ -65,6 +65,8 @@ func GetDB() *gorm.DB {
&
model
.
IdiomSimple
{},
&
model
.
PoetryAncient
{},
&
model
.
PoetryCategory
{},
&
model
.
Medicine
{},
&
model
.
Joke
{},
)
if
err
!=
nil
{
fmt
.
Printf
(
color
.
RedString
(
"migrate models failed, error: %s."
,
err
.
Error
()))
...
...
cmd/test/import/advert.go
浏览文件 @
8e7f2a44
...
...
@@ -25,9 +25,7 @@ func main() {
col1
:=
arr
[
0
]
po
:=
model
.
Advert
{
DataComm
:
model
.
DataComm
{
Name
:
col1
,
},
Name
:
col1
,
}
if
po
.
Name
!=
""
{
...
...
cmd/test/import/joke.go
0 → 100644
浏览文件 @
8e7f2a44
package
main
import
(
"encoding/json"
"fmt"
"github.com/easysoft/zendata/cmd/test/comm"
"github.com/easysoft/zendata/cmd/test/model"
fileUtils
"github.com/easysoft/zendata/pkg/utils/file"
"strings"
)
func
main
()
{
filePath
:=
"/Users/aaron/work/zentao/product/zd/行业数据/笑话.json"
tableName
:=
model
.
Joke
{}
.
TableName
()
db
:=
comm
.
GetDB
()
err
:=
db
.
Exec
(
fmt
.
Sprintf
(
comm
.
TruncateTable
,
tableName
))
.
Error
if
err
!=
nil
{
panic
(
err
)
}
content
:=
fileUtils
.
ReadFileBuf
(
filePath
)
arr
:=
make
([]
string
,
0
)
json
.
Unmarshal
(
content
,
&
arr
)
for
_
,
item
:=
range
arr
{
item
=
strings
.
TrimSpace
(
item
)
cate
:=
model
.
Joke
{
Content
:
item
,
}
if
cate
.
Content
!=
""
{
db
.
Save
(
&
cate
)
}
}
}
cmd/test/import/medicine.go
0 → 100644
浏览文件 @
8e7f2a44
package
main
import
(
"fmt"
"github.com/easysoft/zendata/cmd/test/comm"
"github.com/easysoft/zendata/cmd/test/model"
fileUtils
"github.com/easysoft/zendata/pkg/utils/file"
"strings"
)
func
main
()
{
filePath
:=
"/Users/aaron/work/zentao/product/zd/行业数据/医学.txt"
tableName
:=
model
.
Medicine
{}
.
TableName
()
db
:=
comm
.
GetDB
()
err
:=
db
.
Exec
(
fmt
.
Sprintf
(
comm
.
TruncateTable
,
tableName
))
.
Error
if
err
!=
nil
{
panic
(
err
)
}
content
:=
fileUtils
.
ReadFile
(
filePath
)
for
_
,
line
:=
range
strings
.
Split
(
content
,
"
\n
"
)
{
arr
:=
strings
.
Split
(
strings
.
TrimSpace
(
line
),
" "
)
col1
:=
arr
[
0
]
po
:=
model
.
Medicine
{
Name
:
col1
,
}
if
po
.
Name
!=
""
{
db
.
Save
(
&
po
)
}
}
}
cmd/test/model/model.go
浏览文件 @
8e7f2a44
...
...
@@ -676,3 +676,21 @@ type PoetryCategory struct {
func
(
PoetryCategory
)
TableName
()
string
{
return
"biz_data_poetry_category"
}
type
Medicine
struct
{
DataComm
Name
string
`json:"name"`
}
func
(
Medicine
)
TableName
()
string
{
return
"biz_data_medicine"
}
type
Joke
struct
{
DataComm
Content
string
`json:"content"`
}
func
(
Joke
)
TableName
()
string
{
return
"biz_data_joke"
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录