Jianghan 2 jaren geleden
bovenliggende
commit
9e3d8ac0f5

+ 5 - 0
src/config.json

@@ -36,6 +36,11 @@
     "redisdelkey5": "jypcdetail__rec_entniche_",
     "redis_jy_save": "title_repeat_fulljudgement=192.168.3.207:1679,shaid=192.168.3.207:1679"
   },
+  "redis_cluster": [
+    "172.17.4.239:2479",
+    "172.17.4.240:2579",
+    "172.17.4.84:2379"
+  ],
   "jy_pro": {
     "mgodb": "192.168.3.207:27092",
     "dbsize": 5,

+ 14 - 3
src/service/jy_service.go

@@ -4,6 +4,7 @@ import (
 	"github.com/go-xweb/xweb"
 	"mongodb"
 	qu "qfw/util"
+	"strings"
 	"util"
 )
 
@@ -31,9 +32,19 @@ func (jy *JyData) FindInfo() {
 		if len(identity) == 24 {
 			id = identity
 		} else {
-			identity = rpre.ReplaceAllString(identity, "")
-			identity = rsuf.ReplaceAllString(identity, "")
-			id = qu.CommonDecodeArticle("content", identity)[0]
+			if strings.Contains(identity, "content") {
+				identity = rpre.ReplaceAllString(identity, "")
+				identity = rsuf.ReplaceAllString(identity, "")
+				id = qu.CommonDecodeArticle("content", identity)[0]
+			} else if strings.Contains(identity, "bdprivate") {
+				identity = rpre1.ReplaceAllString(identity, "")
+				identity = rsuf.ReplaceAllString(identity, "")
+				id = qu.CommonDecodeArticle("bdprivate", identity)[0]
+			} else if strings.Contains(identity, "mailprivate") {
+				identity = rpre2.ReplaceAllString(identity, "")
+				identity = rsuf.ReplaceAllString(identity, "")
+				id = qu.CommonDecodeArticle("mailprivate", identity)[0]
+			}
 		}
 		qu.Debug("findInfo --- url/id ---", id)
 		if !mongodb.IsObjectIdHex(id) {

+ 1 - 1
src/service/oprd_service.go

@@ -19,7 +19,7 @@ type OprdData struct {
 	saveData   xweb.Mapper `xweb:"/service/oprd/modify/save"`
 }
 
-var Field = map[string]interface{}{"city": 1, "district": 1, "title": 1, "publishtime": 1, "projectname": 1, "projectcode": 1,
+var Field = map[string]interface{}{"area": 1, "city": 1, "district": 1, "title": 1, "publishtime": 1, "projectname": 1, "projectcode": 1,
 	"budget": 1, "bidamount": 1, "bidopentime": 1, "buyer": 1, "buyertagname": 1, "buyerperson": 1, "buyertel": 1, "agency": 1,
 	"s_winner": 1, "winnerperson": 1, "winnertel": 1, "subtype": 1, "toptype": 1}
 

+ 54 - 13
src/service/repair_service.go

@@ -2,6 +2,7 @@ package service
 
 import (
 	"bytes"
+	"context"
 	"encoding/json"
 	"fmt"
 	"github.com/go-xweb/xweb"
@@ -29,6 +30,7 @@ import (
 var (
 	rpre          = regexp.MustCompile("https://www.jianyu360.cn/article/content/")
 	rpre1         = regexp.MustCompile("https://www.jianyu360.cn/article/bdprivate/")
+	rpre2         = regexp.MustCompile("https://www.jianyu360.cn/article/mailprivate/")
 	rsuf          = regexp.MustCompile("(.html).*")
 	AddSpiderCode = "sdxzbiddingsjzypc" // 新增bidding数据spider_code
 )
@@ -38,6 +40,7 @@ type RepairRule struct {
 	repairList    xweb.Mapper `xweb:"/service/jy/repair"`
 	searchID      xweb.Mapper `xweb:"/service/jy/searchID"`
 	searchJyurl   xweb.Mapper `xweb:"/service/jy/searchJyurl"`
+	searchSha     xweb.Mapper `xweb:"/service/jy/searchSha"`
 	repairEdit    xweb.Mapper `xweb:"/service/jy/edit"`
 	repairDelete  xweb.Mapper `xweb:"/service/jy/delete"`
 	repairSave    xweb.Mapper `xweb:"/service/jy/save"`
@@ -102,7 +105,6 @@ func (jy *RepairRule) RepairCreate() {
 //新增数据
 func (jy *RepairRule) RepairNewSave() {
 	defer qu.Catch()
-	log.Println("新增数据")
 	//mongo新增
 	request_data := GetPostForm(jy.Request)
 	updata := qu.ObjToMap(request_data["data"])
@@ -118,9 +120,10 @@ func (jy *RepairRule) RepairNewSave() {
 
 	//处理个别字段
 	(*updata)["_id"] = primitive.NewObjectID()
-	if hf := qu.ObjToString((*updata)["href"]); hf == "" {
+	if hf := qu.ObjToString((*updata)["href"]); hf == "" || hf == "#" {
 		var Url = "https://www.jianyu360.cn/article/content/%s.html"
 		(*updata)["href"] = fmt.Sprintf(Url, qu.CommonEncodeArticle("content", mongodb.BsonIdToSId((*updata)["_id"])))
+		(*updata)["competehref"] = "#"
 	}
 	// spider_code
 	(*updata)["spidercode"] = AddSpiderCode
@@ -146,14 +149,15 @@ func (jy *RepairRule) RepairNewSave() {
 	b := JYMgo.SaveByOriID(JyCollNameOne, *updata)
 	// 保存服务
 	href := qu.ObjToString((*updata)["href"])
-	db := HexToBigIntMod(href)
+	//db := HexToBigIntMod(href)
 	hashHref := HexText(href)
 	shaid := Sha(detail)
 	if !strings.Contains(href, "https://www.jianyu360.cn/") {
 		// 剑鱼链接 不需要存redis
-		PutRedis("title_repeat_fulljudgement", db, hashHref, mongodb.BsonIdToSId((*updata)["_id"]), -1) // 全量redis
+		//PutRedis("title_repeat_fulljudgement", db, hashHref, mongodb.BsonIdToSId((*updata)["_id"]), -1) // 全量redis
+		RedisClusterPut(RedisCluster, context.TODO(), hashHref, "", -1) // 全量redis
 	}
-	PutRedis("shaid", 0, shaid, mongodb.BsonIdToSId((*updata)["_id"]), 5184000) //	增量reids
+	RedisClusterPut(RedisCluster, context.TODO(), shaid, "", 365*86400) //	增量reids
 	//PutRedis("title_repeat_listpagehref", 0, href, "", 3600*24*30*24)                               // 列表页增量redis
 	if b {
 		log.Println("当前新增id:", mongodb.BsonIdToSId((*updata)["_id"]))
@@ -208,9 +212,10 @@ func (jy *RepairRule) RepairPub() {
 		}
 		if k == "publishtime" {
 			save[k] = qu.Int64All(v)
-		} else if k == "href" && v == "#" {
+		} else if k == "href" && strings.Trim(qu.ObjToString(v), " ") == "#" {
 			var Url = "https://www.jianyu360.cn/article/content/%s.html"
 			save["href"] = fmt.Sprintf(Url, qu.CommonEncodeArticle("content", mongodb.BsonIdToSId(save["_id"])))
+			save["competehref"] = "#"
 		} else if k == "detail" {
 			v = strings.Replace(qu.ObjToString(v), "&#60;", "<", -1)
 			v = strings.Replace(qu.ObjToString(v), "&#62;", ">", -1)
@@ -234,14 +239,18 @@ func (jy *RepairRule) RepairPub() {
 	if b {
 		// 保存服务
 		href := qu.ObjToString(save["href"])
-		db := HexToBigIntMod(href)
+		//db := HexToBigIntMod(href)
 		hashHref := HexText(href)
 		shaid := Sha(qu.ObjToString(save["detail"]))
 		if !strings.Contains(href, "https://www.jianyu360.cn/") {
 			// 剑鱼链接 不需要存redis
-			PutRedis("title_repeat_fulljudgement", db, hashHref, mongodb.BsonIdToSId(save["_id"]), -1)
+			//PutRedis("title_repeat_fulljudgement", db, hashHref, mongodb.BsonIdToSId(save["_id"]), -1)
+			r := RedisClusterPut(RedisCluster, context.TODO(), hashHref, "", -1)
+			qu.Debug(r.String())
+
 		}
-		PutRedis("shaid", 0, shaid, "", 5184000)
+		r := RedisClusterPut(RedisCluster, context.TODO(), shaid, "", 365*86400)
+		qu.Debug(r.String())
 		log.Println("当前新增id:", mongodb.BsonIdToSId(save["_id"]))
 		//日志记录
 		user := jy.GetSession("user").(map[string]interface{})
@@ -331,8 +340,9 @@ func (jy *RepairRule) RepairDelete() {
 			log.Println("delete es err:", err)
 		}
 
+		//  fmt.Sprintf("jypcdetail_%s_%s_%s_%v_%v_%v_%s", userId, stype, sid, isVip, isEntniche, isMember, nodeStr)
 		//删除redis 指定key
-		delName1 := RedisDelKey1 + "*_" + id
+		delName1 := RedisDelKey1 + "*_" + "*_" + id
 		redis.DelByCodePattern(RedisJYName, delName1)
 		//jyredis := redis.RedisPool[RedisJYName].Get()
 		//defer jyredis.Close()
@@ -528,7 +538,7 @@ func (jy *RepairRule) RepairSave() {
 			}
 
 			//删除redis 指定key
-			delName1 := RedisDelKey1 + "*_" + id
+			delName1 := RedisDelKey1 + "*_" + "*_" + id
 			redis.DelByCodePattern(RedisJYName, delName1)
 			//jyredis := redis.RedisPool[RedisJYName].Get()
 			//defer jyredis.Close()
@@ -619,6 +629,33 @@ func (jy *RepairRule) SearchID() {
 	}
 }
 
+func (jy *RepairRule) SearchSha() {
+	defer qu.Catch()
+	if jy.Method() == "POST" {
+		sha := jy.GetString("sha")
+		if sha != "" {
+			info, _ := JYMgo.Find("bidding", bson.M{"s_sha": sha}, nil, nil, false, -1, -1)
+			if len(*info) > 0 {
+				jy.ServeJson(map[string]interface{}{
+					"orgColl": JyCollNameOne,
+					"rep":     true,
+					"data":    *info,
+				})
+			} else {
+				jy.ServeJson(map[string]interface{}{
+					"rep": false,
+					"msg": "未查询到数据",
+				})
+			}
+		} else {
+			jy.ServeJson(map[string]interface{}{
+				"rep": false,
+				"msg": "参数错误",
+			})
+		}
+	}
+}
+
 func (jy *RepairRule) SearchJyurl() {
 	defer qu.Catch()
 	if jy.Method() == "POST" {
@@ -633,6 +670,10 @@ func (jy *RepairRule) SearchJyurl() {
 			jyurl1 := rpre1.ReplaceAllString(jyurl, "")
 			jyurl1 = rsuf.ReplaceAllString(jyurl1, "")
 			new_id = qu.CommonDecodeArticle("bdprivate", jyurl1)[0]
+		} else if strings.Contains(jyurl, "mailprivate") {
+			jyurl1 := rpre2.ReplaceAllString(jyurl, "")
+			jyurl1 = rsuf.ReplaceAllString(jyurl1, "")
+			new_id = qu.CommonDecodeArticle("mailprivate", jyurl1)[0]
 		}
 		qu.Debug(new_id)
 		if !mongodb.IsObjectIdHex(new_id) {
@@ -916,7 +957,7 @@ func ModifyData(tmp map[string]interface{}, user map[string]interface{}) (err ma
 	}
 
 	//删除redis 指定key
-	delName1 := RedisDelKey1 + "*_" + id
+	delName1 := RedisDelKey1 + "*_" + "*_" + id
 	redis.DelByCodePattern(RedisJYName, delName1)
 	//jyredis := redis.RedisPool[RedisJYName].Get()
 	//defer jyredis.Close()
@@ -1030,7 +1071,7 @@ func ModifyData1(tmp map[string]interface{}, user map[string]interface{}) (err m
 	udptask.Udpclient.WriteUdp(by, mu.OP_TYPE_DATA, addr)
 
 	//删除redis 指定key
-	delName1 := RedisDelKey1 + "*_" + id
+	delName1 := RedisDelKey1 + "*_" + "*_" + id
 	redis.DelByCodePattern(RedisJYName, delName1)
 	//jyredis := redis.RedisPool[RedisJYName].Get()
 	//defer jyredis.Close()

+ 1 - 1
src/util/clearHtml.go

@@ -77,7 +77,7 @@ func (c *Cut) ClearHtml(src string) string {
 						return r == 9 || r == 32
 					})
 					if utf8.RuneCountInString(strings.Trim(tmpstr, " ")) < utf8.RuneCountInString(strings.Trim(val, " ")) {
-						selection.SetText(strings.Trim(val, " "))
+						selection.SetAttr("title", strings.Trim(val, " "))
 					}
 				}
 			})

+ 6 - 0
src/util/config.go

@@ -1,6 +1,7 @@
 package util
 
 import (
+	red "github.com/go-redis/redis"
 	"mongodb"
 	qu "qfw/util"
 	"qfw/util/elastic"
@@ -30,6 +31,8 @@ var (
 	RedisDelKey4    string
 	RedisDelKey5    string
 	RedisSave       string // 新增数据保存信息
+
+	RedisCluster *red.ClusterClient
 )
 
 var (
@@ -105,6 +108,9 @@ func initJYRedis() {
 	RedisDelKey4 = qu.ObjToString(jyredis["redisdelkey4"])
 	RedisDelKey5 = qu.ObjToString(jyredis["redisdelkey5"])
 	InitRedis(qu.ObjToString(jyredis["redis_jy_save"]))
+
+	adds := qu.ObjArrToStringArr(Sysconfig["redis_cluster"].([]interface{}))
+	RedisCluster = NewClusterClient(adds)
 }
 
 func InitOther() {

+ 25 - 0
src/util/redisCluster.go

@@ -0,0 +1,25 @@
+package util
+
+import (
+	"context"
+	"github.com/go-redis/redis"
+	"time"
+)
+
+func NewClusterClient(adds []string) *redis.ClusterClient {
+	client := redis.NewClusterClient(&redis.ClusterOptions{
+		Addrs:        adds,
+		MaxRedirects: 5,
+		PoolSize:     10,
+		MaxRetries:   3,
+	})
+	return client
+}
+
+func Get(rdb *redis.ClusterClient, ctx context.Context, key string) *redis.StringCmd {
+	return rdb.Get(ctx, key)
+}
+
+func RedisClusterPut(rdb *redis.ClusterClient, ctx context.Context, key string, value interface{}, d time.Duration) *redis.StatusCmd {
+	return rdb.Set(ctx, key, value, d)
+}

+ 3 - 3
src/web/templates/repair/jy_pro_repair.html

@@ -106,13 +106,13 @@
     var proId = ""
     $(document).ready(function () {
         ttable = $('#dataTable').DataTable({
-            "paging": false,
+            "paging": true,
             "lengthChange": false,
             "searching": false,
             "ordering": false,
             "info": false,
-            "autoWidth": false,
-            "serverSide": false,
+            "autoWidth": true,
+            "serverSide": true,
             "language": {
                 "url": "/dist/js/dataTables.chinese.lang"
             },

+ 25 - 6
src/web/templates/repair/jy_repair.html

@@ -63,6 +63,8 @@
                             <img src="/picture/img_search.jpg" class="search-icon" onclick="idSearch()" />
                             <input class="j-input__inner" type="text" placeholder="请输入查询的剑鱼链接" id="jyurlSea">
                             <img src="/picture/img_search.jpg" class="search-icon" onclick="jyurlSearch()" />
+                            <input class="j-input__inner" type="text" placeholder="请输入查询的sha值" id="shaSea">
+                            <img src="/picture/img_search.jpg" class="search-icon" onclick="jyShaSearch()" />
                         </div>
 
                         <table id="dataTable" class="table table-bordered table-hover">
@@ -120,8 +122,8 @@
             },
             "columns": [
                 {"data": null,width:"5%"},
-                {"data": "_id",width:"10%"},
-                {"data": "title", width: "40%"},
+                {"data": "_id",width:"7%"},
+                {"data": "title", width: "25%"},
                 {"data": function (row) {
                         if (row.href) {
                             var str = "链接地址"
@@ -130,16 +132,16 @@
                         } else {
                             return ""
                         }
-                    }},
+                    },  width: "18%"},
                 {"data": curColl, render: function (val){
                         return curColl
-                    }},
-                {"data": "publishtime",width:"12%", render: function (val) {
+                    },  width: "7%"},
+                {"data": "publishtime",width:"18%", render: function (val) {
                         var dt = new Date()
                         dt.setTime(parseInt(val) * 1000);
                         return dt.format("yyyy-MM-dd")
                     }},
-                {"data": "_id", width:"15%",render: function (val, a, row, pos) {
+                {"data": "_id", width:"20%",render: function (val, a, row, pos) {
                         tmp = '<div>' +
                             '<a class="btn btn-sm btn-primary" href="/service/jy/edit?id='+val+'&coll='+curColl+'">编辑</a>'+
                             '&nbsp'+'&nbsp'+//href="/service/jy/edit?id='+val+'
@@ -186,6 +188,23 @@
         })
     }
 
+    function jyShaSearch() {
+        var search_name = $('#shaSea').val()
+        $.ajax({
+            url:"/service/jy/searchSha",
+            type:"post",
+            data:{"sha": search_name},
+            success:function(r){
+                if (r.rep) {
+                    curColl = "bidding"
+                    $('#dataTable').dataTable().fnClearTable();
+                    $('#dataTable').dataTable().fnAddData(r.data);
+                }else {
+                    showTip(r.msg)
+                }
+            }
+        })
+    }
 
     function del_repair(del_id,coll){
         showConfirm("确定删除?", function() {