You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.6 KiB
63 lines
1.6 KiB
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"io/ioutil"
|
|
|
|
common "main_program/common"
|
|
"main_program/config"
|
|
move_data "main_program/moveData"
|
|
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
func init() {
|
|
flag.StringVar(&common.ConfigFile, "cf", "config.yml", "配置文件名")
|
|
flag.StringVar(&common.Command, "cmd", "", "命令")
|
|
flag.StringVar(&common.Table, "table", "", "需要迁移的表")
|
|
flag.StringVar(&common.Dbpath, "sqlite", "", "sqlite文件地址")
|
|
flag.StringVar(&common.XlsxPath, "excel", "", "excel文件地址")
|
|
}
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
//读取配置文件
|
|
data, _ := ioutil.ReadFile(common.ConfigFile)
|
|
err := yaml.Unmarshal(data, &common.MyEnv)
|
|
if err != nil {
|
|
fmt.Println("读取配置文件错误...")
|
|
return
|
|
}
|
|
config.InitConfig(common.MyEnv.Log.LogEnv, common.MyEnv.Log.LogPath)
|
|
config.Logger.Info("初始化Logger成功...")
|
|
// 判断command
|
|
command := common.MyEnv.Command
|
|
if common.Command != "" {
|
|
command = common.Command
|
|
}
|
|
config.Logger.Infof("Command:%s", command)
|
|
if command == "move_data" {
|
|
// 判断参数
|
|
table := common.MyEnv.MoveData.Table
|
|
if common.Table != "" {
|
|
table = common.Table
|
|
}
|
|
dbPath := common.MyEnv.MoveData.DBPath
|
|
if common.Dbpath != "" {
|
|
dbPath = common.Dbpath
|
|
}
|
|
xlsxPath := common.MyEnv.MoveData.XlsxPath
|
|
if common.XlsxPath != "" {
|
|
xlsxPath = common.XlsxPath
|
|
}
|
|
if table == "" || dbPath == "" {
|
|
config.Logger.Error("move_data配置文件错误...")
|
|
return
|
|
}
|
|
config.Logger.Infof("开始调用move_data方法")
|
|
config.Logger.Infof("table:%s dbPath:%s xlsxPath:%s", table, dbPath, xlsxPath)
|
|
move_data.MoveDataService.Start(table, dbPath, common.MyEnv.Mysql, xlsxPath)
|
|
}
|
|
|
|
}
|
|
|