Ver Fonte

Merge branch 'dev/v1.2.6_zxl' of moapp/message into feature/v1.2.6

zhangxinlei1996 há 1 ano atrás
pai
commit
71d6716f85
3 ficheiros alterados com 30 adições e 7 exclusões
  1. 21 4
      db/db.go
  2. 8 2
      etc/config.yaml
  3. 1 1
      handler/activity/task.go

+ 21 - 4
db/db.go

@@ -12,10 +12,11 @@ import (
 )
 
 var (
-	Mgo_Log *mongodb.MongodbSim
-	Mgo     *mongodb.MongodbSim
-	Mysql   *mysql.Mysql
-	Tidb    *mysql.Mysql
+	Mgo_Log   *mongodb.MongodbSim
+	Mgo       *mongodb.MongodbSim
+	Mysql     *mysql.Mysql
+	Tidb      *mysql.Mysql
+	TidbPoint *mysql.Mysql
 )
 
 type MgoConf struct {
@@ -100,4 +101,20 @@ func init() {
 		}
 	}
 
+	var tidbPointConf MysqlConf
+	if err := gcfg.Instance().MustGet(gctx.New(), "databases.tidbPoint").Scan(&tidbPointConf); err == nil {
+		if tidbPointConf.Address != "" {
+			log.Println("--初始化 tidb--")
+			TidbPoint = &mysql.Mysql{
+				Address:      tidbPointConf.Address,
+				UserName:     tidbPointConf.UserName,
+				PassWord:     tidbPointConf.PassWord,
+				DBName:       tidbPointConf.DbName,
+				MaxOpenConns: tidbPointConf.MaxOpenConns,
+				MaxIdleConns: tidbPointConf.MaxIdleConns,
+			}
+			TidbPoint.Init()
+		}
+	}
+
 }

+ 8 - 2
etc/config.yaml

@@ -56,10 +56,16 @@ databases:
     passWord: "=PDT49#80Z!RVv52_z"
     maxOpenConns: 5
     maxIdleConns: 5
+  tidbPoint:
+    dbName: base_service
+    address: 192.168.3.217:4000
+    userName: root
+    passWord: "=PDT49#80Z!RVv52_z"
+    maxOpenConns: 5
+    maxIdleConns: 5
 
 rpc:
-  payrpc: 192.168.3.128:8600
-  pointrpc: 192.168.20.92:8205
+  payrpc: 192.168.3.149:8600
 
 #其他配置
 newUserAward: #新用户注册奖励

+ 1 - 1
handler/activity/task.go

@@ -97,7 +97,7 @@ func Task(msg *model.Message) {
 		}
 	}
 	//判断是否赠送过积分,送过则不送
-	if db.Mysql.CountBySql(`select count(1) from jypoints.integral_flow where userId =? and pointType =? and sort =1;`, msg.E_userId, code) > 0 {
+	if db.TidbPoint.CountBySql(`select count(1) from jypoints.integral_flow where userId =? and pointType =? and sort =1;`, msg.E_userId, code) > 0 {
 		logger.Info(fmt.Sprintf("用户%s已经增加过积分%v,不再增加积分。", msg.E_userId, code))
 		return
 	}