|
@@ -2,6 +2,7 @@ package service
|
|
|
|
|
|
import (
|
|
import (
|
|
"bytes"
|
|
"bytes"
|
|
|
|
+ "context"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"fmt"
|
|
"fmt"
|
|
"github.com/go-xweb/xweb"
|
|
"github.com/go-xweb/xweb"
|
|
@@ -29,6 +30,7 @@ import (
|
|
var (
|
|
var (
|
|
rpre = regexp.MustCompile("https://www.jianyu360.cn/article/content/")
|
|
rpre = regexp.MustCompile("https://www.jianyu360.cn/article/content/")
|
|
rpre1 = regexp.MustCompile("https://www.jianyu360.cn/article/bdprivate/")
|
|
rpre1 = regexp.MustCompile("https://www.jianyu360.cn/article/bdprivate/")
|
|
|
|
+ rpre2 = regexp.MustCompile("https://www.jianyu360.cn/article/mailprivate/")
|
|
rsuf = regexp.MustCompile("(.html).*")
|
|
rsuf = regexp.MustCompile("(.html).*")
|
|
AddSpiderCode = "sdxzbiddingsjzypc" // 新增bidding数据spider_code
|
|
AddSpiderCode = "sdxzbiddingsjzypc" // 新增bidding数据spider_code
|
|
)
|
|
)
|
|
@@ -38,6 +40,7 @@ type RepairRule struct {
|
|
repairList xweb.Mapper `xweb:"/service/jy/repair"`
|
|
repairList xweb.Mapper `xweb:"/service/jy/repair"`
|
|
searchID xweb.Mapper `xweb:"/service/jy/searchID"`
|
|
searchID xweb.Mapper `xweb:"/service/jy/searchID"`
|
|
searchJyurl xweb.Mapper `xweb:"/service/jy/searchJyurl"`
|
|
searchJyurl xweb.Mapper `xweb:"/service/jy/searchJyurl"`
|
|
|
|
+ searchSha xweb.Mapper `xweb:"/service/jy/searchSha"`
|
|
repairEdit xweb.Mapper `xweb:"/service/jy/edit"`
|
|
repairEdit xweb.Mapper `xweb:"/service/jy/edit"`
|
|
repairDelete xweb.Mapper `xweb:"/service/jy/delete"`
|
|
repairDelete xweb.Mapper `xweb:"/service/jy/delete"`
|
|
repairSave xweb.Mapper `xweb:"/service/jy/save"`
|
|
repairSave xweb.Mapper `xweb:"/service/jy/save"`
|
|
@@ -102,7 +105,6 @@ func (jy *RepairRule) RepairCreate() {
|
|
//新增数据
|
|
//新增数据
|
|
func (jy *RepairRule) RepairNewSave() {
|
|
func (jy *RepairRule) RepairNewSave() {
|
|
defer qu.Catch()
|
|
defer qu.Catch()
|
|
- log.Println("新增数据")
|
|
|
|
//mongo新增
|
|
//mongo新增
|
|
request_data := GetPostForm(jy.Request)
|
|
request_data := GetPostForm(jy.Request)
|
|
updata := qu.ObjToMap(request_data["data"])
|
|
updata := qu.ObjToMap(request_data["data"])
|
|
@@ -118,9 +120,10 @@ func (jy *RepairRule) RepairNewSave() {
|
|
|
|
|
|
//处理个别字段
|
|
//处理个别字段
|
|
(*updata)["_id"] = primitive.NewObjectID()
|
|
(*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"
|
|
var Url = "https://www.jianyu360.cn/article/content/%s.html"
|
|
(*updata)["href"] = fmt.Sprintf(Url, qu.CommonEncodeArticle("content", mongodb.BsonIdToSId((*updata)["_id"])))
|
|
(*updata)["href"] = fmt.Sprintf(Url, qu.CommonEncodeArticle("content", mongodb.BsonIdToSId((*updata)["_id"])))
|
|
|
|
+ (*updata)["competehref"] = "#"
|
|
}
|
|
}
|
|
// spider_code
|
|
// spider_code
|
|
(*updata)["spidercode"] = AddSpiderCode
|
|
(*updata)["spidercode"] = AddSpiderCode
|
|
@@ -146,14 +149,15 @@ func (jy *RepairRule) RepairNewSave() {
|
|
b := JYMgo.SaveByOriID(JyCollNameOne, *updata)
|
|
b := JYMgo.SaveByOriID(JyCollNameOne, *updata)
|
|
// 保存服务
|
|
// 保存服务
|
|
href := qu.ObjToString((*updata)["href"])
|
|
href := qu.ObjToString((*updata)["href"])
|
|
- db := HexToBigIntMod(href)
|
|
|
|
|
|
+ //db := HexToBigIntMod(href)
|
|
hashHref := HexText(href)
|
|
hashHref := HexText(href)
|
|
shaid := Sha(detail)
|
|
shaid := Sha(detail)
|
|
if !strings.Contains(href, "https://www.jianyu360.cn/") {
|
|
if !strings.Contains(href, "https://www.jianyu360.cn/") {
|
|
// 剑鱼链接 不需要存redis
|
|
// 剑鱼链接 不需要存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
|
|
//PutRedis("title_repeat_listpagehref", 0, href, "", 3600*24*30*24) // 列表页增量redis
|
|
if b {
|
|
if b {
|
|
log.Println("当前新增id:", mongodb.BsonIdToSId((*updata)["_id"]))
|
|
log.Println("当前新增id:", mongodb.BsonIdToSId((*updata)["_id"]))
|
|
@@ -208,9 +212,10 @@ func (jy *RepairRule) RepairPub() {
|
|
}
|
|
}
|
|
if k == "publishtime" {
|
|
if k == "publishtime" {
|
|
save[k] = qu.Int64All(v)
|
|
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"
|
|
var Url = "https://www.jianyu360.cn/article/content/%s.html"
|
|
save["href"] = fmt.Sprintf(Url, qu.CommonEncodeArticle("content", mongodb.BsonIdToSId(save["_id"])))
|
|
save["href"] = fmt.Sprintf(Url, qu.CommonEncodeArticle("content", mongodb.BsonIdToSId(save["_id"])))
|
|
|
|
+ save["competehref"] = "#"
|
|
} else if k == "detail" {
|
|
} else if k == "detail" {
|
|
v = strings.Replace(qu.ObjToString(v), "<", "<", -1)
|
|
v = strings.Replace(qu.ObjToString(v), "<", "<", -1)
|
|
v = strings.Replace(qu.ObjToString(v), ">", ">", -1)
|
|
v = strings.Replace(qu.ObjToString(v), ">", ">", -1)
|
|
@@ -234,14 +239,18 @@ func (jy *RepairRule) RepairPub() {
|
|
if b {
|
|
if b {
|
|
// 保存服务
|
|
// 保存服务
|
|
href := qu.ObjToString(save["href"])
|
|
href := qu.ObjToString(save["href"])
|
|
- db := HexToBigIntMod(href)
|
|
|
|
|
|
+ //db := HexToBigIntMod(href)
|
|
hashHref := HexText(href)
|
|
hashHref := HexText(href)
|
|
shaid := Sha(qu.ObjToString(save["detail"]))
|
|
shaid := Sha(qu.ObjToString(save["detail"]))
|
|
if !strings.Contains(href, "https://www.jianyu360.cn/") {
|
|
if !strings.Contains(href, "https://www.jianyu360.cn/") {
|
|
// 剑鱼链接 不需要存redis
|
|
// 剑鱼链接 不需要存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"]))
|
|
log.Println("当前新增id:", mongodb.BsonIdToSId(save["_id"]))
|
|
//日志记录
|
|
//日志记录
|
|
user := jy.GetSession("user").(map[string]interface{})
|
|
user := jy.GetSession("user").(map[string]interface{})
|
|
@@ -331,8 +340,9 @@ func (jy *RepairRule) RepairDelete() {
|
|
log.Println("delete es err:", err)
|
|
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
|
|
//删除redis 指定key
|
|
- delName1 := RedisDelKey1 + "*_" + id
|
|
|
|
|
|
+ delName1 := RedisDelKey1 + "*_" + "*_" + id
|
|
redis.DelByCodePattern(RedisJYName, delName1)
|
|
redis.DelByCodePattern(RedisJYName, delName1)
|
|
//jyredis := redis.RedisPool[RedisJYName].Get()
|
|
//jyredis := redis.RedisPool[RedisJYName].Get()
|
|
//defer jyredis.Close()
|
|
//defer jyredis.Close()
|
|
@@ -528,7 +538,7 @@ func (jy *RepairRule) RepairSave() {
|
|
}
|
|
}
|
|
|
|
|
|
//删除redis 指定key
|
|
//删除redis 指定key
|
|
- delName1 := RedisDelKey1 + "*_" + id
|
|
|
|
|
|
+ delName1 := RedisDelKey1 + "*_" + "*_" + id
|
|
redis.DelByCodePattern(RedisJYName, delName1)
|
|
redis.DelByCodePattern(RedisJYName, delName1)
|
|
//jyredis := redis.RedisPool[RedisJYName].Get()
|
|
//jyredis := redis.RedisPool[RedisJYName].Get()
|
|
//defer jyredis.Close()
|
|
//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() {
|
|
func (jy *RepairRule) SearchJyurl() {
|
|
defer qu.Catch()
|
|
defer qu.Catch()
|
|
if jy.Method() == "POST" {
|
|
if jy.Method() == "POST" {
|
|
@@ -633,6 +670,10 @@ func (jy *RepairRule) SearchJyurl() {
|
|
jyurl1 := rpre1.ReplaceAllString(jyurl, "")
|
|
jyurl1 := rpre1.ReplaceAllString(jyurl, "")
|
|
jyurl1 = rsuf.ReplaceAllString(jyurl1, "")
|
|
jyurl1 = rsuf.ReplaceAllString(jyurl1, "")
|
|
new_id = qu.CommonDecodeArticle("bdprivate", jyurl1)[0]
|
|
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)
|
|
qu.Debug(new_id)
|
|
if !mongodb.IsObjectIdHex(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
|
|
//删除redis 指定key
|
|
- delName1 := RedisDelKey1 + "*_" + id
|
|
|
|
|
|
+ delName1 := RedisDelKey1 + "*_" + "*_" + id
|
|
redis.DelByCodePattern(RedisJYName, delName1)
|
|
redis.DelByCodePattern(RedisJYName, delName1)
|
|
//jyredis := redis.RedisPool[RedisJYName].Get()
|
|
//jyredis := redis.RedisPool[RedisJYName].Get()
|
|
//defer jyredis.Close()
|
|
//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)
|
|
udptask.Udpclient.WriteUdp(by, mu.OP_TYPE_DATA, addr)
|
|
|
|
|
|
//删除redis 指定key
|
|
//删除redis 指定key
|
|
- delName1 := RedisDelKey1 + "*_" + id
|
|
|
|
|
|
+ delName1 := RedisDelKey1 + "*_" + "*_" + id
|
|
redis.DelByCodePattern(RedisJYName, delName1)
|
|
redis.DelByCodePattern(RedisJYName, delName1)
|
|
//jyredis := redis.RedisPool[RedisJYName].Get()
|
|
//jyredis := redis.RedisPool[RedisJYName].Get()
|
|
//defer jyredis.Close()
|
|
//defer jyredis.Close()
|