12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package utility
- import (
- m "app.yhyue.com/moapp/jybase/mongodb"
- "context"
- "fmt"
- "github.com/gogf/gf/v2/frame/g"
- "github.com/gogf/gf/v2/os/gctx"
- "jybxseo/internal/consts"
- )
- type (
- mgoConf struct {
- Address string
- Size int
- DbName string
- ReplSet string
- UserName string
- Password string
- Collection string
- Collection_back string
- }
- )
- var (
- mongdbConf mgoConf
- Mgo m.MongodbSim
- )
- func init() {
- initCtx := gctx.New()
- fmt.Println(consts.CityType)
- if err := g.Cfg().MustGet(initCtx, "mongodb").Struct(&mongdbConf); err != nil {
- panic(err)
- }
- Mgo = m.MongodbSim{
- MongodbAddr: mongdbConf.Address,
- Size: mongdbConf.Size,
- DbName: mongdbConf.DbName,
- UserName: mongdbConf.UserName,
- Password: mongdbConf.Password,
- ReplSet: mongdbConf.ReplSet,
- }
- Mgo.InitPool()
- if err := g.Cfg().MustGet(context.Background(), "entMongodb").Struct(&mongdbConf); err != nil {
- panic(err)
- }
- }
|