renzheng 9 years ago
parent
commit
81ced1dd0f

+ 36 - 2
common/src/qfw/util/common.go

@@ -6,8 +6,6 @@ import (
 	"encoding/hex"
 	"encoding/json"
 	"fmt"
-	"github.com/dchest/captcha"
-	"gopkg.in/mgo.v2/bson"
 	"io"
 	"log"
 	mathRand "math/rand"
@@ -16,6 +14,9 @@ import (
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/dchest/captcha"
+	"gopkg.in/mgo.v2/bson"
 )
 
 const (
@@ -203,6 +204,39 @@ func Int64All(num interface{}) int64 {
 	}
 }
 
+func Float64All(num interface{}) float64 {
+	if i, ok := num.(float64); ok {
+		return float64(i)
+	} else if i0, ok0 := num.(int32); ok0 {
+		return float64(i0)
+	} else if i1, ok1 := num.(int64); ok1 {
+		return float64(i1)
+	} else if i2, ok2 := num.(int); ok2 {
+		return float64(i2)
+	} else if i3, ok3 := num.(float32); ok3 {
+		return float64(i3)
+	} else if i4, ok4 := num.(string); ok4 {
+		in, _ := strconv.Atoi(i4)
+		return float64(in)
+	} else if i5, ok5 := num.(int16); ok5 {
+		return float64(i5)
+	} else if i6, ok6 := num.(int8); ok6 {
+		return float64(i6)
+	} else if i6, ok6 := num.(uint); ok6 {
+		return float64(i6)
+	} else if i6, ok6 := num.(uint8); ok6 {
+		return float64(i6)
+	} else if i6, ok6 := num.(uint16); ok6 {
+		return float64(i6)
+	} else if i6, ok6 := num.(uint32); ok6 {
+		return float64(i6)
+	} else if i6, ok6 := num.(uint64); ok6 {
+		return float64(i6)
+	} else {
+		return 0
+	}
+}
+
 func IntAllDef(num interface{}, defaultNum int) int {
 	if i, ok := num.(int); ok {
 		return int(i)

+ 11 - 2
common/src/qfw/util/elastic/elasticutil_Index_test.go

@@ -1,11 +1,12 @@
 package elastic
 
 import (
-	_ "gopkg.in/mgo.v2/bson"
-	_ "gopkg.in/olivere/elastic.v1"
 	"log"
 	_ "log"
 
+	_ "gopkg.in/mgo.v2/bson"
+	_ "gopkg.in/olivere/elastic.v1"
+
 	"qfw/util/mongodb"
 	"testing"
 )
@@ -72,3 +73,11 @@ func Test_Convert(t *testing.T) {
 	//InitElastic("http://192.168.3.14:9800")
 	log.Println(ConverData(mongodb.FindOne("enterprise", `{"_id":"556db9f0c2e8753072b52ee9"}`)))
 }
+
+func Test_saveToEs(t *testing.T) {
+	InitElasticSize("http://192.168.3.18:9800", 2)
+	Save("bidlibrary", "bidlibrary", map[string]interface{}{
+		"_id":   "556db9f0c2e8753072b52ee5",
+		"title": "你好,试试2",
+	})
+}

+ 1 - 1
common/src/qfw/util/mongodb/mongodbSim.go

@@ -191,7 +191,7 @@ func (m *MongodbSim) Find(c string, query interface{}, order interface{}, fields
 		coll := sess.DB(m.DbName).C(c)
 		var err error
 		if single {
-			err = coll.Find(ObjToM(query)).Select(ObjToOth(fields)).One(&res[0])
+			err = coll.Find(ObjToM(query)).Select(ObjToOth(fields)).Sort(ObjToArr(order)...).One(&res[0])
 		} else if start > -1 {
 			err = coll.Find(ObjToM(query)).Select(ObjToOth(fields)).Sort(ObjToArr(order)...).Skip(start).Limit(limit).All(&res)
 		} else {

+ 63 - 1
push/src/config.json

@@ -1 +1,63 @@
-{"bid":{"interval":60,"lastpushtime":"2015-10-10 10:10:10"},"bidStartTime":"2015-12-30 17:28:48","bidTitle":"亲!剑鱼为您速报最新鲜的中标信息啦","bidViewDomain":"192.168.3.132","durationMinutes":10,"fixPush":"oJULtwzXo6EFV1Ah-XeyRBimXGM8","mail_bid":"\u003cdiv\u003e%s\u003c/div\u003e,想了解更多信息,请访问http://www.qimingxing.info。","maxPushSize":50,"mgoAddr":"192.168.3.18:27080","mgoSize":10,"province":{"上海":9,"云南":25,"内蒙古":5,"北京":1,"台湾":32,"吉林":7,"四川":13,"天津":2,"宁夏":30,"安徽":12,"山东":15,"山西":4,"广东":19,"广西":20,"新疆":31,"江苏":10,"江西":14,"河北":3,"河南":16,"浙江":11,"海南":21,"湖北":17,"湖南":18,"澳门":34,"甘肃":28,"福建":13,"西藏":26,"贵州":24,"辽宁":6,"重庆":22,"陕西":27,"青海":29,"香港":33,"黑龙江":8},"pushInfoScopeDays":50,"rpcPort":"8766","smtpAddr":"smtp.exmail.qq.com","smtpFromUser":"企明星","smtpPort":465,"smtpPwd":"qy123456","smtpUser":"qyfw@topnet.net.cn","tenderStartTime":"2015-12-30 17:28:48","tenderTitle":"亲!剑鱼为您速报最新鲜的招标信息啦","weixinRpcServer":"127.0.0.1:82","weixin_bid":"\u003cdiv\u003e%s最新招标信息\u003c/div\u003e\u003cdiv\u003e%s\u003c/div\u003e","wxRpcRemark":"请到网站个人中心查看详细."}
+{
+    "bid": {
+        "interval": 60,
+        "lastpushtime": "2015-10-10 10:10:10"
+    },
+    "bidStartTime": "2015-12-30 17:28:48",
+    "bidTitle": "亲!剑鱼为您速报最新鲜的中标信息啦",
+    "bidViewDomain": "192.168.3.132",
+    "durationMinutes": 10,
+    "fixPush": "oJULtwzXo6EFV1Ah-XeyRBimXGM8",
+    "mail_bid": "\u003cdiv\u003e%s\u003c/div\u003e,想了解更多信息,请访问http://www.qimingxing.info。",
+    "maxPushSize": 50,
+    "mgoAddr": "192.168.3.18:27080",
+    "mgoSize": 10,
+    "province": {
+        "上海": 9,
+        "云南": 25,
+        "内蒙古": 5,
+        "北京": 1,
+        "台湾": 32,
+        "吉林": 7,
+        "四川": 13,
+        "天津": 2,
+        "宁夏": 30,
+        "安徽": 12,
+        "山东": 15,
+        "山西": 4,
+        "广东": 19,
+        "广西": 20,
+        "新疆": 31,
+        "江苏": 10,
+        "江西": 14,
+        "河北": 3,
+        "河南": 16,
+        "浙江": 11,
+        "海南": 21,
+        "湖北": 17,
+        "湖南": 18,
+        "澳门": 34,
+        "甘肃": 28,
+        "福建": 13,
+        "西藏": 26,
+        "贵州": 24,
+        "辽宁": 6,
+        "重庆": 22,
+        "陕西": 27,
+        "青海": 29,
+        "香港": 33,
+        "黑龙江": 8
+    },
+    "pushInfoScopeDays": 50,
+    "rpcPort": "8766",
+    "smtpAddr": "smtp.exmail.qq.com",
+    "smtpFromUser": "企明星",
+    "smtpPort": 465,
+    "smtpPwd": "qy123456",
+    "smtpUser": "qyfw@topnet.net.cn",
+    "tenderStartTime": "2015-12-30 17:28:48",
+    "tenderTitle": "亲!剑鱼为您速报最新鲜的招标信息啦",
+    "weixinRpcServer": "127.0.0.1:82",
+    "weixin_bid": "\u003cdiv\u003e%s最新招标信息\u003c/div\u003e\u003cdiv\u003e%s\u003c/div\u003e",
+    "wxRpcRemark": "请到网站个人中心查看详细."
+}