wangchuanjin 5 years ago
parent
commit
3d36171658
34 changed files with 330 additions and 719 deletions
  1. 0 37
      src/config.json
  2. 53 0
      src/db.json
  3. 1 3
      src/jfw/filter/logfilter.go
  4. 2 4
      src/jfw/front/websocket.go
  5. 3 5
      src/jfw/modules/app/src/app/filter/logfilter.go
  6. 11 53
      src/jfw/modules/app/src/app/followent/followent.go
  7. 3 37
      src/jfw/modules/app/src/app/followent/myfwent.go
  8. 0 39
      src/jfw/modules/app/src/config.json
  9. 50 0
      src/jfw/modules/app/src/db.json
  10. 15 1
      src/jfw/modules/app/src/jfw/config/config.go
  11. 0 4
      src/jfw/modules/app/src/main.go
  12. 0 19
      src/jfw/modules/app/src/mongodb.json
  13. 2 2
      src/jfw/modules/app/src/seo.json
  14. BIN
      src/jfw/modules/app/src/web.zip
  15. 3 7
      src/jfw/modules/app/src/web/templates/followent/set.html
  16. 1 2
      src/jfw/modules/app/src/web/templates/weixin/wxinfocontent.html
  17. 0 12
      src/jfw/modules/entsesearch/src/config.json
  18. 20 0
      src/jfw/modules/entsesearch/src/db.json
  19. 0 9
      src/jfw/modules/entsesearch/src/main.go
  20. 1 85
      src/jfw/modules/entsesearch/src/search/entsesearch.go
  21. 0 18
      src/jfw/modules/entsesearch/src/tools/mongo.go
  22. 0 91
      src/jfw/modules/entsesearch/src/tools/rpccall.go
  23. 0 41
      src/jfw/modules/entsesearch/src/wx/wxjssdk.go
  24. 0 6
      src/jfw/modules/followent/src/config.json
  25. 20 0
      src/jfw/modules/followent/src/db.json
  26. 15 57
      src/jfw/modules/followent/src/followent/followent.go
  27. 3 40
      src/jfw/modules/followent/src/followent/myfwent.go
  28. 0 5
      src/jfw/modules/followent/src/main.go
  29. 26 48
      src/jfw/modules/followent/src/web/templates/weixin/set.html
  30. 98 66
      src/jfw/public/db.go
  31. 0 3
      src/main.go
  32. 0 19
      src/mongodb.json
  33. 1 2
      src/web/templates/weixin/wxinfocontent.html
  34. 2 4
      src/web/templates/weixin/wxinfocontent_rec.html

+ 0 - 37
src/config.json

