|
@@ -2,6 +2,7 @@ package main
|
|
|
|
|
|
import (
|
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
|
+ "app.yhyue.com/moapp/jybase/mysql"
|
|
|
"context"
|
|
|
"fmt"
|
|
|
"github.com/ClickHouse/clickhouse-go/v2"
|
|
@@ -42,144 +43,36 @@ type (
|
|
|
LastUserBindingTime string `json:"lastUserBindingTime"`
|
|
|
}
|
|
|
DB struct {
|
|
|
- CornExp1 int64 `json:"cornexp1"`
|
|
|
- CornExp2 int64 `json:"cornexp2"`
|
|
|
- CornExp2Start string `json:"cornexp2Strat"`
|
|
|
- CornExp2End string `json:"cornexp2End"`
|
|
|
- CornExp3 string `json:"cornexp3"`
|
|
|
- CornExp4 string `json:"cornexp4"`
|
|
|
- CornExp5 int64 `json:"cornexp5"`
|
|
|
- CornExp6 int64 `json:"cornexp6"`
|
|
|
- CornExp7 string `json:"cornexp7"`
|
|
|
- CornExp8 int64 `json:"cornexp8"`
|
|
|
- CornExp9 string `json:"cornexp9"`
|
|
|
- TiDb struct {
|
|
|
- Host string `json:"host"`
|
|
|
- Port int `json:"port"`
|
|
|
- Database string `json:"database"`
|
|
|
- User string `json:"user"`
|
|
|
- Password string `json:"password"`
|
|
|
- PollSize int `json:"poolsize"`
|
|
|
- MaxIdle int `json:"maxidle"`
|
|
|
- MaxLeftTime int `json:"maxleft"`
|
|
|
- } `json:"tiDb"`
|
|
|
- TiDbData struct {
|
|
|
- Host string `json:"host"`
|
|
|
- Port int `json:"port"`
|
|
|
- Database string `json:"database"`
|
|
|
- User string `json:"user"`
|
|
|
- Password string `json:"password"`
|
|
|
- PollSize int `json:"poolsize"`
|
|
|
- MaxIdle int `json:"maxidle"`
|
|
|
- MaxLeftTime int `json:"maxleft"`
|
|
|
- } `json:"tiDbData"`
|
|
|
- TiDbPower struct {
|
|
|
- Host string `json:"host"`
|
|
|
- Port int `json:"port"`
|
|
|
- Database string `json:"database"`
|
|
|
- User string `json:"user"`
|
|
|
- Password string `json:"password"`
|
|
|
- PollSize int `json:"poolsize"`
|
|
|
- MaxIdle int `json:"maxidle"`
|
|
|
- MaxLeftTime int `json:"maxleft"`
|
|
|
- } `json:"tiDbPower"`
|
|
|
- WorderOrder struct {
|
|
|
- Host string `json:"host"`
|
|
|
- Port int `json:"port"`
|
|
|
- Database string `json:"database"`
|
|
|
- User string `json:"user"`
|
|
|
- Password string `json:"password"`
|
|
|
- PollSize int `json:"poolsize"`
|
|
|
- MaxIdle int `json:"maxidle"`
|
|
|
- MaxLeftTime int `json:"maxleft"`
|
|
|
- } `json:"workOrder"`
|
|
|
- BaseService struct {
|
|
|
- Host string `json:"host"`
|
|
|
- Port int `json:"port"`
|
|
|
- Database string `json:"database"`
|
|
|
- User string `json:"user"`
|
|
|
- Password string `json:"password"`
|
|
|
- PollSize int `json:"poolsize"`
|
|
|
- MaxIdle int `json:"maxidle"`
|
|
|
- MaxLeftTime int `json:"maxleft"`
|
|
|
- } `json:"baseService"`
|
|
|
- BiService struct {
|
|
|
- Host string `json:"host"`
|
|
|
- Port int `json:"port"`
|
|
|
- Database string `json:"database"`
|
|
|
- User string `json:"user"`
|
|
|
- Password string `json:"password"`
|
|
|
- PollSize int `json:"poolsize"`
|
|
|
- MaxIdle int `json:"maxidle"`
|
|
|
- MaxLeftTime int `json:"maxleft"`
|
|
|
- } `json:"biService"`
|
|
|
- ThirdParty struct {
|
|
|
- Host string `json:"host"`
|
|
|
- Port int `json:"port"`
|
|
|
- Database string `json:"database"`
|
|
|
- User string `json:"user"`
|
|
|
- Password string `json:"password"`
|
|
|
- PollSize int `json:"poolsize"`
|
|
|
- MaxIdle int `json:"maxidle"`
|
|
|
- MaxLeftTime int `json:"maxleft"`
|
|
|
- } `json:"thirdParty"`
|
|
|
- Jyactivities struct {
|
|
|
- Host string `json:"host"`
|
|
|
- Port int `json:"port"`
|
|
|
- Database string `json:"database"`
|
|
|
- User string `json:"user"`
|
|
|
- Password string `json:"password"`
|
|
|
- PollSize int `json:"poolsize"`
|
|
|
- MaxIdle int `json:"maxidle"`
|
|
|
- MaxLeftTime int `json:"maxleft"`
|
|
|
- } `json:"jyactivities"`
|
|
|
- DebrisProduct struct {
|
|
|
- Host string `json:"host"`
|
|
|
- Port int `json:"port"`
|
|
|
- Database string `json:"database"`
|
|
|
- User string `json:"user"`
|
|
|
- Password string `json:"password"`
|
|
|
- } `json:"debrisProduct"`
|
|
|
- Mysql struct {
|
|
|
- Host string `json:"host"`
|
|
|
- Port int `json:"port"`
|
|
|
- Database string `json:"database"`
|
|
|
- User string `json:"user"`
|
|
|
- Password string `json:"password"`
|
|
|
- PollSize int `json:"poolsize"`
|
|
|
- MaxIdle int `json:"maxidle"`
|
|
|
- MaxLeftTime int `json:"maxleft"`
|
|
|
- } `json:"mysql"`
|
|
|
- DataAnalysis struct {
|
|
|
- Host string `json:"host"`
|
|
|
- Port int `json:"port"`
|
|
|
- Database string `json:"database"`
|
|
|
- User string `json:"user"`
|
|
|
- Password string `json:"password"`
|
|
|
- PollSize int `json:"poolsize"`
|
|
|
- MaxIdle int `json:"maxidle"`
|
|
|
- MaxLeftTime int `json:"maxleft"`
|
|
|
- } `json:"dataAnalysis"`
|
|
|
- Mgo struct {
|
|
|
+ CornExp1 int64 `json:"cornexp1"`
|
|
|
+ CornExp2 int64 `json:"cornexp2"`
|
|
|
+ CornExp2Start string `json:"cornexp2Strat"`
|
|
|
+ CornExp2End string `json:"cornexp2End"`
|
|
|
+ CornExp3 string `json:"cornexp3"`
|
|
|
+ CornExp4 string `json:"cornexp4"`
|
|
|
+ CornExp5 int64 `json:"cornexp5"`
|
|
|
+ CornExp6 int64 `json:"cornexp6"`
|
|
|
+ CornExp7 string `json:"cornexp7"`
|
|
|
+ CornExp8 int64 `json:"cornexp8"`
|
|
|
+ CornExp9 string `json:"cornexp9"`
|
|
|
+ TiDb MysqlConfig `json:"tiDb"`
|
|
|
+ TiDbData MysqlConfig `json:"tiDbData"`
|
|
|
+ TiDbPower MysqlConfig `json:"tiDbPower"`
|
|
|
+ WorderOrder MysqlConfig `json:"workOrder"`
|
|
|
+ BaseService MysqlConfig `json:"baseService"`
|
|
|
+ BiService MysqlConfig `json:"biService"`
|
|
|
+ ThirdParty MysqlConfig `json:"thirdParty"`
|
|
|
+ Jyactivities MysqlConfig `json:"jyactivities"`
|
|
|
+ DebrisProduct MysqlConfig `json:"debrisProduct"`
|
|
|
+ Mysql MysqlConfig `json:"mysql"`
|
|
|
+ DataAnalysis MysqlConfig `json:"dataAnalysis"`
|
|
|
+ Mgo struct {
|
|
|
Address string `json:"address"`
|
|
|
DbName string `json:"dbName"`
|
|
|
DbSize int `json:"dbSize"`
|
|
|
} `json:"mgo"`
|
|
|
- MgoLog struct {
|
|
|
- Address string `json:"address"`
|
|
|
- DbName string `json:"dbName"`
|
|
|
- DbSize int `json:"dbSize"`
|
|
|
- User string `json:"user"`
|
|
|
- Password string `json:"password"`
|
|
|
- } `json:"mgoLog"`
|
|
|
- MgoQyxy struct {
|
|
|
- Address string `json:"address"`
|
|
|
- DbName string `json:"dbName"`
|
|
|
- DbSize int `json:"dbSize"`
|
|
|
- User string `json:"user"`
|
|
|
- Password string `json:"password"`
|
|
|
- } `json:"mgoQyxy"`
|
|
|
- Es struct {
|
|
|
+ MgoLog MongoConfig `json:"mgoLog"`
|
|
|
+ MgoQyxy MongoConfig `json:"mgoQyxy"`
|
|
|
+ Es struct {
|
|
|
Address string `json:"address"`
|
|
|
DbSize int `json:"dbSize"`
|
|
|
Version string `json:"version"`
|
|
@@ -220,6 +113,7 @@ type (
|
|
|
EntId int `json:"entId"`
|
|
|
Mail GmailAuth `json:"mail"` //邮箱配置
|
|
|
Clickhouse CHouseConfig `json:"clickhouse"`
|
|
|
+ Crm MysqlConfig `json:"crmTiDb"`
|
|
|
}
|
|
|
LableJson struct {
|
|
|
ConditionConfig []ConditionEntity `json:"conditionConfig"`
|
|
@@ -241,6 +135,23 @@ type (
|
|
|
MaxIdleConns int
|
|
|
MaxOpenConns int
|
|
|
}
|
|
|
+ MysqlConfig struct {
|
|
|
+ Host string `json:"host"`
|
|
|
+ Port int `json:"port"`
|
|
|
+ Database string `json:"database"`
|
|
|
+ User string `json:"user"`
|
|
|
+ Password string `json:"password"`
|
|
|
+ PollSize int `json:"poolsize"`
|
|
|
+ MaxIdle int `json:"maxidle"`
|
|
|
+ MaxLeftTime int `json:"maxleft"`
|
|
|
+ }
|
|
|
+ MongoConfig struct {
|
|
|
+ Address string `json:"address"`
|
|
|
+ DbName string `json:"dbName"`
|
|
|
+ DbSize int `json:"dbSize"`
|
|
|
+ User string `json:"user"`
|
|
|
+ Password string `json:"password"`
|
|
|
+ }
|
|
|
)
|
|
|
type GmailAuth struct {
|
|
|
SmtpHost string //邮箱服务器
|
|
@@ -339,3 +250,13 @@ func ConnectClickhouse(cHouseConfig *CHouseConfig) error {
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
+func MysqlTidbInit(data MysqlConfig) *mysql.Mysql {
|
|
|
+ return &mysql.Mysql{
|
|
|
+ Address: data.Host + ":" + fmt.Sprint(data.Port),
|
|
|
+ UserName: data.User,
|
|
|
+ PassWord: data.Password,
|
|
|
+ DBName: data.Database,
|
|
|
+ MaxOpenConns: data.PollSize,
|
|
|
+ MaxIdleConns: data.MaxIdle,
|
|
|
+ }
|
|
|
+}
|