|
@@ -10,16 +10,23 @@ import (
|
|
|
qu "qfw/util"
|
|
|
"qfw/util/elastic"
|
|
|
"qfw/util/redis"
|
|
|
+ "regexp"
|
|
|
"time"
|
|
|
"udptask"
|
|
|
. "util"
|
|
|
)
|
|
|
|
|
|
+var (
|
|
|
+ rpre *regexp.Regexp = regexp.MustCompile("https://www.jianyu360.com/article/content/")
|
|
|
+ rsuf *regexp.Regexp = regexp.MustCompile("(.html).*")
|
|
|
+)
|
|
|
+
|
|
|
+
|
|
|
type RepairRule struct {
|
|
|
*xweb.Action
|
|
|
repairList xweb.Mapper `xweb:"/service/jianyu/repair"`
|
|
|
searchID xweb.Mapper `xweb:"/service/jianyu/searchID"`
|
|
|
- searchHref xweb.Mapper `xweb:"/service/jianyu/searchHref"`
|
|
|
+ searchJyurl xweb.Mapper `xweb:"/service/jianyu/searchJyurl"`
|
|
|
repairEdit xweb.Mapper `xweb:"/service/jianyu/edit"`
|
|
|
repairDelete xweb.Mapper `xweb:"/service/jianyu/delete"`
|
|
|
repairSave xweb.Mapper `xweb:"/service/jianyu/save"`
|
|
@@ -29,7 +36,6 @@ type RepairRule struct {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
func (jy *RepairRule) RepairList() {
|
|
|
defer qu.Catch()
|
|
|
jy.Render("repair/jianyu_repair.html")
|
|
@@ -43,8 +49,30 @@ func (jy *RepairRule) RepairNewSave() {
|
|
|
request_data := GetPostForm(jy.Request)
|
|
|
updata:=qu.ObjToMap(request_data["data"])
|
|
|
reasons := qu.ObjToString(request_data["reasons"])
|
|
|
- //tmp_json,_ :=json.Marshal(updata)
|
|
|
- //new_data:=qu.ObjToMap(string(tmp_json))
|
|
|
+
|
|
|
+ //处理个别字段
|
|
|
+ if val, ok := (*updata)["comeintime"];ok{
|
|
|
+ (*updata)["comeintime"] = qu.Int64All(val)
|
|
|
+ }else {
|
|
|
+ curtime := time.Now().Unix()
|
|
|
+ (*updata)["comeintime"] = curtime
|
|
|
+ }
|
|
|
+
|
|
|
+ if val, ok := (*updata)["publishtime"];ok{
|
|
|
+ (*updata)["publishtime"] = qu.Int64All(val)
|
|
|
+ }else {
|
|
|
+ pt:= int64(0)
|
|
|
+ (*updata)["publishtime"] = pt
|
|
|
+ }
|
|
|
+
|
|
|
+ if val, ok := (*updata)["infoformat"];ok{
|
|
|
+ (*updata)["infoformat"] = qu.IntAll(val)
|
|
|
+ }else {
|
|
|
+ (*updata)["infoformat"] = 1
|
|
|
+ }
|
|
|
+
|
|
|
+ (*updata)["extracttype"] = 0
|
|
|
+
|
|
|
delete(*updata,"_id")
|
|
|
cur_id:=JYMgo.Save(JyCollNameOne,*updata)
|
|
|
if cur_id!="" {
|
|
@@ -108,7 +136,16 @@ func (jy *RepairRule) RepairCreate() {
|
|
|
defer qu.Catch()
|
|
|
jy.T["detail"] = map[string]string{"detail":""}
|
|
|
jy.T["contenthtml"] = map[string]string{"contenthtml":""}
|
|
|
- jy.T["data"] = map[string]string{"title":"新增信息等等"}
|
|
|
+ jy.T["data"] = map[string]string{
|
|
|
+ "title":"",
|
|
|
+ "site":"",
|
|
|
+ "spidercode":"",
|
|
|
+ "href":"",
|
|
|
+ "channel":"",
|
|
|
+ "toptype":"",
|
|
|
+ "subtype":"",
|
|
|
+ "area":"",
|
|
|
+ }
|
|
|
jy.Render("repair/jianyu_create.html", &jy.T)
|
|
|
}
|
|
|
|
|
@@ -205,9 +242,37 @@ func (jy *RepairRule) RepairSave() {
|
|
|
reasons := qu.ObjToString(request_data["reasons"])
|
|
|
id := qu.ObjToString((*updata)["_id"])
|
|
|
old_data, _ := JYMgo.FindById(coll,id,"")//记录当前表的源数据
|
|
|
- //new_data:=*updata
|
|
|
- //tmp_json,_ :=json.Marshal(updata)
|
|
|
- //new_data:=qu.ObjToMap(string(tmp_json))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //处理个别字段
|
|
|
+ if val, ok := (*updata)["comeintime"];ok{
|
|
|
+ (*updata)["comeintime"] = qu.Int64All(val)
|
|
|
+ }else {
|
|
|
+ curtime := time.Now().Unix()
|
|
|
+ (*updata)["comeintime"] = curtime
|
|
|
+ }
|
|
|
+
|
|
|
+ if val, ok := (*updata)["publishtime"];ok{
|
|
|
+ (*updata)["publishtime"] = qu.Int64All(val)
|
|
|
+ }else {
|
|
|
+ pt:= int64(0)
|
|
|
+ (*updata)["publishtime"] = pt
|
|
|
+ }
|
|
|
+
|
|
|
+ if val, ok := (*updata)["infoformat"];ok{
|
|
|
+ (*updata)["infoformat"] = qu.IntAll(val)
|
|
|
+ }else {
|
|
|
+ (*updata)["infoformat"] = 1
|
|
|
+ }
|
|
|
+
|
|
|
+ (*updata)["extracttype"] = 0
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
query := bson.M{
|
|
|
"_id": qu.StringTOBsonId(id),
|
|
@@ -324,13 +389,19 @@ func (jy *RepairRule) SearchID() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (jy *RepairRule) SearchHref() {
|
|
|
+func (jy *RepairRule) SearchJyurl() {
|
|
|
defer qu.Catch()
|
|
|
if jy.Method() == "POST" {
|
|
|
- href := jy.GetString("href")
|
|
|
- data_one, rep_one := JYMgo.Find(JyCollNameOne, bson.M{"href": href}, nil, nil, false, -1, -1)
|
|
|
+
|
|
|
+ jyurl := jy.GetString("jyurl")
|
|
|
+ jyurl = rpre.ReplaceAllString(jyurl, "")
|
|
|
+ jyurl = rsuf.ReplaceAllString(jyurl, "")
|
|
|
+ new_id:=qu.CommonDecodeArticle("content", jyurl)[0]
|
|
|
+ log.Println(new_id)
|
|
|
+
|
|
|
+ data_one, rep_one := JYMgo.Find(JyCollNameOne, bson.M{"_id": qu.StringTOBsonId(new_id)}, nil, nil, false, -1, -1)
|
|
|
if !rep_one ||len(*data_one)<=0 {
|
|
|
- data_two, rep_two := JYMgo.Find(JyCollNameTwo, bson.M{"href": href}, nil, nil, false, -1, -1)
|
|
|
+ data_two, rep_two := JYMgo.Find(JyCollNameTwo, bson.M{"_id": qu.StringTOBsonId(new_id)}, nil, nil, false, -1, -1)
|
|
|
if !rep_two ||len(*data_two)<=0 {
|
|
|
jy.ServeJson(map[string]interface{}{
|
|
|
"rep": false,
|