Selaa lähdekoodia

Merge branch 'master' of https://app.yhyue.com/moapp/jypkg into master

zhangxinlei1996 2 vuotta sitten
vanhempi
commit
0d6d33fa63

+ 57 - 54
common/src/qfw/util/dataexport/common.go

@@ -1,10 +1,10 @@
 package dataexport
 
 import (
-	"fmt"
-	"log"
 	qutil "app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/mysql"
+	"fmt"
+	"log"
 	"strings"
 )
 
@@ -58,69 +58,72 @@ func GetDataExportMatchKey(scd *SieveCondition, list *[]map[string]interface{})
 		} else {
 			log.Println("历史推送数据订阅词匹配失败++++", len(scd.SelectIds), len(scd.PushKeyWords), scd.Id)
 		}
-	} else if len(scd.Keyword) > 0 && scd.Keyword[0].Keyword != "" { //关键词二次匹配
+	} else if len(scd.Keyword) > 0 { //关键词二次匹配
 		types := scd.SelectType
 		var keys []string
 		//统计关键词
 		for _, vk := range scd.Keyword {
 			key := []string{}
-			if strings.Contains(vk.Keyword, " ") {
-				for _, v := range strings.Split(vk.Keyword, " ") {
-					if v != "" {
-						key = append(key, v)
-					}
+			for _, v := range strings.Split(vk.Keyword, " ") {
+				if v != "" {
+					key = append(key, v)
+				}
+			}
+			if len(vk.Appended) > 0 {
+				for _, v := range vk.Appended {
+					key = append(key, strings.Split(v, " ")...)
 				}
-			} else {
-				key = append(key, vk.Keyword)
 			}
 			vk.Keyword = strings.Join(key, ",")
-			keys = append(keys, strings.Replace(vk.Keyword, "+", ",", -1))
+			keys = append(keys, strings.ReplaceAll(vk.Keyword, "+", ","))
 		}
 		key := strings.Join(keys, ",")
-		//二次匹配
-		for _, data := range *list {
-			keyWord := []string{}
-			if strings.Contains(types, "title") {
-				title := qutil.ObjToString(data["title"])
-				keyWord = KeyWordToDatas(title, key, keyWord)
-			}
-			if strings.Contains(types, "detail") {
-				detail := qutil.ObjToString(data["detail"])
-				keyWord = KeyWordToDatas(detail, key, keyWord)
-			}
-			if strings.Contains(types, "purchasing") {
-				purchasing := qutil.ObjToString(data["purchasing"])
-				keyWord = KeyWordToDatas(purchasing, key, keyWord)
-			}
-			if strings.Contains(types, "filetext") {
-				filetext := qutil.ObjToString(data["filetext"])
-				keyWord = KeyWordToDatas(filetext, key, keyWord)
-			}
-			if strings.Contains(types, "projectname.pname") {
-				projectname := qutil.ObjToString(data["projectname"])
-				keyWord = KeyWordToDatas(projectname, key, keyWord)
-			}
-			if strings.Contains(types, "mbuyer") {
-				buyer := qutil.ObjToString(data["buyer"])
-				keyWord = KeyWordToDatas(buyer, key, keyWord)
-			}
-			if strings.Contains(types, "mwinner") {
-				winner := qutil.ObjToString(data["s_winner"])
-				keyWord = KeyWordToDatas(winner, key, keyWord)
-			}
-			if strings.Contains(types, "magency") {
-				winner := qutil.ObjToString(data["agency"])
-				keyWord = KeyWordToDatas(winner, key, keyWord)
-			}
-			keyMap := map[string]bool{}
-			keyArr := []string{}
-			for _, key1 := range keyWord {
-				keyMap[key1] = true
-			}
-			for k, _ := range keyMap {
-				keyArr = append(keyArr, k)
+		if key != "" {
+			//二次匹配
+			for _, data := range *list {
+				keyWord := []string{}
+				if strings.Contains(types, "title") {
+					title := qutil.ObjToString(data["title"])
+					keyWord = KeyWordToDatas(title, key, keyWord)
+				}
+				if strings.Contains(types, "detail") {
+					detail := qutil.ObjToString(data["detail"])
+					keyWord = KeyWordToDatas(detail, key, keyWord)
+				}
+				if strings.Contains(types, "purchasing") {
+					purchasing := qutil.ObjToString(data["purchasing"])
+					keyWord = KeyWordToDatas(purchasing, key, keyWord)
+				}
+				if strings.Contains(types, "filetext") {
+					filetext := qutil.ObjToString(data["filetext"])
+					keyWord = KeyWordToDatas(filetext, key, keyWord)
+				}
+				if strings.Contains(types, "projectname.pname") {
+					projectname := qutil.ObjToString(data["projectname"])
+					keyWord = KeyWordToDatas(projectname, key, keyWord)
+				}
+				if strings.Contains(types, "mbuyer") {
+					buyer := qutil.ObjToString(data["buyer"])
+					keyWord = KeyWordToDatas(buyer, key, keyWord)
+				}
+				if strings.Contains(types, "mwinner") {
+					winner := qutil.ObjToString(data["s_winner"])
+					keyWord = KeyWordToDatas(winner, key, keyWord)
+				}
+				if strings.Contains(types, "magency") {
+					winner := qutil.ObjToString(data["agency"])
+					keyWord = KeyWordToDatas(winner, key, keyWord)
+				}
+				keyMap := map[string]bool{}
+				keyArr := []string{}
+				for _, key1 := range keyWord {
+					keyMap[key1] = true
+				}
+				for k, _ := range keyMap {
+					keyArr = append(keyArr, k)
+				}
+				data["keyword"] = strings.Join(keyArr, ",")
 			}
-			data["keyword"] = strings.Join(keyArr, ",")
 		}
 	}
 }

+ 84 - 34
common/src/qfw/util/dataexport/dataexport.go

@@ -647,11 +647,6 @@ func GetDataExportSelectReallyCount(bid mg.MongodbSim, biddingName string, ids [
 func GetDataExportSelectResult(bidding mg.MongodbSim, biddingName string, scd *SieveCondition, dataType string, checkCount int) (*[]map[string]interface{}, error) {
 	sess := bidding.GetMgoConn()
 	defer bidding.DestoryMongoConn(sess)
-	var queryIds []interface{}
-	for _, idStr := range scd.SelectIds {
-		queryIds = append(queryIds, mg.StringTOBsonId(idStr))
-	}
-
 	selectMap := map[string]interface{}{
 		"_id": 1, "title": 1, "detail": 1, "area": 1, "city": 1, "publishtime": 1, "projectname": 1, "buyer": 1, "s_winner": 1, "bidamount": 1, "subtype": 1, "toptype": 1, "filetext": 1, "purchasing": 1,
 	}
@@ -660,38 +655,93 @@ func GetDataExportSelectResult(bidding mg.MongodbSim, biddingName string, scd *S
 			selectMap[key] = 1
 		}
 	}
-	returnLsit := make([]map[string]interface{}, 0, len(queryIds))
-	iter := sess.DB(biddingName).C("bidding").Select(selectMap).Find(map[string]interface{}{"_id": map[string]interface{}{
-		"$in": queryIds,
-	}}).Iter()
-	for m := make(map[string]interface{}); iter.Next(&m); {
-		m["_id"] = mg.BsonIdToSId(m["_id"])
-		detail, _ := m["detail"].(string)
-		if detail != "" {
-			m["detail"] = contentfilterReg.ReplaceAllString(detail, "")
-		}
-		returnLsit = append(returnLsit, m)
-		m = make(map[string]interface{})
+	if checkCount == -1 && len(scd.SelectIds) > 500 {
+		scd.SelectIds = scd.SelectIds[:500]
+	}
+	pool := make(chan bool, 10)
+	wait := &sync.WaitGroup{}
+	var lock sync.Mutex
+	returnLsit := make([]map[string]interface{}, 0, len(scd.SelectIds))
+	for _, v := range SplitArray(scd.SelectIds, 200) {
+		pool <- true
+		wait.Add(1)
+		go func(arr []string) error {
+			defer func() {
+				wait.Done()
+				<-pool
+			}()
+			var queryIds []interface{}
+			for _, idStr := range arr {
+				queryIds = append(queryIds, mg.StringTOBsonId(idStr))
+			}
+			iter := sess.DB(biddingName).C("bidding").Select(selectMap).Find(map[string]interface{}{"_id": map[string]interface{}{
+				"$in": queryIds,
+			}}).Iter()
+			for m := make(map[string]interface{}); iter.Next(&m); {
+				m["_id"] = mg.BsonIdToSId(m["_id"])
+				detail, _ := m["detail"].(string)
+				if detail != "" {
+					m["detail"] = contentfilterReg.ReplaceAllString(detail, "")
+				}
+				lock.Lock()
+				returnLsit = append(returnLsit, m)
+				lock.Unlock()
+				m = make(map[string]interface{})
+			}
+			iter_back := sess.DB(biddingName).C("bidding_back").Select(selectMap).Find(map[string]interface{}{"_id": map[string]interface{}{
+				"$in": queryIds,
+			}}).Iter()
+			for m := make(map[string]interface{}); iter_back.Next(&m); {
+				m["_id"] = mg.BsonIdToSId(m["_id"])
+				detail, _ := m["detail"].(string)
+				if detail != "" {
+					m["detail"] = contentfilterReg.ReplaceAllString(detail, "")
+				}
+				lock.Lock()
+				returnLsit = append(returnLsit, m)
+				lock.Unlock()
+				m = make(map[string]interface{})
+			}
+			return nil
+		}(v)
+
 	}
-	if len(returnLsit) == checkCount {
+	wait.Wait()
+	if len(returnLsit) == checkCount || checkCount == -1 {
 		return &returnLsit, nil
+	} else {
+		return nil, fmt.Errorf("选择数据导出异常 数据量期望%d条,实际查询%d条", checkCount, len(returnLsit))
 	}
-	iter_back := sess.DB(biddingName).C("bidding_back").Select(selectMap).Find(map[string]interface{}{"_id": map[string]interface{}{
-		"$in": queryIds,
-	}}).Iter()
-	for m := make(map[string]interface{}); iter_back.Next(&m); {
-		m["_id"] = mg.BsonIdToSId(m["_id"])
-		detail, _ := m["detail"].(string)
-		if detail != "" {
-			m["detail"] = contentfilterReg.ReplaceAllString(detail, "")
+}
+
+// SplitArray 分割数组
+func SplitArray(arr []string, num int64) [][]string {
+	max := int64(len(arr))
+	//判断数组大小是否小于等于指定分割大小的值,是则把原数组放入二维数组返回
+	if max <= num {
+		return [][]string{arr}
+	}
+	//获取应该数组分割为多少份
+	var quantity int64
+	if max%num == 0 {
+		quantity = max / num
+	} else {
+		quantity = (max / num) + 1
+	}
+	//声明分割好的二维数组
+	var segments = make([][]string, 0)
+	//声明分割数组的截止下标
+	var start, end, i int64
+	for i = 1; i <= quantity; i++ {
+		end = i * num
+		if i != quantity {
+			segments = append(segments, arr[start:end])
+		} else {
+			segments = append(segments, arr[start:])
 		}
-		returnLsit = append(returnLsit, m)
-		m = make(map[string]interface{})
-	}
-	if len(returnLsit) == checkCount || checkCount == -1 {
-		return &returnLsit, nil
+		start = i * num
 	}
-	return nil, fmt.Errorf("选择数据导出异常 数据量期望%d条,实际查询%d条", checkCount, len(returnLsit))
+	return segments
 }
 
 func GetDataExportIds(elasticAddress string, scd *SieveCondition, checkCount int) ([]string, error) {
@@ -983,7 +1033,7 @@ func FormatExportData(entmg mg.MongodbSim, data *[]map[string]interface{}, webdo
 			date := v["bidopentime"]
 			v["bidopentime"] = FormatDateWithObj(&date, Date_Short_Layout)
 		}
-		if v["signendtime"] != nil {
+		if qutil.IntAll(v["signendtime"]) != 0 {
 			date := v["signendtime"]
 			v["signendtime"] = FormatDateWithObj(&date, Date_Short_Layout)
 		}
@@ -1053,7 +1103,7 @@ func doSearch(sql string, start, count int, dataType string) *[]map[string]inter
 		if dataType != "" {
 			dataexport_field := `"_id","title","detail","area","city","publishtime","projectname","buyer","s_winner","bidamount","subtype","toptype","filetext","purchasing"`
 			if dataType == "2" {
-				dataexport_field += `,"href","projectcode","buyerperson","buyertel","budget","bidopentime","agency","projectscope","winnerperson","winnertel","bidendtime", "district", "signendtime", "buyeraddr"`
+				dataexport_field += `,"href","projectcode","buyerperson","buyertel","budget","bidopentime","agency","projectscope","winnerperson","winnertel","bidendtime","district","signendtime","buyeraddr"`
 			}
 			sql = sql[:len(sql)-1] + `,"_source":[` + dataexport_field + "]}"
 		}

+ 7 - 3
common/src/qfw/util/dataexport/entdataexport.go

@@ -54,11 +54,11 @@ func GetEntDataExportCount(sim, bid mg.MongodbSim, bidMgoDBName, elasticAddress,
 		insertFlag = "true"
 	}
 	for _, v := range *res {
-		if v["signendtime"] != nil {
+		if util.IntAll(v["signendtime"]) != 0 {
 			date := v["signendtime"]
 			v["signendtime"] = FormatDateWithObj(&date, Date_Short_Layout)
 		}
-		if v["bidendtime"] != nil {
+		if util.IntAll(v["bidendtime"]) != 0 {
 			date := v["bidendtime"]
 			v["bidendtime"] = FormatDateWithObj(&date, Date_Short_Layout)
 		}
@@ -224,10 +224,14 @@ func FormatExportDatas(Mgo_Ent mongodb.MongodbSim, data *[]map[string]interface{
 				date := v["bidopentime"]
 				v["bidopentime"] = FormatDateWithObj(&date, Date_Short_Layout)
 			}
-			if v["signendtime"] != nil {
+			if util.IntAll(v["signendtime"]) != 0 {
 				date := v["signendtime"]
 				v["signendtime"] = FormatDateWithObj(&date, Date_Short_Layout)
 			}
+			if util.IntAll(v["bidendtime"]) != 0 {
+				date := v["bidendtime"]
+				v["bidendtime"] = FormatDateWithObj(&date, Date_Short_Layout)
+			}
 			if v["currency"] == "" || v["currency"] == nil {
 				v["currency"] = "人民币"
 			}

+ 12 - 4
common/src/qfw/util/jy/jy.go

@@ -15,16 +15,16 @@ import (
 	"time"
 	"unicode"
 
-	. "app.yhyue.com/moapp/jybase/date"
-
 	util "app.yhyue.com/moapp/jybase/common"
+	. "app.yhyue.com/moapp/jybase/date"
+	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
 	"app.yhyue.com/moapp/jybase/mail"
 	. "app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jybase/redis"
 	qrpc "app.yhyue.com/moapp/jybase/rpc"
 	"app.yhyue.com/moapp/jybase/sms"
-
-	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
+	. "app.yhyue.com/moapp/jypkg/middleground"
+	"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
 )
 
 //获取用户合并以前,合并以后的openid
@@ -480,3 +480,11 @@ func TimeProcessing(hour interface{}, duration int) time.Time {
 	t := todayZero.Add(mm)
 	return t
 }
+
+//清除用户权益缓存、菜单缓存
+func ClearUserCache(middleground *Middleground, positionId int64) {
+	middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
+		PositionId: fmt.Sprint(positionId),
+	})
+	middleground.PowerCheckCenter.DelCheckRedis("10000", positionId)
+}

+ 20 - 17
common/src/qfw/util/jy/userMerge.go

@@ -9,23 +9,25 @@ import (
 	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
 	. "app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jybase/mysql"
+	. "app.yhyue.com/moapp/jypkg/identity"
+	. "app.yhyue.com/moapp/jypkg/middleground"
 	"go.mongodb.org/mongo-driver/bson"
 )
 
 //dev3.7 账号合并
 type UserMerge struct {
-	mysqlDb       *mysql.Mysql
-	mg            MongodbSim
-	sess          *httpsession.Session
-	userCenterApi string //获取用户中台api
+	mysqlDb      *mysql.Mysql
+	mg           MongodbSim
+	sess         *httpsession.Session
+	middleground *Middleground
 }
 
-func CreateUserMerge(mg MongodbSim, msql *mysql.Mysql, sess *httpsession.Session, ucapi string) *UserMerge {
+func CreateUserMerge(mg MongodbSim, msql *mysql.Mysql, sess *httpsession.Session, middleground *Middleground) *UserMerge {
 	return &UserMerge{
-		mysqlDb:       msql,
-		mg:            mg,
-		sess:          sess,
-		userCenterApi: ucapi,
+		mysqlDb:      msql,
+		mg:           mg,
+		sess:         sess,
+		middleground: middleground,
 	}
 }
 
@@ -38,7 +40,7 @@ var (
 //pId 手机用户id
 //当wId和pId都为空时 即不需要合并
 func (this *UserMerge) MergeQuery() (wId, pId, bPhone string, err error) {
-	userId, _ := this.sess.Get("userId").(string)
+	userId, _ := this.sess.Get("mgoUserId").(string)
 	if userId == "" {
 		err = fmt.Errorf("未获取到用户身份")
 		return
@@ -92,19 +94,16 @@ func (this *UserMerge) MergeQuery() (wId, pId, bPhone string, err error) {
 }
 
 //更新session
-func (this *UserMerge) FlushSession(userData *map[string]interface{}, userId string) {
-	if userData == nil {
-		userData, _ = this.mg.FindById("user", userId, `{"_id":1,"i_shareknow":1,"s_m_openid":1,"s_nickname":1,"s_headimage":1,"s_headimageurl":1,"s_phone":1,"s_m_phone":1,"s_jpushid":1,"s_opushid":1,"s_appponetype":1,"s_appversion":1,"base_user_id":1}`)
+func (this *UserMerge) FlushSession(userId string) {
+	userData, _ := this.mg.FindById("user", userId, `{"_id":1,"i_shareknow":1,"s_m_openid":1,"s_nickname":1,"s_headimage":1,"s_headimageurl":1,"s_phone":1,"s_m_phone":1,"s_jpushid":1,"s_opushid":1,"s_appponetype":1,"s_appversion":1,"base_user_id":1}`)
+	if userData == nil || len(*userData) == 0 {
+		return
 	}
 	sessionVal := make(map[string]interface{})
 	sessionVal["user"] = *userData
 	if (*userData)["i_shareknow"] != nil {
 		sessionVal["shareknow"] = (*userData)["i_shareknow"]
 	}
-	if userId == "" {
-		userId = BsonIdToSId((*userData)["_id"])
-	}
-	ClearBigVipUserPower(userId) //大会员状态刷新
 	sessionVal["userId"] = userId
 	sessionVal["mgoUserId"] = userId
 	nickName, _ := (*userData)["s_nickname"].(string)
@@ -137,4 +136,8 @@ func (this *UserMerge) FlushSession(userData *map[string]interface{}, userId str
 	sessionVal["app_name"] = nickName
 	sessionVal["base_user_id"] = qutil.IntAll((*userData)["base_user_id"])
 	this.sess.SetMultiple(sessionVal)
+	positionId, _ := SwitchToBest(qutil.Int64All(sessionVal["base_user_id"]), this.sess, this.middleground, &this.mg, true)
+	if positionId > 0 {
+		ClearUserCache(this.middleground, positionId)
+	}
 }

+ 3 - 3
ent/entity/customer.go

@@ -271,7 +271,7 @@ func (this *Customer) GetDeptCustomerList(dept_id, ent_id int, name, alloc, staf
 	customerList = &[]map[string]interface{}{}
 	searchSql := ` 1=1 `
 	searchValues := []interface{}{}
-	searchValues = append(searchValues, dept_id, dept_id, ent_id)
+	searchValues = append(searchValues, dept_id, dept_id, ent_id, ent_id)
 	if name != "" { //名字模糊查询
 		searchSql += ` and b.name like ? `
 		searchValues = append(searchValues, "%"+name+"%")
@@ -362,7 +362,7 @@ func (this *Customer) GetDeptCustomerList(dept_id, ent_id int, name, alloc, staf
 						) b ON ( a.user_id = b.id ) 
 				 limit 100000) as a
 					LEFT JOIN entniche_customer b ON ( a.customer_id = b.id ) 
-				AND b.ent_id = 14640 
+				AND b.ent_id = ? 
 				AND b.state = 1
 				LEFT JOIN entniche_user c ON ( a.user_id = c.id ) WHERE ` + searchSql + ` 
 							GROUP BY  a.customer_id  ` + allocSql + ` order by updatetime desc,	b.createtime desc `
@@ -397,7 +397,7 @@ func (this *Customer) GetDeptCustomerList(dept_id, ent_id int, name, alloc, staf
 						) b ON ( a.user_id = b.id ) limit 100000
 				   ) as a
 					LEFT JOIN entniche_customer b ON ( a.customer_id = b.id ) 
-				AND b.ent_id = 14640 
+				AND b.ent_id = ? 
 				AND b.state = 1
 				LEFT JOIN entniche_user c ON ( a.user_id = c.id )  WHERE ` + searchSql + `
 							GROUP BY  a.customer_id  ` + allocSql + ` order by updatetime desc,	b.createtime desc `

+ 15 - 1
ent/entity/user.go

@@ -188,6 +188,11 @@ func (u *User) Add(tx *sql.Tx, entId int, user *User, paymentAddress, source, ns
 func (u *User) Update(mail string, userId, deptId, entId int) bool {
 	return Mysql.ExecTx("修改员工", func(tx *sql.Tx) bool {
 		ok_1 := Mysql.UpdateOrDeleteBySqlByTx(tx, `update entniche_user set mail=?,timestamp=? where id=? and ent_id=?`, mail, NowFormat(Date_Full_Layout), userId, entId)
+		Mgo_Bidding.Update("ent_user", map[string]interface{}{"i_entid": entId, "i_userid": userId}, map[string]interface{}{
+			"$set": map[string]interface{}{
+				"o_pushset.s_email": mail,
+			},
+		}, true, false)
 		ok_2 := VarUser.Move(tx, entId, deptId, fmt.Sprint(userId))
 		return ok_1 == 1 && ok_2
 	})
@@ -274,8 +279,12 @@ func (u *User) PhoneExist(phone string, entId int) *[]map[string]interface{} {
 func (u *User) UpdateInfo(mail string, phone string, name string, userId, deptId, entId int, entPhone string, entName string, isAdmin bool) bool {
 	if isAdmin {
 		ok := Mysql.ExecTx("修改员工", func(tx *sql.Tx) bool {
-
 			ok_1 := Mysql.UpdateOrDeleteBySqlByTx(tx, `update entniche_user set mail=?,phone=?,name=?,timestamp=? where id=? and ent_id=?`, mail, phone, name, NowFormat(Date_Full_Layout), userId, entId)
+			MQFW.Update("ent_user", map[string]interface{}{"i_entid": entId, "i_userid": userId}, map[string]interface{}{
+				"$set": map[string]interface{}{
+					"o_pushset.s_email": mail,
+				},
+			}, true, false)
 			ok_2 := Mysql.UpdateOrDeleteBySqlByTx(tx, "update entniche_info set admin=?,phone=? where id=?", name, phone, entId)
 			ok_3 := VarUser.Move(tx, entId, deptId, fmt.Sprint(userId))
 			return ok_1 != -1 && ok_3 && ok_2 != -1
@@ -293,6 +302,11 @@ func (u *User) UpdateInfo(mail string, phone string, name string, userId, deptId
 	} else {
 		return Mysql.ExecTx("修改员工", func(tx *sql.Tx) bool {
 			ok_1 := Mysql.UpdateOrDeleteBySqlByTx(tx, `update entniche_user set mail=?,phone=?,name=?,timestamp=? where id=? and ent_id=?`, mail, phone, name, NowFormat(Date_Full_Layout), userId, entId)
+			MQFW.Update("ent_user", map[string]interface{}{"i_entid": entId, "i_userid": userId}, map[string]interface{}{
+				"$set": map[string]interface{}{
+					"o_pushset.s_email": mail,
+				},
+			}, true, false)
 			ok_2 := VarUser.Move(tx, entId, deptId, fmt.Sprint(userId))
 			return ok_1 == 1 && ok_2
 		})

+ 3 - 0
go.mod

@@ -48,8 +48,10 @@ require (
 	github.com/howeyc/fsnotify v0.9.0 // indirect
 	github.com/jinzhu/inflection v1.0.0 // indirect
 	github.com/jinzhu/now v1.1.1 // indirect
+	github.com/josharian/intern v1.0.0 // indirect
 	github.com/json-iterator/go v1.1.12 // indirect
 	github.com/klauspost/compress v1.13.6 // indirect
+	github.com/mailru/easyjson v0.7.7 // indirect
 	github.com/mattn/go-colorable v0.1.9 // indirect
 	github.com/mattn/go-isatty v0.0.14 // indirect
 	github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
@@ -57,6 +59,7 @@ require (
 	github.com/modern-go/reflect2 v1.0.2 // indirect
 	github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
 	github.com/olivere/elastic v6.2.37+incompatible // indirect
+	github.com/olivere/elastic/v7 v7.0.22 // indirect
 	github.com/openzipkin/zipkin-go v0.4.0 // indirect
 	github.com/pelletier/go-toml/v2 v2.0.6 // indirect
 	github.com/pkg/errors v0.9.1 // indirect

+ 2 - 0
go.sum

@@ -514,6 +514,7 @@ github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=
 github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw=
 github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
 github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
+github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
 github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
 github.com/frankban/quicktest v1.7.2/go.mod h1:jaStnuzAqU1AJdCO0l53JDCJrVDKcS03DbaAcR7Ks/o=
 github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
@@ -935,6 +936,7 @@ github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FW
 github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
 github.com/olivere/elastic v6.2.37+incompatible h1:UfSGJem5czY+x/LqxgeCBgjDn6St+z8OnsCuxwD3L0U=
 github.com/olivere/elastic v6.2.37+incompatible/go.mod h1:J+q1zQJTgAz9woqsbVRqGeB5G1iqDKVBWLNSYW8yfJ8=
+github.com/olivere/elastic/v7 v7.0.22 h1:esBA6JJwvYgfms0EVlH7Z+9J4oQ/WUADF2y/nCNDw7s=
 github.com/olivere/elastic/v7 v7.0.22/go.mod h1:VDexNy9NjmtAkrjNoI7tImv7FR4tf5zUA3ickqu5Pc8=
 github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=

+ 16 - 4
public/db.go

@@ -1,13 +1,13 @@
 package public
 
 import (
-	"log"
-
 	util "app.yhyue.com/moapp/jybase/common"
 	elastic "app.yhyue.com/moapp/jybase/esv1"
+	es "app.yhyue.com/moapp/jybase/esv7"
 	m "app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jybase/mysql"
 	"app.yhyue.com/moapp/jybase/redis"
+	"log"
 )
 
 var (
@@ -21,6 +21,8 @@ var (
 	Mgo_Log     m.MongodbSim
 	Mgo_Bidding m.MongodbSim
 	//Mgo_Qyfw    m.MongodbSim
+
+	EsDoc *elastic.Elastic
 )
 
 type dbConf struct {
@@ -34,6 +36,7 @@ type dbConf struct {
 	}
 	Elasticsearch struct {
 		Main *esConf
+		Doc  *esConf
 	}
 	Redis struct {
 		Main  *redisConf
@@ -57,8 +60,10 @@ type mgoConf struct {
 }
 
 type esConf struct {
-	Address string
-	Size    int
+	Address  string
+	Size     int
+	UserName string
+	Password string
 }
 type redisConf struct {
 	Address string
@@ -79,6 +84,13 @@ func init() {
 			elastic.InitElasticSize(DbConf.Elasticsearch.Main.Address, DbConf.Elasticsearch.Main.Size)
 			log.Println("初始化 elasticsearch")
 		}
+
+		if DbConf.Elasticsearch.Doc != nil {
+			es.InitElasticSizeByAuth(DbConf.Elasticsearch.Doc.Address, DbConf.Elasticsearch.Doc.Size,
+				DbConf.Elasticsearch.Doc.UserName, DbConf.Elasticsearch.Doc.Password)
+			log.Println("初始化 doc elasticsearch")
+		}
+
 		//初始化redis
 		if DbConf.Redis.Main != nil {
 			log.Println("初始化 redis")