Skip to content

Commit

Permalink
包位置调整
Browse files Browse the repository at this point in the history
  • Loading branch information
pixel committed Mar 2, 2021
1 parent ded39b9 commit 7363fa5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
16 changes: 8 additions & 8 deletions server/cmd/gva/initdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ limitations under the License.
package gva

import (
"gin-vue-admin/cmd/source"
"gin-vue-admin/core"
"gin-vue-admin/utils"

"github.com/gookit/color"

_ "gin-vue-admin/core"
Expand All @@ -41,15 +40,16 @@ var initdbCmd = &cobra.Command{
path, _ := cmd.Flags().GetString("path")
global.GVA_VP = core.Viper(path)
global.GVA_LOG = core.Zap() // 初始化zap日志库
utils.Mysql.CheckDatabase()
utils.Mysql.CheckUtf8mb4()
utils.Mysql.Info()
utils.Mysql.Init()

source.Mysql.CheckDatabase()
source.Mysql.CheckUtf8mb4()
source.Mysql.Info()
source.Mysql.Init()
switch frame {
case "gin":
if global.GVA_CONFIG.System.DbType == "mysql" {
utils.Mysql.AutoMigrateTables()
utils.Mysql.InitData()
source.Mysql.AutoMigrateTables()
source.Mysql.InitData()
}
case "gf":
color.Info.Println("gf功能开发中")
Expand Down
3 changes: 1 addition & 2 deletions server/utils/init_db.go → server/cmd/source/init_db.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package utils
package source

import (
"database/sql"

"github.com/spf13/viper"
)

Expand Down
2 changes: 1 addition & 1 deletion server/utils/mysql.go → server/cmd/source/mysql.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package utils
package source

import (
"fmt"
Expand Down
8 changes: 4 additions & 4 deletions server/service/sys_initdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package service

import (
"fmt"
"gin-vue-admin/cmd/source"
"gin-vue-admin/global"
"gin-vue-admin/model/request"
"gin-vue-admin/utils"
)

//@author: [songzhibin97](https://github.com/songzhibin97)
Expand All @@ -23,7 +23,7 @@ func InitDB(conf request.InitDB) error {
dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/", conf.UserName, conf.Password, conf.Host, conf.Port)
fmt.Println(dsn)
createSql := fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_general_ci;", conf.DBName)
if err := utils.CreateTable(dsn, "mysql", createSql); err != nil {
if err := source.CreateTable(dsn, "mysql", createSql); err != nil {
return err
}
setting := map[string]interface{}{
Expand All @@ -32,9 +32,9 @@ func InitDB(conf request.InitDB) error {
"mysql.username": conf.UserName,
"mysql.password": conf.Password,
}
if err := utils.WriteConfig(global.GVA_VP, setting); err != nil {
if err := source.WriteConfig(global.GVA_VP, setting); err != nil {
return err
}
utils.InitDB()
source.InitDB()
return nil
}

0 comments on commit 7363fa5

Please sign in to comment.