@@ -1,33 +1,12 @@
 {
     "nodeName":"node1",
-    "influxaddr": "http://192.168.3.11:8086",
-    "influxdb": "jy_logs",
     "qrModelID": "2",
     "numTimeNumber": 15,
     "strTimeNumber": 30,
-    "elasticsearch": "http://192.168.3.128:9800,http://192.168.3.11:9800",
-    "elasticPoolSize": 30,
-    "redisaddrs": "other=192.168.3.128:1712,push=192.168.3.128:1712,pushcache_1=192.168.3.128:5000,pushcache_2_a=192.168.3.128:5001,pushcache_2_b=192.168.3.128:5002,sso=192.168.3.128:1712,session=192.168.3.128:1712,recovery=192.168.3.128:1712",
-    "redislogin": "login=192.168.3.128:1712",
     "webport": "83",
     "webrpcport": "8084",
     "weixinrpc": "127.0.0.1:8083",
     "cacheflag": false,
-    "cassandra": {
-        "log": {
-            "host": [
-                "192.168.3.11"
-            ],
-            "size": 5,
-            "port": 9042
-        },
-        "push": {
-            "host": [
-                "192.168.3.11"
-            ],
-            "size": 5
-        }
-    },
     "agreement": "http",
     "webdomain": "http://web-jydev-zxl.jianyu360.cn",
     "redirect": {
@@ -259,22 +238,6 @@
         "subscribeTokenTimeout": 15,
         "version": "V2.5.1"
     },
-    "mysql": {
-        "dbName": "jianyu",
-        "address": "192.168.3.11:3366",
-        "userName": "root",
-        "passWord": "Topnet123",
-		"maxOpenConns":500,
-		"maxIdleConns":200
-    },
-	"pushMysql": {
-        "dbName": "jianyu",
-        "address": "192.168.3.11:3366",
-        "userName": "root",
-        "passWord": "Topnet123",
-		"maxOpenConns":2000,
-		"maxIdleConns":1000
-    },
     "mail": [
         {
             "addr": "smtp.exmail.qq.com",

+ 53 - 0
src/db.json

@@ -0,0 +1,53 @@
+{
+	"mongodb": {
+		"main": {
+			"address": "192.168.3.128:27080",
+	 		"size": 5,
+	 		"dbName": "qfw"
+		},
+		"log": {
+			"address": "192.168.3.128:27090",
+	 		"size": 5,
+	 		"dbName": "qfw",
+			"userName": "admin",
+			"password": "123456"
+		},
+		"ent": {
+			"address": "192.168.3.128:27080",
+	 		"size": 5,
+	 		"dbName": "extract_v3"
+		}
+	},
+	"elasticsearch": {
+		"main": {
+			"address": "http://192.168.3.128:9800,http://192.168.3.11:9800",
+	    	"size": 30
+		}
+    },
+    "redis": {
+    	"main":{
+			"address": "other=192.168.3.128:1712,push=192.168.3.128:1712,pushcache_1=192.168.3.128:5000,pushcache_2_a=192.168.3.128:5001,pushcache_2_b=192.168.3.128:5002,sso=192.168.3.128:1712,session=192.168.3.128:1712,recovery=192.168.3.128:1712"
+		},
+		"login": {
+			"address": "login=192.168.3.128:1712"
+		}
+    },
+    "mysql": {
+	    "main": {
+	        "dbName": "jianyu",
+	        "address": "192.168.3.11:3366",
+	        "userName": "root",
+	        "passWord": "Topnet123",
+			"maxOpenConns": 500,
+			"maxIdleConns": 200
+	    },
+		"push": {
+	        "dbName": "jianyu",
+	        "address": "192.168.3.11:3366",
+	        "userName": "root",
+	        "passWord": "Topnet123",
+			"maxOpenConns": 2000,
+			"maxIdleConns": 1000
+	    }
+    }
+}

+ 1 - 3
src/jfw/filter/logfilter.go

@@ -20,7 +20,6 @@ import (
 
 	"github.com/go-xweb/httpsession"
 	"github.com/go-xweb/xweb"
-	"github.com/gocql/gocql"
 )
 
 //日志过滤器
@@ -118,8 +117,7 @@ func addLog(l *logfilter, session *httpsession.Session, req *http.Request) {
 	str := string(md)
 	logs := map[string]interface{}{
 		"id":        uc.DayShortTime(),
-		"tuid":      gocql.TimeUUID(),
-		"date":      timeNow,
+		"date":      timeNow.Unix(),
 		"ip":        req.Proto,
 		"refer":     ref,
 		"year":      timeNow.Year(),

+ 2 - 4
src/jfw/front/websocket.go

@@ -3,10 +3,8 @@ package front
 import (
 	"encoding/json"
 	"fmt"
+	"jfw/public"
 	"log"
-
-	//"net/http"
-	"jfw/config"
 	qutil "qfw/util"
 	"qfw/util/redis"
 	"strings"
@@ -52,7 +50,7 @@ func init() {
 		go ms.GC()
 		MapSocketArr[i] = ms
 	}
-	redis.InitRedisLogin(config.Sysconfig["redislogin"].(string))
+	redis.InitRedisLogin(public.DbConf.Redis.Login.Address)
 }
 
 //

+ 3 - 5
src/jfw/modules/app/src/app/filter/logfilter.go

@@ -62,9 +62,7 @@ func SaveLogTask() {
 		arr = make([]map[string]interface{}, 0)
 		for _, v := range tmp {
 			go func(v map[string]interface{}) {
-				if public.Mgo_Log.Save("jy_fapp", v) == "" {
-					public.MQFW.Save("jyapp_logs", v)
-				}
+				public.Mgo_Log.Save("jyapp_logs", v)
 			}(v)
 		}
 	}
@@ -114,7 +112,7 @@ func addLog(l *logfilter, session *httpsession.Session, req *http.Request) {
 	md, _ := json.Marshal(req.Form)
 	str := string(md)
 	logs := map[string]interface{}{
-		"date":      timeNow,
+		"date":      timeNow.Unix(),
 		"ip":        req.Proto,
 		"refer":     ref,
 		"year":      timeNow.Year(),
@@ -138,7 +136,7 @@ func addLog(l *logfilter, session *httpsession.Session, req *http.Request) {
 	if len(arr) >= nc || s_url == "/sl" {
 		for _, v := range arr {
 			go func(v map[string]interface{}) {
-				public.Mgo_Log.Save("jy_fapp", v)
+				public.Mgo_Log.Save("jyapp_logs", v)
 			}(v)
 		}
 		arr = make([]map[string]interface{}, 0)

+ 11 - 53
src/jfw/modules/app/src/app/followent/followent.go

@@ -9,7 +9,6 @@ import (
 	"qfw/util/redis"
 	"strconv"
 	"strings"
-	"time"
 
 	"github.com/go-xweb/xweb"
 	"gopkg.in/mgo.v2/bson"
@@ -38,18 +37,11 @@ func init() {
 }
 func (f *FollowEnt) AjaxSearch() error {
 	defer util.Catch()
-	id := f.GetString("id")
-	winner := f.GetString("winner")
+	winner := strings.TrimSpace(f.GetString("winner"))
 	//是否关注此企业
 	var follow = "n"
-	s_id := ""
-	if id == "" {
-		s_id = createId(winner)
-	} else {
-		s_id = util.DecodeArticleId2ByCheck(id)[0] //企业id
-	}
 	userid, _ := f.GetSession("userId").(string) //用户id
-	oneQy, ok := mongodb.FindOneByField("jylab_followent", `{"s_userid":"`+userid+`","s_id":"`+s_id+`"}`, `{"a_visited":1}`)
+	oneQy, ok := mongodb.FindOneByField("jylab_followent", map[string]interface{}{"s_userid": userid, "s_entname": winner}, `{"a_visited":1}`)
 	if ok && len(*oneQy) != 0 && oneQy != nil && *oneQy != nil {
 		follow = "y" //已经关注此企业
 	}
@@ -89,7 +81,7 @@ func (f *FollowEnt) AddEnt() error {
 }
 
 func (f *FollowEnt) RecList() {
-	var entName = f.GetString("entName")
+	var entName = strings.TrimSpace(f.GetString("entName"))
 	limit, _ := strconv.Atoi(config.Sysconfig["recommendEntLimit"].(string))
 	re := jylabutil.GetEenNameImmediate(entName, limit)
 	if re != nil && len(re) != 0 {
@@ -110,7 +102,6 @@ func (f *FollowEnt) Detail(followId string) error {
 	userId := util.ObjToString(f.GetSession("userId"))
 	followId = util.DecodeArticleId2ByCheck(followId)[0]
 	winner := ""
-	winnerId := ""
 	var a_visited interface{}
 	oneQy, ok := mongodb.FindOneByField("jylab_followent", map[string]interface{}{
 		"_id":      bson.ObjectIdHex(followId),
@@ -137,10 +128,8 @@ func (f *FollowEnt) Detail(followId string) error {
 		}
 	}
 	winner = util.ObjToString((*oneQy)["s_entname"])
-	winnerId = util.ObjToString((*oneQy)["s_id"])
 	f.T["data"] = public.GetWinnerNewestDatas(winner)
 	f.T["winner"] = winner
-	f.T["s_id"] = util.EncodeArticleId2ByCheck(winnerId)
 	f.T["_id"] = util.EncodeArticleId2ByCheck(followId)
 	f.T["follow"] = follow
 	f.T["a_visited"] = a_visited
@@ -151,21 +140,11 @@ func (f *FollowEnt) Detail(followId string) error {
 func (f *FollowEnt) NewInfo(param string) error {
 	defer util.Catch()
 	userId := util.ObjToString(f.GetSession("userId"))
-	winner := ""
-	winnerId := ""
-	if param != "" {
-		winner = strings.Split(param, "___")[0]
-		winnerId = strings.Split(param, "___")[1]
-	}
+	winner := strings.TrimSpace(strings.Split(param, "___")[0])
 	var follow = "n"
 	var a_visited interface{}
 	//判断用户是否关注
-	if winnerId == "" {
-		winnerId = createId(winner)
-	} else {
-		winnerId = util.DecodeArticleId2ByCheck(winnerId)[0] //企业id
-	}
-	oneQy, ok := mongodb.FindOneByField("jylab_followent", `{"s_userid":"`+userId+`","s_id":"`+winnerId+`"}`, `{"a_visited":1}`)
+	oneQy, ok := mongodb.FindOneByField("jylab_followent", map[string]interface{}{"s_userid": userId, "s_entname": winner}, `{"a_visited":1}`)
 	if ok && oneQy != nil && len(*oneQy) > 0 {
 		follow = "y" //已经关注此企业
 		if (*oneQy)["a_visited"] != nil {
@@ -175,7 +154,6 @@ func (f *FollowEnt) NewInfo(param string) error {
 	}
 	f.T["data"] = public.GetWinnerNewestDatas(winner)
 	f.T["winner"] = winner
-	f.T["s_id"] = util.EncodeArticleId2ByCheck(winnerId)
 	f.T["follow"] = follow
 	f.T["a_visited"] = a_visited
 	return f.Render("/followent/set.html", &f.T)
@@ -186,10 +164,11 @@ func (f *FollowEnt) QgFollow() error {
 	defer util.Catch()
 	status := "n"
 	userid, _ := f.GetSession("userId").(string)
-	id := f.GetString("id")
-	s_id := util.DecodeArticleId2ByCheck(id)[0]
-	ok := mongodb.Del("jylab_followent", `{"s_userid":"`+userid+`","s_id":"`+s_id+`"}`)
-	if ok {
+	name := strings.TrimSpace(f.GetString("name"))
+	data, ok := mongodb.FindOne("jylab_followent", map[string]interface{}{"s_userid": userid, "s_entname": name})
+	if ok && data != nil && len(*data) > 0 && mongodb.Del("jylab_followent", map[string]interface{}{"_id": (*data)["_id"]}) {
+		(*data)["s_followid"] = BsonIdToSId((*data)["_id"])
+		mongodb.Save("jylab_followent_back", data)
 		status = "y"
 	}
 	f.ServeJson(map[string]interface{}{
@@ -207,32 +186,11 @@ func (f *FollowEnt) Followent() error {
 	return f.Render("/followent/index.html")
 }
 
-//没有企业id创建企业id
-func createId(winner string) string {
-	defer util.Catch()
-	if winner == "" {
-		return ""
-	}
-	tem, ok := mongodb.FindOneByField("winner", `{"name":"`+winner+`"}`, `{"_id":1}`)
-	winnerid := ""
-	if ok && len(*tem) == 0 {
-		data := map[string]interface{}{}
-		data["name"] = winner
-		data["winnersign"] = 1
-		data["l_createtime"] = time.Now().Unix()
-		winnerid = mongodb.Save("winner", data)
-		data["_id"] = winnerid
-	} else {
-		//log.Println(*tem, "---------", util.BsonIdToSId((*tem)["_id"]))
-		winnerid = util.ObjToString(BsonIdToSId((*tem)["_id"]))
-	}
-	return winnerid
-}
 func (f *FollowEnt) Visited() error {
 	defer util.Catch()
 	id := f.GetString("id")
 	id = util.DecodeArticleId2ByCheck(id)[0]
-	mongodb.Update("jylab_followent", `{"_id":"`+id+`"}`, map[string]interface{}{
+	mongodb.Update("jylab_followent", map[string]interface{}{"_id": id}, map[string]interface{}{
 		"$addToSet": map[string]interface{}{"a_visited": f.GetString("sid")},
 	}, false, false)
 	return nil

+ 3 - 37
src/jfw/modules/app/src/app/followent/myfwent.go

@@ -3,10 +3,7 @@ package followent
 import (
 	"jfw/config"
 	"jfw/public"
-	"log"
-	. "qfw/mongodb"
 	"qfw/util"
-	"qfw/util/elastic"
 	"strings"
 	"time"
 
@@ -31,24 +28,17 @@ func (m *Myfwent) Addfwent() error {
 	defer util.Catch()
 	userId := m.GetSession("userId").(string)
 	followId := ""
-	s_id := ""
-	entname := m.GetString("winner")
-	if m.GetString("id") == "" {
-		s_id = Findent(entname)
-	} else {
-		s_id = util.DecodeArticleId2ByCheck(m.GetString("id"))[0]
-	}
+	entname := strings.TrimSpace(m.GetString("winner"))
 	var status = "n"
-	if mongodb.Count("jylab_followent", `{"s_userid":"`+userId+`","s_id":"`+s_id+`"}`) > 0 {
+	if mongodb.Count("jylab_followent", map[string]interface{}{"s_userid": userId, "s_entname": entname}) > 0 {
 		status = "e" //已经关注过此企业
-	} else if mongodb.Count("jylab_followent", `{"s_userid":"`+userId+`"}`) >= util.IntAll(config.Sysconfig["followentlimit"]) {
+	} else if mongodb.Count("jylab_followent", map[string]interface{}{"s_userid": userId}) >= util.IntAll(config.Sysconfig["followentlimit"]) {
 		status = "m" //超过最大关注数
 	} else {
 		data := make(map[string]interface{})
 		data["s_entname"] = m.GetString("winner")
 		data["s_userid"] = userId
 		data["l_createtime"] = time.Now().Unix()
-		data["s_id"] = s_id
 		if followId = mongodb.Save("jylab_followent", data); len(followId) > 0 {
 			status = "y"
 		}
@@ -56,34 +46,10 @@ func (m *Myfwent) Addfwent() error {
 	m.ServeJson(map[string]interface{}{
 		"status":   status,
 		"followId": util.EncodeArticleId2ByCheck(followId),
-		"infoId":   util.EncodeArticleId2ByCheck(s_id),
 	})
 	return nil
 }
 
-//
-func Findent(entname string) string {
-	defer util.Catch()
-	tem, ok := mongodb.FindOneByField("winner", `{"name":"`+entname+`"}`, `{"_id":1}`)
-	winnerid := ""
-	if ok && len(*tem) == 0 {
-		data := map[string]interface{}{}
-		data["name"] = entname
-		data["winnersign"] = 1
-		data["l_createtime"] = time.Now().Unix()
-		winnerid = mongodb.Save("winner", data)
-		data["_id"] = winnerid
-		flag := elastic.Save("winner", "winner", data)
-		if !flag {
-			log.Println("企业保存elastic出错!")
-		}
-	} else {
-		//log.Println(*tem, "---------", util.BsonIdToSId((*tem)["_id"]))
-		winnerid = util.ObjToString(BsonIdToSId((*tem)["_id"]))
-	}
-	return winnerid
-}
-
 //删除30无更新数据的企业
 func (m *Myfwent) DelOvertimeCompany() error {
 	defer util.Catch()

+ 0 - 39
src/jfw/modules/app/src/config.json

@@ -1,47 +1,8 @@
 {
-    "influxaddr": "http://192.168.3.207:8086",
-    "influxdb": "jy_logs",
-    "elasticsearch": "http://192.168.3.128:9800",
-    "elasticPoolSize": 2,
-    "logMongodbServers":"192.168.3.128:27080",  
-    "logMongodbName":"qfw",
-    "logMongodbPoolSize":5,
     "cookiedomain": ".jianyu360.cn",
-    "redisaddrs": "other=192.168.3.128:1712,push=192.168.3.128:1712,pushcache_1=192.168.3.128:1712,pushcache_2_a=192.168.3.128:1712,pushcache_2_b=192.168.3.128:1712,sso=192.168.3.128:1712,session=192.168.3.128:1712",
     "webport": "89",
     "weixinrpc": "127.0.0.1:8083",
-    "cassandra": {
-        "log": {
-            "host": [
-                "192.168.3.207"
-            ],
-            "size": 5,
-            "port": 9043
-        },
-        "push": {
-            "host": [
-                "192.168.3.207"
-            ],
-            "size": 5
-        }
-    },
     "cacheflag": false,
-    "mysql": {
-        "dbName": "jianyu",
-        "address": "192.168.3.11:3366",
-        "userName": "root",
-        "passWord": "Topnet123",
-		"maxOpenConns":2,
-		"maxIdleConns":2
-    },
-	"pushMysql": {
-        "dbName": "jianyu",
-        "address": "192.168.3.11:3366",
-        "userName": "root",
-        "passWord": "Topnet123",
-		"maxOpenConns":2,
-		"maxIdleConns":2
-    },
     "agreement": "http",
     "webdomain": "http://web-jydev-tsz.jianyu360.cn",
     "redirect": {

+ 50 - 0
src/jfw/modules/app/src/db.json

@@ -0,0 +1,50 @@
+{
+	"mongodb": {
+		"main": {
+			"address": "192.168.3.128:27080",
+	 		"size": 5,
+	 		"dbName": "qfw"
+		},
+		"log": {
+			"address": "192.168.3.128:27090",
+	 		"size": 5,
+	 		"dbName": "qfw",
+			"userName": "admin",
+			"password": "123456"
+		},
+		"ent": {
+			"address": "192.168.3.128:27080",
+	 		"size": 5,
+	 		"dbName": "extract_v3"
+		}
+	},
+	"elasticsearch": {
+		"main": {
+			"address": "http://192.168.3.128:9800",
+	    	"size": 2
+		}
+    },
+    "redis": {
+    	"main": {
+			"address": "other=192.168.3.128:1712,push=192.168.3.128:1712,pushcache_1=192.168.3.128:1712,pushcache_2_a=192.168.3.128:1712,pushcache_2_b=192.168.3.128:1712,sso=192.168.3.128:1712,session=192.168.3.128:1712"
+		}
+    },
+    "mysql": {
+	    "main": {
+	        "dbName": "jianyu",
+	        "address": "192.168.3.11:3366",
+	        "userName": "root",
+	        "passWord": "Topnet123",
+			"maxOpenConns": 2,
+			"maxIdleConns": 2
+	    },
+		"push": {
+	        "dbName": "jianyu",
+	        "address": "192.168.3.11:3366",
+	        "userName": "root",
+	        "passWord": "Topnet123",
+			"maxOpenConns": 2,
+			"maxIdleConns": 2
+	    }
+    }
+}

+ 15 - 1
src/jfw/modules/app/src/jfw/config/config.go

@@ -19,8 +19,22 @@ var WeixinConfig map[string]interface{}
 
 var GmailAuth []*mail.GmailAuth
 
-func init() {
+type mgoConf struct {
+	Main *mgo
+	Log  *mgo
+	Ent  *mgo
+}
+type mgo struct {
+	Address  string
+	Size     int
+	DbName   string
+	UserName string
+	Password string
+}
 
+var MgoConf *mgoConf
+
+func init() {
 	util.ReadConfig(&Sysconfig)
 	WeixinConfig, _ = Sysconfig["wxJianyu"].(map[string]interface{})
 	mails, _ := Sysconfig["mail"].([]interface{})

+ 0 - 4
src/jfw/modules/app/src/main.go

@@ -7,14 +7,11 @@ import (
 	_ "app/filter"
 	_ "app/followent"
 	_ "app/front"
-
-	//_ "app/pay"
 	"app/tag"
 	. "jfw/config"
 	"jfw/public"
 	"net/http"
 	"qfw/util"
-	"qfw/util/elastic"
 	"strings"
 	"time"
 
@@ -24,7 +21,6 @@ import (
 
 func init() {
 	initXweb()
-	elastic.InitElasticSize(Sysconfig["elasticsearch"].(string), util.IntAllDef(Sysconfig["elasticPoolSize"], 30))
 }
 
 func main() {

+ 0 - 19
src/jfw/modules/app/src/mongodb.json

@@ -1,19 +0,0 @@
-{
-	"main":{
-		"address": "192.168.3.128:27080",
- 		"size": 5,
- 		"dbName": "qfw"
-	},
-	"log":{
-		"address": "192.168.3.128:27080",
- 		"size": 5,
- 		"dbName": "qfw",
-		"userName": "admin",
-		"password": "123456"
-	},
-	"ent":{
-		"address": "192.168.3.128:27080",
- 		"size": 5,
- 		"dbName": "extract_v3"
-	}
-}

+ 2 - 2
src/jfw/modules/app/src/seo.json

@@ -1,7 +1,7 @@
 {	
-	"cdn":"http://web-jydev-xzh.jianyu360.cn",
+	"cdn":"http://web-jydev-wcj.jianyu360.cn",
 	"cdns":{
-	 	"web-jydev-xzh.jianyu360.cn":""
+	 	"web-jydev-wcj.jianyu360.cn":""
 	},
     "qfw": {
         "swordfish": {

BIN
src/jfw/modules/app/src/web.zip


+ 3 - 7
src/jfw/modules/app/src/web/templates/followent/set.html

@@ -25,7 +25,6 @@ if(sessionStorage){
 <script type="text/javascript">
 	var data = {{.T.data}};
 	var winner = {{.T.winner}}; //企业名称
-	var id = {{.T.s_id}}; //企业id
 	var follow = {{.T.follow}};
 	var isOld = 0;
 	///////////////////////
@@ -47,7 +46,7 @@ if(sessionStorage){
 		//解决样式回显问题
 		$.post(
 			"/jyapp/followent/ajaxSearch",
-			{"winner":winner,"id":id},
+			{"winner":winner},
 			function(r){
 				follow = r.follow;
 				if(follow == "n"){
@@ -121,13 +120,10 @@ if(sessionStorage){
 		//确定
 		$("#sure").click(function(){
 			easyPopup.hide();
-			if(id == ""){
-				EasyAlert.show("取消失败!");
-			}
 			//发送Ajax请求,取消关注
 			$.post(
 				"/jyapp/followent/qgFollow",
-				{"id":id},
+				{"name":winner},
 				function(r){
 					if(r.status == "y"){
 						if(sessionStorage){
@@ -156,7 +152,7 @@ if(sessionStorage){
 		$(".gz-followcancel").click(function(){
 			$.post(
 				"/jyapp/followent/addfwent",
-				{"id":id,"winner":winner},
+				{"winner":winner},
 				function(r){
 					if(r.status == "y" || r.status == "e"){
 						if(sessionStorage){

+ 1 - 2
src/jfw/modules/app/src/web/templates/weixin/wxinfocontent.html

@@ -2050,8 +2050,7 @@ $(function(){
         if(winner_con){
             sessionStorage.version="1";
             winner_con = winner_con.replace(/#/g,"%23").replace(/\?/g,"%3F");
-            var winner_id = "";
-            window.location.href = "/jyapp/followent/newInfo/"+winner_con+"___"+winner_id;
+            window.location.href = "/jyapp/followent/newInfo/"+winner_con;
 		}
     });
 	$(".jysub").click(function(){

+ 0 - 12
src/jfw/modules/entsesearch/src/config.json

@@ -1,16 +1,4 @@
 {
-    "mongodbServers": "192.168.3.128:27080",
-    "mongodbPoolSize": "5",
-    "mongodbName": "qfw",
-    "influxaddr": "http://192.168.3.207:8086",
-    "influxdb": "jy_logs",
-    "elasticsearch": "http://192.168.3.128:9800",
-    "elasticPoolSize": 30,
-    "redisaddrs": "other=192.168.3.128:1712,push=192.168.3.128:1712,sso=192.168.3.128:1712,session=192.168.3.128:1712",
-    "cassandra": [
-        "192.168.3.207"
-    ],
-    "cassandrasize": 5,
     "webport": "8090",
     "webrpcport": "84",
     "weixinrpc": "127.0.0.1:83",

+ 20 - 0
src/jfw/modules/entsesearch/src/db.json

@@ -0,0 +1,20 @@
+{
+	"mongodb": {
+		"main": {
+			"address": "192.168.3.128:27080",
+	 		"size": 5,
+	 		"dbName": "qfw"
+		}
+	},
+	"elasticsearch": {
+		"main": {
+			"address": "http://192.168.3.128:9800",
+	    	"size": 30
+		}
+    },
+    "redis": {
+    	"main": {
+			"address": "other=192.168.3.128:1712,push=192.168.3.128:1712,sso=192.168.3.128:1712,session=192.168.3.128:1712"
+		}
+    }
+}

+ 0 - 9
src/jfw/modules/entsesearch/src/main.go

@@ -2,13 +2,9 @@ package main
 
 import (
 	"config"
-	"qfw/util"
-	"qfw/util/elastic"
-	"qfw/util/redis"
 	_ "search"
 	"tag"
 	"time"
-	ca "ucbsutil/cassandra"
 
 	"github.com/go-xweb/httpsession"
 	"github.com/go-xweb/xweb"
@@ -16,11 +12,6 @@ import (
 
 func init() {
 	initXweb()
-	//初始化cassandra
-	ca.ViewCacheLen = true
-	ca.InitCassandra("jianyu", util.IntAll(config.Sysconfig["cassandrasize"]), util.ObjArrToStringArr(config.Sysconfig["cassandra"].([]interface{})))
-	redis.InitRedisBySize(config.Sysconfig["redisaddrs"].(string), 100, 30, 300)
-	elastic.InitElasticSize(config.Sysconfig["elasticsearch"].(string), util.IntAllDef(config.Sysconfig["elasticPoolSize"], 30))
 }
 
 func main() {

+ 1 - 85
src/jfw/modules/entsesearch/src/search/entsesearch.go

@@ -4,16 +4,11 @@ import (
 	"config"
 	"jfw/jylabutil"
 	"jfw/public"
-	"net"
-	"net/http"
 	"qfw/util"
 	"strconv"
-	"strings"
 	"time"
-	uc "ucbsutil"
 
 	"github.com/go-xweb/xweb"
-	"github.com/gocql/gocql"
 )
 
 const (
@@ -89,7 +84,7 @@ func (e *EntSeSearch) ProList() {
 		if proList != nil {
 			listSize = len(proList)
 		}
-		SaveUserSearchLog(e.Request, userid, -1, e.GetString("source"), "中标企业搜索", map[string]interface{}{
+		public.SaveUserSearchLog(e.Request, userid, -1, e.GetString("source"), "中标企业搜索", map[string]interface{}{
 			"search_word":  searchname,
 			"search_area":  scope,
 			"search_price": []string{money_from, money_to},
@@ -124,82 +119,3 @@ func (e *EntSeSearch) ProList() {
 		"hasNextPage": proList != nil && len(proList) == wx_pageSize && pageNum < wx_maxPageNum,
 	})
 }
-
-//保存用户搜索日志
-func SaveUserSearchLog(request *http.Request, userid string, count int64, platform, source string, condition map[string]interface{}) {
-	go func() {
-		data := map[string]interface{}{
-			"ip":     GetIp(request),
-			"count":  count,
-			"openid": userid,
-			"pform":  platform,
-			"source": source,
-			"date":   time.Now(),
-			"uagent": request.Header.Get("User-Agent"),
-		}
-		for _, v := range []string{"pagenum", "pagesize", "search_word", "search_area", "search_publishtime", "search_industry", "search_price", "search_type"} {
-			if vv := condition[v]; vv != nil {
-				//替换key
-				if v == "search_word" {
-					v = "word"
-				} else if v == "search_area" {
-					v = "area"
-				} else if v == "search_publishtime" {
-					v = "ptime"
-				} else if v == "search_industry" {
-					v = "indst"
-				} else if v == "search_price" {
-					v = "price"
-				} else if v == "search_type" {
-					v = "type"
-				} else if v == "pagenum" {
-					v = "pnum"
-				} else if v == "pagesize" {
-					v = "psize"
-				}
-				data[v] = vv
-			}
-		}
-		data["id"] = uc.DayShortTime()
-		data["tuid"] = gocql.TimeUUID()
-		if public.MQLOG.Save("jy_search", data) == "" {
-			data := map[string]interface{}{
-				"ip":         GetIp(request),
-				"count":      count,
-				"s_userid":   userid,
-				"platform":   platform,
-				"source":     source,
-				"createtime": time.Now().Unix(),
-				"userAgent":  request.Header.Get("User-Agent"),
-			}
-			for _, v := range []string{"pagenum", "pagesize", "search_word", "search_area", "search_publishtime", "search_industry", "search_price", "search_type"} {
-				if vv := condition[v]; vv != nil {
-					data[v] = vv
-				}
-			}
-			public.MQFW.Save("jy_search_log", data)
-		}
-	}()
-}
-
-//获取请求ip
-func GetIp(req *http.Request) string {
-	if req == nil {
-		return ""
-	}
-	ip_for := req.Header.Get("x-forwarded-for")
-	ip_client := req.Header.Get("http_client_ip")
-	ip_addr := req.Header.Get("Remote_addr")
-	un := "unknown"
-	if (ip_for != un) && (len(strings.TrimSpace(ip_for)) > 0) {
-		return ip_for
-	}
-	if (ip_client != un) && (len(strings.TrimSpace(ip_client)) > 0) {
-		return ip_client
-	}
-	if (ip_addr != un) && (len(strings.TrimSpace(ip_addr)) > 0) {
-		return ip_addr
-	}
-	ip, _, _ := net.SplitHostPort(req.RemoteAddr)
-	return ip
-}

+ 0 - 18
src/jfw/modules/entsesearch/src/tools/mongo.go

@@ -1,18 +0,0 @@
-package tools
-
-import (
-	"config"
-	"qfw/util"
-	"qfw/util/mongodb"
-)
-
-var MQFW mongodb.MongodbSim
-
-func init() {
-	MQFW = mongodb.MongodbSim{
-		MongodbAddr: util.ObjToString(config.Sysconfig["mongodbServers"]),
-		Size:        util.IntAll(config.Sysconfig["mongodbPoolSize"]),
-		DbName:      util.ObjToString(config.Sysconfig["mongodbName"]),
-	}
-	MQFW.InitPool()
-}

+ 0 - 91
src/jfw/modules/entsesearch/src/tools/rpccall.go

@@ -1,91 +0,0 @@
-package tools
-
-import (
-	"config"
-	"encoding/json"
-	"log"
-	"net/rpc"
-	"qfw/util"
-	qrpc "qfw/util/rpc"
-)
-
-var rpcserver string
-
-func init() {
-	rpcserver = config.Sysconfig["weixinrpc"].(string)
-}
-
-//发送管理员模板消息
-func SendBidOpenMsg(p *qrpc.NotifyMsg, repl *qrpc.RpcResult) (err error) {
-	util.Try(func() {
-		client, e := rpc.DialHTTP("tcp", rpcserver)
-		defer client.Close()
-		if e != nil {
-			err = e
-			log.Println(p.UserId + "---" + err.Error())
-			return
-		}
-		err = client.Call("WeiXinRpc.SendBidOpenMsg", p, &repl)
-		if err != nil {
-			log.Println(p.UserId + "---" + err.Error())
-		}
-	}, func(e interface{}) {})
-	return
-}
-
-//保存不正常用户
-func SaveAbnormal(openid string) {
-	util.Try(func() {
-		client, err := rpc.DialHTTP("tcp", rpcserver)
-		defer client.Close()
-		if err != nil {
-			log.Println(err.Error())
-			return
-		}
-		var repl string
-		err = client.Call("WeiXinRpc.SaveAbnormal", openid, &repl)
-		if err != nil {
-			log.Println(err.Error())
-		}
-	}, func(e interface{}) {})
-}
-
-//分享二维码图片
-func GetShareQR(url uint32) string {
-	var ret string
-	util.Try(func() {
-		client, err := rpc.DialHTTP("tcp", rpcserver)
-		defer client.Close()
-		if err != nil {
-			log.Println(err.Error())
-			return
-		}
-		err = client.Call("WeiXinRpc.GetShareQR", url, &ret)
-		if err != nil {
-			log.Println(err.Error())
-		}
-	}, func(e interface{}) {})
-	return ret
-}
-
-//取得预生成订单编号,我们的系统要控制下,别订单重复了
-func GetPrepayId(param map[string]string) (res *map[string]interface{}, e error) {
-	util.Try(func() {
-		client, err := rpc.DialHTTP("tcp", rpcserver)
-		defer client.Close()
-		if err != nil {
-			e = err
-			log.Println(err.Error())
-			return
-		}
-		var ret []byte
-		err = client.Call("WeiXinRpc.GetPrepayId", param, &ret)
-		if err != nil {
-			e = err
-			log.Println(err.Error())
-		} else {
-			json.Unmarshal(ret, &res)
-		}
-	}, func(e interface{}) {})
-	return
-}

+ 0 - 41
src/jfw/modules/entsesearch/src/wx/wxjssdk.go

@@ -1,41 +0,0 @@
-package wx
-
-import (
-	"config"
-	"encoding/json"
-	"log"
-	"net/rpc"
-	"qfw/util"
-	"qfw/util/redis"
-)
-
-func SignJSSDK(url string) []string {
-	util.Catch()
-	var signature []string
-	var key = "wxsignature_" + url
-	if ret := redis.Get("other", key); ret != nil {
-		if d, err := json.Marshal(ret); err == nil {
-			json.Unmarshal(d, &signature)
-		}
-	}
-	if signature == nil || len(signature) == 0 {
-		util.Try(func() {
-			client, err := rpc.DialHTTP("tcp", util.ObjToString(config.Sysconfig["weixinrpc"]))
-			defer client.Close()
-			if err != nil {
-				log.Println(err.Error())
-				return
-			}
-			err = client.Call("WeiXinRpc.GetJSInterfaceParam", url, &signature)
-			if err != nil {
-				log.Println(err.Error())
-			}
-		}, func(e interface{}) {})
-		if signature == nil || len(signature) != 4 || signature[3] == "" {
-			signature = []string{"", "", "", ""}
-		} else {
-			redis.Put("other", key, signature, 90*60)
-		}
-	}
-	return signature
-}

+ 0 - 6
src/jfw/modules/followent/src/config.json

@@ -1,10 +1,4 @@
 {
-    "mongodbServers": "192.168.3.18:27080",
-    "mongodbPoolSize": "5",
-    "mongodbName": "qfw",
-    "elasticsearch": "http://192.168.3.18:9800",
-    "elasticPoolSize": 30,
-    "redisaddrs": "other=192.168.3.18:3379,push=192.168.3.18:3379,sso=192.168.3.18:3379,session=192.168.3.18:3379,recovery=192.168.3.18:3379",
     "webport": "81",
     "weixinrpc": "127.0.0.1:8083",
     "cacheflag": false,

+ 20 - 0
src/jfw/modules/followent/src/db.json

@@ -0,0 +1,20 @@
+{
+	"mongodb": {
+		"main": {
+			"address": "192.168.3.128:27080",
+	 		"size": 5,
+	 		"dbName": "qfw"
+		}
+	},
+	"elasticsearch": {
+		"main":{
+			"address": "http://192.168.3.128:9800",
+	    	"size": 30
+		}
+    },
+    "redis": {
+    	"main": {
+			"address": "other=192.168.3.128:1712,push=192.168.3.128:1712,sso=192.168.3.128:1712,session=192.168.3.128:1712,recovery=192.168.3.128:1712"
+		}
+    }
+}

+ 15 - 57
src/jfw/modules/followent/src/followent/followent.go

@@ -5,11 +5,11 @@ import (
 	"jfw/jylabutil"
 	"jfw/public"
 	"jfw/wx"
+	. "qfw/mongodb"
 	"qfw/util"
 	"qfw/util/redis"
 	"strconv"
 	"strings"
-	"time"
 
 	"github.com/go-xweb/xweb"
 	"gopkg.in/mgo.v2/bson"
@@ -37,18 +37,11 @@ func init() {
 }
 func (f *FollowEnt) AjaxSearch() error {
 	defer util.Catch()
-	id := f.GetString("id")
-	winner := f.GetString("winner")
+	winner := strings.TrimSpace(f.GetString("winner"))
 	//是否关注此企业
 	var follow = "n"
-	s_id := ""
-	if id == "" {
-		s_id = createId(winner)
-	} else {
-		s_id = util.DecodeArticleId2ByCheck(id)[0] //企业id
-	}
 	userId := f.GetSession("userId").(string) //用户id
-	oneQy, ok := mongodb.FindOneByField("jylab_followent", `{"s_userid":"`+userId+`","s_id":"`+s_id+`"}`, `{"a_visited":1}`)
+	oneQy, ok := mongodb.FindOneByField("jylab_followent", map[string]interface{}{"s_userid": userId, "s_entname": winner}, `{"a_visited":1}`)
 	if ok && len(*oneQy) != 0 && oneQy != nil && *oneQy != nil {
 		follow = "y" //已经关注此企业
 	}
@@ -69,8 +62,8 @@ func (f *FollowEnt) EntList() error {
 	f.T["flag"] = false
 	if ok && datas != nil && len(*datas) > 0 {
 		for _, v := range *datas {
-			v["_id"] = util.EncodeArticleId2ByCheck(util.BsonIdToSId(v["_id"]))
-			v["s_id"] = util.EncodeArticleId2ByCheck(util.BsonIdToSId(v["s_id"]))
+			v["_id"] = util.EncodeArticleId2ByCheck(BsonIdToSId(v["_id"]))
+			v["s_id"] = util.EncodeArticleId2ByCheck(BsonIdToSId(v["s_id"]))
 			if v["l_lastpushtime"] == "" || v["l_lastpushtime"] == nil {
 				v["l_lastpushtime"] = v["l_createtime"]
 			}
@@ -101,7 +94,7 @@ func (f *FollowEnt) AddEnt() error {
 }
 
 func (f *FollowEnt) RecList() {
-	var entName = f.GetString("entName")
+	var entName = strings.TrimSpace(f.GetString("entName"))
 	limit, _ := strconv.Atoi(config.Sysconfig["recommendEntLimit"].(string))
 	re := jylabutil.GetEenNameImmediate(entName, limit)
 	if re != nil && len(re) != 0 {
@@ -125,7 +118,6 @@ func (f *FollowEnt) Detail(followId string) error {
 	}
 	followId = util.DecodeArticleId2ByCheck(followId)[0]
 	winner := ""
-	winnerId := ""
 	var a_visited interface{}
 	oneQy, ok := mongodb.FindOneByField("jylab_followent", map[string]interface{}{
 		"_id":      bson.ObjectIdHex(followId),
@@ -147,10 +139,8 @@ func (f *FollowEnt) Detail(followId string) error {
 		follow = "y"
 	}
 	winner = util.ObjToString((*oneQy)["s_entname"])
-	winnerId = util.ObjToString((*oneQy)["s_id"])
 	f.T["data"] = public.GetWinnerNewestDatas(winner)
 	f.T["winner"] = winner
-	f.T["s_id"] = util.EncodeArticleId2ByCheck(winnerId)
 	f.T["_id"] = util.EncodeArticleId2ByCheck(followId)
 	f.T["follow"] = follow
 	f.T["a_visited"] = a_visited
@@ -168,30 +158,19 @@ func (f *FollowEnt) NewInfo(param string) error {
 	if userId == "" {
 		return f.Redirect("/swordfish/about")
 	}
-	winner := ""
-	winnerId := ""
-	if param != "" {
-		winner = strings.Split(param, "___")[0]
-		winnerId = strings.Split(param, "___")[1]
-	}
-	if winnerId == "" {
-		winnerId = createId(winner)
-	} else {
-		winnerId = util.DecodeArticleId2ByCheck(winnerId)[0] //企业id
-	}
+	winner := strings.TrimSpace(strings.Split(param, "___")[0])
 	var follow = "n"
 	var a_visited interface{}
-	oneQy, ok := mongodb.FindOneByField("jylab_followent", `{"s_userid":"`+userId+`","s_id":"`+winnerId+`"}`, `{"a_visited":1}`)
+	oneQy, ok := mongodb.FindOneByField("jylab_followent", map[string]interface{}{"s_userid": userId, "s_entname": winner}, `{"a_visited":1}`)
 	if ok && oneQy != nil && len(*oneQy) > 0 {
 		follow = "y" //已经关注此企业
 		if (*oneQy)["a_visited"] != nil {
 			a_visited = (*oneQy)["a_visited"]
 		}
-		f.T["_id"] = util.EncodeArticleId2ByCheck(util.BsonIdToSId((*oneQy)["_id"]))
+		f.T["_id"] = util.EncodeArticleId2ByCheck(BsonIdToSId((*oneQy)["_id"]))
 	}
 	f.T["data"] = public.GetWinnerNewestDatas(winner)
 	f.T["winner"] = winner
-	f.T["s_id"] = util.EncodeArticleId2ByCheck(winnerId)
 	f.T["follow"] = follow
 	f.T["a_visited"] = a_visited
 	f.T["signature"] = wx.SignJSSDK(f.Site() + f.Url())
@@ -209,14 +188,11 @@ func (f *FollowEnt) QgFollow() error {
 		return f.Redirect("/swordfish/about")
 	}
 	status := "n"
-	id := f.GetString("id")
-	s_id := util.DecodeArticleId2ByCheck(id)[0]
-	data, ok := mongodb.FindOne("jylab_followent", `{"s_userid":"`+userid+`","s_id":"`+s_id+`"}`)
-	if mongodb.Del("jylab_followent", `{"s_userid":"`+userid+`","s_id":"`+s_id+`"}`) {
-		if ok && data != nil && len(*data) > 0 {
-			(*data)["s_followid"] = util.BsonIdToSId((*data)["_id"])
-			mongodb.Save("jylab_followent_back", data)
-		}
+	name := strings.TrimSpace(f.GetString("name"))
+	data, ok := mongodb.FindOne("jylab_followent", map[string]interface{}{"s_userid": userid, "s_entname": name})
+	if ok && data != nil && len(*data) > 0 && mongodb.Del("jylab_followent", map[string]interface{}{"_id": (*data)["_id"]}) {
+		(*data)["s_followid"] = BsonIdToSId((*data)["_id"])
+		mongodb.Save("jylab_followent_back", data)
 		status = "y"
 	}
 	f.ServeJson(map[string]interface{}{
@@ -234,29 +210,11 @@ func (f *FollowEnt) Followent() error {
 	return f.Render("/weixin/index.html")
 }
 
-//没有企业id创建企业id
-func createId(winner string) string {
-	defer util.Catch()
-	tem, ok := mongodb.FindOneByField("winner", `{"name":"`+winner+`"}`, `{"_id":1}`)
-	winnerid := ""
-	if ok && len(*tem) == 0 {
-		data := map[string]interface{}{}
-		data["name"] = winner
-		data["winnersign"] = 1
-		data["l_createtime"] = time.Now().Unix()
-		winnerid = mongodb.Save("winner", data)
-		data["_id"] = winnerid
-	} else {
-		//log.Println(*tem, "---------", util.BsonIdToSId((*tem)["_id"]))
-		winnerid = util.ObjToString(util.BsonIdToSId((*tem)["_id"]))
-	}
-	return winnerid
-}
 func (f *FollowEnt) Visited() error {
 	defer util.Catch()
 	id := f.GetString("id")
 	id = util.DecodeArticleId2ByCheck(id)[0]
-	mongodb.Update("jylab_followent", `{"_id":"`+id+`"}`, map[string]interface{}{
+	mongodb.Update("jylab_followent", map[string]interface{}{"_id": id}, map[string]interface{}{
 		"$addToSet": map[string]interface{}{"a_visited": f.GetString("sid")},
 	}, false, false)
 	return nil

+ 3 - 40
src/jfw/modules/followent/src/followent/myfwent.go

@@ -3,9 +3,7 @@ package followent
 import (
 	"config"
 	"jfw/public"
-	"log"
 	"qfw/util"
-	"qfw/util/elastic"
 	"strings"
 	"time"
 
@@ -30,22 +28,12 @@ func (m *Myfwent) Addfwent() error {
 	defer util.Catch()
 	userid := util.ObjToString(m.GetSession("userId"))
 	openid := util.ObjToString(m.GetSession("s_m_openid").(string))
-	if userid == "" || openid == "" {
-		return m.Redirect("/swordfish/about")
-	}
-
 	followId := ""
-	s_id := ""
-	entname := m.GetString("winner")
-	if m.GetString("id") == "" {
-		s_id = Findent(entname)
-	} else {
-		s_id = util.DecodeArticleId2ByCheck(m.GetString("id"))[0]
-	}
+	entname := strings.TrimSpace(m.GetString("winner"))
 	var status = "n"
-	if mongodb.Count("jylab_followent", `{"s_userid":"`+userid+`","s_id":"`+s_id+`"}`) > 0 {
+	if mongodb.Count("jylab_followent", map[string]interface{}{"s_userid": userid, "s_entname": entname}) > 0 {
 		status = "e" //已经关注过此企业
-	} else if mongodb.Count("jylab_followent", `{"s_userid":"`+userid+`"}`) >= util.IntAll(config.Sysconfig["followentlimit"]) {
+	} else if mongodb.Count("jylab_followent", map[string]interface{}{"s_userid": userid}) >= util.IntAll(config.Sysconfig["followentlimit"]) {
 		status = "m" //超过最大关注数
 	} else {
 		data := make(map[string]interface{})
@@ -54,7 +42,6 @@ func (m *Myfwent) Addfwent() error {
 		data["s_openid"] = openid
 		data["i_ispush"] = 1
 		data["l_createtime"] = time.Now().Unix()
-		data["s_id"] = s_id
 		if followId = mongodb.Save("jylab_followent", data); len(followId) > 0 {
 			status = "y"
 		}
@@ -62,34 +49,10 @@ func (m *Myfwent) Addfwent() error {
 	m.ServeJson(map[string]interface{}{
 		"status":   status,
 		"followId": util.EncodeArticleId2ByCheck(followId),
-		"infoId":   util.EncodeArticleId2ByCheck(s_id),
 	})
 	return nil
 }
 
-//
-func Findent(entname string) string {
-	defer util.Catch()
-	tem, ok := mongodb.FindOneByField("winner", `{"name":"`+entname+`"}`, `{"_id":1}`)
-	winnerid := ""
-	if ok && len(*tem) == 0 {
-		data := map[string]interface{}{}
-		data["name"] = entname
-		data["winnersign"] = 1
-		data["l_createtime"] = time.Now().Unix()
-		winnerid = mongodb.Save("winner", data)
-		data["_id"] = winnerid
-		flag := elastic.Save("winner", "winner", data)
-		if !flag {
-			log.Println("企业保存elastic出错!")
-		}
-	} else {
-		//log.Println(*tem, "---------", util.BsonIdToSId((*tem)["_id"]))
-		winnerid = util.ObjToString(util.BsonIdToSId((*tem)["_id"]))
-	}
-	return winnerid
-}
-
 //删除30无更新数据的企业
 func (m *Myfwent) DelOvertimeCompany() error {
 	defer util.Catch()

+ 0 - 5
src/jfw/modules/followent/src/main.go

@@ -3,9 +3,6 @@ package main
 import (
 	"config"
 	_ "followent"
-	"qfw/util"
-	"qfw/util/elastic"
-	"qfw/util/redis"
 	"tag"
 	"time"
 
@@ -15,8 +12,6 @@ import (
 
 func init() {
 	initXweb()
-	redis.InitRedisBySize(config.Sysconfig["redisaddrs"].(string), 100, 30, 300)
-	elastic.InitElasticSize(config.Sysconfig["elasticsearch"].(string), util.IntAllDef(config.Sysconfig["elasticPoolSize"], 30))
 }
 
 func main() {

+ 26 - 48
src/jfw/modules/followent/src/web/templates/weixin/set.html

@@ -27,9 +27,7 @@ if(sessionStorage){
 <script type="text/javascript">
 	var data = {{.T.data}};
 	var winner = {{.T.winner}}; //企业名称
-	var id = {{.T.s_id}}; //企业id 
 	var follow = {{.T.follow}};   
-	var zbadd = {{Msg "seo" "ZBADDRESS"}};
 	var isOld = 0; 
 	initShare({{.T.signature}},{{.T.openid}},2,"jy_extend",{{.T.nickname}},{{.T.avatar}});
 	$(function(){
@@ -44,7 +42,7 @@ if(sessionStorage){
 		//解决样式回显问题
 		$.post(
 			"/jylab/followent/ajaxSearch",
-			{"winner":winner,"id":id},
+			{"winner":winner},
 			function(r){
 				follow = r.follow;
 				if(follow == "n"){
@@ -118,13 +116,10 @@ if(sessionStorage){
 		//确定
 		$("#sure").click(function(){
 			easyPopup.hide();
-			if(id == ""){
-				EasyAlert.show("取消失败!");
-			}
 			//发送Ajax请求,取消关注
 			$.post(
 				"/jylab/followent/qgFollow",
-				{"id":id},
+				{"name":winner},
 				function(r){
 					if(r.status == "y"){
 						if(sessionStorage){
@@ -154,22 +149,22 @@ if(sessionStorage){
 		$(".gz-followcancel").click(function(){
 			$.post(
 				"/jylab/followent/addfwent",
-				{"id":id,"winner":winner},
+				{"winner":winner},
 				function(r){
 					if(r.status == "y" || r.status == "e"){
-						if(sessionStorage){
-							sessionStorage.followSetReload = "1";
-						}
-                  		EasyAlert.show('已关注"'+winner+'"');
-						sessionStorage.version="1";
-						setTimeout(function(){
-							window.location.href = "/jylab/followent/entList";
-						},1000)	
-               		}else if(r.status == "m"){
-                    	EasyAlert.show("最多可关注10个企业!");
-               		}else{
-                   		EasyAlert.show("数据提交失败!");
-                	}
+  						if(sessionStorage){
+  							sessionStorage.followSetReload = "1";
+  						}
+              EasyAlert.show('已关注"'+winner+'"');
+  						sessionStorage.version="1";
+  						setTimeout(function(){
+  							window.location.href = "/jylab/followent/entList";
+  						},1000)	
+         		}else if(r.status == "m"){
+              EasyAlert.show("最多可关注10个企业!");
+         		}else{
+             	EasyAlert.show("数据提交失败!");
+          	}
 				}
 			)
 		})	
@@ -177,46 +172,29 @@ if(sessionStorage){
 	
 function isVisited(sid){
 	var a_visited = {{.T.a_visited}};
-	for(var i=0;i<a_visited.length;i++){
-		if(a_visited[i] == sid){
-			return true;
-		}
-	}
+  if (a_visited!=null){
+  	for(var i=0;i<a_visited.length;i++){
+  		if(a_visited[i] == sid){
+  			return true;
+  		}
+  	}
+  }
 	return false;
 }
 function beforeRedirect(obj,sid,link,isOld){
 	if($(obj).hasClass("visited")){
-		if(isOld){
-			myRedirect({{Msg "seo" "ZBADDRESS"}},link,sid);
-		}else{
-			newredirect({{Msg "seo" "ZBADDRESS"}},link,sid);
-		}
+		newredirect("",link,sid);
 		return;
 	}
 	var _id = {{.T._id}}
 	$(obj).addClass("visited");
 	if(typeof(sid) != "undefined" && sid != null && sid != "" && typeof(_id) != "undefined" && _id != null && _id != ""){
 		$.post("/jylab/followent/notice/visited",{id:_id,sid:sid},function(r){
-			if(isOld){
-				myRedirect({{Msg "seo" "ZBADDRESS"}},link,sid);
-			}else{
-				newredirect({{Msg "seo" "ZBADDRESS"}},link,sid);
-			}	
+			newredirect("",link,sid);
 		});
 	}else{
-		if(isOld){
-			myRedirect({{Msg "seo" "ZBADDRESS"}},link,sid);
-		}else{
-			newredirect({{Msg "seo" "ZBADDRESS"}},link,sid);
-		}
-	}
-}
-function myRedirect(zbadd,link,sid){
-	link = link.replace(/\n/g,"");
-	if(!/^http/.test(link)){
-		link="http://"+link
+		newredirect("",link,sid);
 	}
-	window.location.href="/";
 }
 </script>
 </head>

+ 98 - 66
src/jfw/public/db.go

@@ -1,22 +1,35 @@
 package public
 
 import (
-	. "jfw/config"
 	"log"
 	mg "qfw/mongodb"
 	mg_v1 "qfw/mongodb_v1"
 	"qfw/util"
+	"qfw/util/elastic"
 	"qfw/util/jy"
 	"qfw/util/mysql"
 	"qfw/util/redis"
 )
 
-type mgoConf struct {
-	Main *mgo
-	Log  *mgo
-	Ent  *mgo
+type dbConf struct {
+	Mongodb struct {
+		Main *mgoConf
+		Log  *mgoConf
+		Ent  *mgoConf
+	}
+	Elasticsearch struct {
+		Main *esConf
+	}
+	Redis struct {
+		Main  *redisConf
+		Login *redisConf
+	}
+	Mysql struct {
+		Main *mysqlConf
+		Push *mysqlConf
+	}
 }
-type mgo struct {
+type mgoConf struct {
 	Address  string
 	Size     int
 	DbName   string
@@ -24,7 +37,23 @@ type mgo struct {
 	Password string
 }
 
-var MgoConf *mgoConf
+type esConf struct {
+	Address string
+	Size    int
+}
+type redisConf struct {
+	Address string
+}
+type mysqlConf struct {
+	DbName       string
+	Address      string
+	UserName     string
+	PassWord     string
+	MaxOpenConns int
+	MaxIdleConns int
+}
+
+var DbConf *dbConf
 
 var (
 	Mysql     *mysql.Mysql
@@ -35,69 +64,72 @@ var (
 )
 
 func init() {
-	util.ReadConfig("./mongodb.json", &MgoConf)
-	//初始化redis
-	redisConfig, _ := Sysconfig["redisaddrs"].(string)
-	if redisConfig != "" {
-		log.Println("初始化 mongodb redis")
-		redis.InitRedisBySize(Sysconfig["redisaddrs"].(string), 100, 30, 300)
-	}
-	//
-	if MgoConf.Main != nil {
-		log.Println("初始化 mongodb main")
-		MQFW = mg.MongodbSim{
-			MongodbAddr: MgoConf.Main.Address,
-			Size:        MgoConf.Main.Size,
-			DbName:      MgoConf.Main.DbName,
+	util.ReadConfig("./db.json", &DbConf)
+	if DbConf != nil {
+		if DbConf.Elasticsearch.Main != nil {
+			elastic.InitElasticSize(DbConf.Elasticsearch.Main.Address, DbConf.Elasticsearch.Main.Size)
+			log.Println("初始化 elasticsearch")
 		}
-		MQFW.InitPool()
-	}
-	if MgoConf.Ent != nil {
-		log.Println("初始化 mongodb ent")
-		Mgo_Ent = mg.MongodbSim{
-			MongodbAddr: MgoConf.Ent.Address,
-			Size:        MgoConf.Ent.Size,
-			DbName:      MgoConf.Ent.DbName,
+		//初始化redis
+		if DbConf.Redis.Main != nil {
+			log.Println("初始化 redis")
+			redis.InitRedisBySize(DbConf.Redis.Main.Address, 100, 30, 300)
 		}
-		Mgo_Ent.InitPool()
-	}
-	if MgoConf.Log != nil {
-		log.Println("初始化 mongodb log")
-		Mgo_Log = mg_v1.MongodbSim{
-			MongodbAddr: MgoConf.Log.Address,
-			Size:        MgoConf.Log.Size,
-			DbName:      MgoConf.Log.DbName,
-			UserName:    MgoConf.Log.UserName,
-			Password:    MgoConf.Log.Password,
+		//
+		if DbConf.Mongodb.Main != nil {
+			log.Println("初始化 mongodb main")
+			MQFW = mg.MongodbSim{
+				MongodbAddr: DbConf.Mongodb.Main.Address,
+				Size:        DbConf.Mongodb.Main.Size,
+				DbName:      DbConf.Mongodb.Main.DbName,
+			}
+			MQFW.InitPool()
 		}
-		Mgo_Log.InitPool()
-	}
-	mysqlConfig, _ := Sysconfig["mysql"].(map[string]interface{})
-	if mysqlConfig != nil {
-		log.Println("初始化 mysql")
-		Mysql = &mysql.Mysql{
-			Address:      util.ObjToString(mysqlConfig["address"]),
-			UserName:     util.ObjToString(mysqlConfig["userName"]),
-			PassWord:     util.ObjToString(mysqlConfig["passWord"]),
-			DBName:       util.ObjToString(mysqlConfig["dbName"]),
-			MaxOpenConns: util.IntAll(mysqlConfig["maxOpenConns"]),
-			MaxIdleConns: util.IntAll(mysqlConfig["maxIdleConns"]),
+		if DbConf.Mongodb.Ent != nil {
+			log.Println("初始化 mongodb ent")
+			Mgo_Ent = mg.MongodbSim{
+				MongodbAddr: DbConf.Mongodb.Ent.Address,
+				Size:        DbConf.Mongodb.Ent.Size,
+				DbName:      DbConf.Mongodb.Ent.DbName,
+			}
+			Mgo_Ent.InitPool()
 		}
-		Mysql.Init()
-	}
-	//
-	pushMysqlConfig, _ := Sysconfig["pushMysql"].(map[string]interface{})
-	if pushMysqlConfig != nil {
-		log.Println("初始化 pushMysql")
-		PushMysql = &mysql.Mysql{
-			Address:      util.ObjToString(pushMysqlConfig["address"]),
-			UserName:     util.ObjToString(pushMysqlConfig["userName"]),
-			PassWord:     util.ObjToString(pushMysqlConfig["passWord"]),
-			DBName:       util.ObjToString(pushMysqlConfig["dbName"]),
-			MaxOpenConns: util.IntAll(pushMysqlConfig["maxOpenConns"]),
-			MaxIdleConns: util.IntAll(pushMysqlConfig["maxIdleConns"]),
+		if DbConf.Mongodb.Log != nil {
+			log.Println("初始化 mongodb log")
+			Mgo_Log = mg_v1.MongodbSim{
+				MongodbAddr: DbConf.Mongodb.Log.Address,
+				Size:        DbConf.Mongodb.Log.Size,
+				DbName:      DbConf.Mongodb.Log.DbName,
+				UserName:    DbConf.Mongodb.Log.UserName,
+				Password:    DbConf.Mongodb.Log.Password,
+			}
+			Mgo_Log.InitPool()
+		}
+		if DbConf.Mysql.Main != nil {
+			log.Println("初始化 mysql")
+			Mysql = &mysql.Mysql{
+				Address:      DbConf.Mysql.Main.Address,
+				UserName:     DbConf.Mysql.Main.UserName,
+				PassWord:     DbConf.Mysql.Main.PassWord,
+				DBName:       DbConf.Mysql.Main.DbName,
+				MaxOpenConns: DbConf.Mysql.Main.MaxOpenConns,
+				MaxIdleConns: DbConf.Mysql.Main.MaxIdleConns,
+			}
+			Mysql.Init()
+		}
+		//
+		if DbConf.Mysql.Push != nil {
+			log.Println("初始化 pushMysql")
+			PushMysql = &mysql.Mysql{
+				Address:      DbConf.Mysql.Push.Address,
+				UserName:     DbConf.Mysql.Push.UserName,
+				PassWord:     DbConf.Mysql.Push.PassWord,
+				DBName:       DbConf.Mysql.Push.DbName,
+				MaxOpenConns: DbConf.Mysql.Push.MaxOpenConns,
+				MaxIdleConns: DbConf.Mysql.Push.MaxIdleConns,
+			}
+			PushMysql.Init()
+			jy.PushMapping.Init(PushMysql)
 		}
-		PushMysql.Init()
-		jy.PushMapping.Init(PushMysql)
 	}
 }

+ 0 - 3
src/main.go

@@ -18,7 +18,6 @@ import (
 	"net/http"
 	"net/rpc"
 	"qfw/util"
-	"qfw/util/elastic"
 	"qfw/util/endless"
 	_ "qfw/util/mysql"
 
@@ -32,8 +31,6 @@ import (
 
 func init() {
 	initXweb()
-	//redis.InitRedisBySize(Sysconfig["redisaddrs"].(string), 100, 30, 300)
-	elastic.InitElasticSize(Sysconfig["elasticsearch"].(string), util.IntAllDef(Sysconfig["elasticPoolSize"], 30))
 	//定时任务
 	timetask.TaskService()
 

+ 0 - 19
src/mongodb.json

@@ -1,19 +0,0 @@
-{
-	"main":{
-		"address": "192.168.3.128:27080",
- 		"size": 5,
- 		"dbName": "qfw"
-	},
-	"log":{
-		"address": "192.168.3.128:27080",
- 		"size": 5,
- 		"dbName": "qfw",
-		"userName": "admin",
-		"password": "123456"
-	},
-	"ent":{
-		"address": "192.168.3.128:27080",
- 		"size": 5,
- 		"dbName": "extract_v3"
-	}
-}

+ 1 - 2
src/web/templates/weixin/wxinfocontent.html

@@ -1471,8 +1471,7 @@ $(function(){
         if(winner_con){
             sessionStorage.version="1";
             winner_con = winner_con.replace(/#/g,"%23").replace(/\?/g,"%3F");
-            var winner_id = "";
-            window.location.href = "/jylab/followent/newInfo/"+winner_con+"___"+winner_id;
+            window.location.href = "/jylab/followent/newInfo/"+winner_con;
 		}
     });
 	$(".jysub").click(function(){

+ 2 - 4
src/web/templates/weixin/wxinfocontent_rec.html

@@ -1162,8 +1162,7 @@ function clearup(rp){
         if(winner_con){
             sessionStorage.version="1";
             winner_con = winner_con.replace(/#/g,"%23").replace(/\?/g,"%3F");
-            var winner_id = "";
-            window.location.href = "/jylab/followent/newInfo/"+winner_con+"___"+winner_id;
+            window.location.href = "/jylab/followent/newInfo/"+winner_con;
 		}
     });
 }
@@ -1972,8 +1971,7 @@ $(function(){
         if(winner_con){
             sessionStorage.version="1";
             winner_con = winner_con.replace(/#/g,"%23").replace(/\?/g,"%3F");
-            var winner_id = "";
-            window.location.href = "/jylab/followent/newInfo/"+winner_con+"___"+winner_id;
+            window.location.href = "/jylab/followent/newInfo/"+winner_con;
 		}
     });
 	$(".jysub").click(function(){