Browse Source

添加jit模块的路由

pull/33/head
zhangxin 3 years ago
parent
commit
ce4e92cab0
2 changed files with 28 additions and 0 deletions
  1. +27
    -0
      db/mongo.go
  2. +1
    -0
      web/routes/routes.go

+ 27
- 0
db/mongo.go View File

@ -0,0 +1,27 @@
package db
import (
"LAPP_ACURA_MOM_BACKEND/conf"
"context"
"fmt"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"time"
)
var AppMongo *mongo.Client
func InitMongo() error {
//1.建立链接
ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
dsn := fmt.Sprintf("mongodb://%s:%d", conf.DbConfig.Mongdbip, conf.DbConfig.Mongdbport)
client, err := mongo.Connect(ctx, options.Client().ApplyURI(dsn))
if err != nil {
return err
}
if err = client.Ping(ctx, nil); err != nil {
return err
}
AppMongo = client
return err
}

+ 1
- 0
web/routes/routes.go View File

@ -10,6 +10,7 @@ import (
_ "LAPP_ACURA_MOM_BACKEND/web/controllers/base"
_ "LAPP_ACURA_MOM_BACKEND/web/controllers/common"
homereg "LAPP_ACURA_MOM_BACKEND/web/controllers/home"
_ "LAPP_ACURA_MOM_BACKEND/web/controllers/jit"
_ "LAPP_ACURA_MOM_BACKEND/web/controllers/me"
_ "LAPP_ACURA_MOM_BACKEND/web/controllers/om"
_ "LAPP_ACURA_MOM_BACKEND/web/controllers/pln"


Loading…
Cancel
Save