package main

import log "github.com/donnie4w/go-logger/logger"

func initClass() {
	initMgo()
	initMysql()
}

//初始化mgo
func initMgo() {
	if IsLocal {
		Source_Mgo = &MongodbSim{
			MongodbAddr: "192.168.3.207:27092",
			DbName:      "zktest_extract_data",
			Size:        10,
			UserName:    "",
			Password:    "",
		}
		Source_Mgo.InitPool()

		Bid_Mgo = &MongodbSim{
			MongodbAddr: "192.168.3.207:27092",
			DbName:      "zktest_extract_data",
			Size:        10,
			UserName:    "",
			Password:    "",
		}
		Bid_Mgo.InitPool()
	} else {
		Source_Mgo = &MongodbSim{
			MongodbAddr: "172.17.4.87:27080",
			DbName:      "zk_sqldata",
			Size:        10,
			UserName:    "",
			Password:    "",
		}
		Source_Mgo.InitPool()

		Bid_Mgo = &MongodbSim{
			MongodbAddr: "172.17.145.163:27083,172.17.4.187:27082",
			DbName:      "qfw",
			Size:        10,
			UserName:    "zhengkun",
			Password:    "zk@123123",
		}
		Bid_Mgo.InitPool()
	}
}

func initMysql() {
	username, password := "root", "=PDT49#80Z!RVv52_z"
	address := "192.168.3.217:4000"
	if !IsLocal {
		username = "zhengkun"
		password = "Zk#20220824"
		address = "172.17.4.242:4000"
	}
	MysqlDevTool = &Mysql{
		Address:  address,
		UserName: username,
		PassWord: password,
		DBName:   "seo_words",
	}
	MysqlDevTool.Init()

}

func InsertMysqlDevData(name string, data map[string]interface{}, mark interface{}) int64 {
	inb := MysqlDevTool.Insert(name, data)
	if inb == -1 {
		log.Debug("插入数据异常...", name, "~", mark)
	}
	return inb
}
