Skip to content

Commit 513259f

Browse files
author
pixel
committed
自动初始化单独建包 为 命令行做基础
1 parent 11cde72 commit 513259f

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

server/go.mod

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ require (
2222
github.com/json-iterator/go v1.1.10 // indirect
2323
github.com/lestrrat-go/file-rotatelogs v2.3.0+incompatible
2424
github.com/lestrrat-go/strftime v1.0.3 // indirect
25-
github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570 // indirect
26-
github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042 // indirect
2725
github.com/mailru/easyjson v0.7.1 // indirect
2826
github.com/mitchellh/mapstructure v1.2.2 // indirect
2927
github.com/mojocn/base64Captcha v1.3.1
@@ -42,7 +40,6 @@ require (
4240
github.com/swaggo/swag v1.6.7
4341
github.com/tebeka/strftime v0.1.3 // indirect
4442
github.com/unrolled/secure v1.0.7
45-
github.com/urfave/cli v1.22.2 // indirect
4643
go.uber.org/zap v1.10.0
4744
golang.org/x/net v0.0.0-20200320220750-118fecf932d8 // indirect
4845
golang.org/x/sys v0.0.0-20200610111108-226ff32320da // indirect

server/gva/init_data/init_data.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"gin-vue-admin/model"
66
gormadapter "github.com/casbin/gorm-adapter/v3"
77
"github.com/satori/go.uuid"
8+
"go.uber.org/zap"
89
"gorm.io/gorm"
910
"time"
1011
)
@@ -309,6 +310,7 @@ func InitSysBaseMenus() (err error) {
309310
{Model: gorm.Model{ID: 23, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: true, ParentId: "3", Path: "dictionaryDetail/:id", Name: "dictionaryDetail", Component: "view/superAdmin/dictionary/sysDictionaryDetail.vue", Sort: 1, Meta: model.Meta{Title: "字典详情", Icon: "s-order"}},
310311
{Model: gorm.Model{ID: 24, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "3", Path: "operation", Name: "operation", Component: "view/superAdmin/operation/sysOperationRecord.vue", Sort: 6, Meta: model.Meta{Title: "操作历史", Icon: "time"}},
311312
{Model: gorm.Model{ID: 25, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "simpleUploader", Name: "simpleUploader", Component: "view/example/simpleUploader/simpleUploader", Sort: 6, Meta: model.Meta{Title: "断点续传(插件版)", Icon: "upload"}},
313+
{Model: gorm.Model{ID: 26, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "0", Path: "https://www.gin-vue-admin.com", Name: "https://www.gin-vue-admin.com", Hidden: false, Component: "/", Sort: 0, Meta: model.Meta{Title: "官方网站", Icon: "s-home"}},
312314
}
313315
if tx.Create(&insert).Error != nil { // 遇到错误时回滚事务
314316
tx.Rollback()
@@ -366,6 +368,7 @@ func InitSysAuthorityMenus() (err error) {
366368
{"888", 23},
367369
{"888", 24},
368370
{"888", 25},
371+
{"888", 26},
369372
{"8881", 1},
370373
{"8881", 2},
371374
{"8881", 8},
@@ -476,7 +479,7 @@ func InitData() {
476479
err = InitSysDictionaryDetail()
477480
err = InitExaFileUploadAndDownload()
478481
if err != nil {
479-
global.GVA_LOG.Error("initialize data failed", err)
482+
global.GVA_LOG.Error("initialize data failed", zap.Any("err", err))
480483
}
481484
global.GVA_LOG.Debug("initialize data success")
482485
}

server/initialize/data.go

Whitespace-only changes.

server/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"gin-vue-admin/core"
55
"gin-vue-admin/global"
6-
"gin-vue-admin/gva/init_data"
6+
//"gin-vue-admin/gva/init_data"
77
"gin-vue-admin/initialize"
88
//"runtime"
99
)
@@ -25,7 +25,7 @@ func main() {
2525
initialize.Mysql()
2626
}
2727
initialize.DBTables()
28-
init_data.InitData() // 打开注释即可初始化数据
28+
//init_data.InitData() // 打开注释即可初始化数据 使用过后一定要再次注释或删除
2929
// 程序结束前关闭数据库链接
3030
db, _ := global.GVA_DB.DB()
3131
defer db.Close()

server/service/sys_db_initialize.go

Whitespace-only changes.

0 commit comments

Comments
 (0)