Bladeren bron

Merge branch 'develop' of 192.168.3.17:zhanghongbo/qfw into develop

wangshan 8 jaren geleden
bovenliggende
commit
a8870defba

+ 14 - 0
common/src/github.com/PuerkitoBio/goquery/property.go

@@ -99,6 +99,20 @@ func (s *Selection) Html() (ret string, e error) {
 	return
 }
 
+func (s *Selection) OuterHtml() (ret string, e error) {
+	// Since there is no .innerHtml, the HTML content must be re-created from
+	// the nodes using html.Render.
+	var buf bytes.Buffer
+	if len(s.Nodes) > 0 {
+		e = html.Render(&buf, s.Nodes[0])
+		if e != nil {
+			return
+		}
+		ret = buf.String()
+	}
+	return
+}
+
 // AddClass adds the given class(es) to each element in the set of matched elements.
 // Multiple class names can be specified, separated by a space or via multiple arguments.
 func (s *Selection) AddClass(class ...string) *Selection {

+ 5 - 1
common/src/qfw/util/elastic/elasticutil.go

@@ -918,7 +918,9 @@ const (
 func GetNgramQuery(query interface{}, mustquery, findfields string) (qstr string) {
 	var words []string
 	if q, ok := query.(string); ok {
-		words = strings.Split(q, ",")
+		if q != "" {
+			words = strings.Split(q, ",")
+		}
 	} else if q, ok := query.([]string); ok {
 		words = q
 	} else if q, ok := query.([]interface{}); ok {
@@ -937,6 +939,8 @@ func GetNgramQuery(query interface{}, mustquery, findfields string) (qstr string
 		}
 		qstr = fmt.Sprintf(NgramStr, mustquery, strings.Join(musts, ","))
 		//log.Println("ngram-query", qstr)
+	} else {
+		qstr = fmt.Sprintf(NgramStr, mustquery, "")
 	}
 	return
 }

File diff suppressed because it is too large
+ 1 - 0
common/src/qfw/util/encrypt_test.go


+ 25 - 0
common/src/qfw/util/mongodb/mongodbSim.go

@@ -149,6 +149,31 @@ func (m *MongodbSim) UpdateBulk(c string, doc ...[]map[string]interface{}) bool
 	return b
 }
 
+//批量更新
+func (m *MongodbSim) UpSertBulk(c string, doc ...[]map[string]interface{}) bool {
+	defer util.Catch()
+	sess := m.GetMgoConn()
+	b := true
+	if sess != nil {
+		defer m.DestoryMongoConn(sess)
+		coll := sess.DB(m.DbName).C(c)
+		bulk := coll.Bulk()
+		for _, v := range doc {
+			if len(v) == 2 {
+				bulk.Upsert(v[0], v[1])
+			}
+		}
+		_, err := bulk.Run()
+		if nil != err {
+			log.Println("BulkUpsertError", err)
+			b = false
+		}
+	} else {
+		b = false
+	}
+	return b
+}
+
 //批量插入
 func (m *MongodbSim) SaveBulk(c string, doc ...map[string]interface{}) bool {
 	defer util.Catch()

Some files were not shown because too many files changed in this diff