|
@@ -5,7 +5,6 @@ import (
|
|
|
"gopkg.in/mgo.v2/bson"
|
|
|
"log"
|
|
|
qu "qfw/util"
|
|
|
- "reflect"
|
|
|
. "util"
|
|
|
)
|
|
|
|
|
@@ -32,11 +31,17 @@ func (jy *RepairRule) RepairList() {
|
|
|
func (jy *RepairRule) RepairEdit() {
|
|
|
defer qu.Catch()
|
|
|
id := jy.GetString("id")
|
|
|
- data, _ := JYMgo.FindById(JyCollName,id,"")
|
|
|
-
|
|
|
+ coll := jy.GetString("coll")
|
|
|
+ data, _ := JYMgo.FindById(coll,id,"")
|
|
|
//contenthtml detail 单独拿出来
|
|
|
+ detail:= qu.ObjToString((*data)["detail"])
|
|
|
+ contenthtml:= qu.ObjToString((*data)["contenthtml"])
|
|
|
+ jy.T["detail"] = map[string]string{"detail":detail}
|
|
|
+ jy.T["contenthtml"] = map[string]string{"contenthtml":contenthtml}
|
|
|
+ delete(*data,"detail")
|
|
|
+ delete(*data,"contenthtml")
|
|
|
jy.T["data"] = *data
|
|
|
-
|
|
|
+ jy.T["coll"] = coll
|
|
|
|
|
|
jy.Render("repair/jianyu_edit.html", &jy.T)
|
|
|
}
|
|
@@ -44,16 +49,33 @@ func (jy *RepairRule) RepairEdit() {
|
|
|
//删除
|
|
|
func (jy *RepairRule) RepairDelete() {
|
|
|
defer qu.Catch()
|
|
|
- //测试-待定
|
|
|
- jy.ServeJson(map[string]interface{}{
|
|
|
- "rep": true,
|
|
|
- })
|
|
|
- //_id := jy.GetString("_id")
|
|
|
- //set := bson.M{"_id":qu.StringTOBsonId(_id)}
|
|
|
- //b :=Mgo.Del("JyCollName",set)
|
|
|
- //jy.ServeJson(map[string]interface{}{
|
|
|
- // "rep": b,
|
|
|
- //})
|
|
|
+ id := jy.GetString("_id")
|
|
|
+ coll := jy.GetString("coll")
|
|
|
+ log.Println(id,coll)
|
|
|
+ set := bson.M{"_id":qu.StringTOBsonId(id)}
|
|
|
+ b :=JYMgo.Del(coll,set)
|
|
|
+
|
|
|
+ if !b {
|
|
|
+ jy.ServeJson(map[string]interface{}{
|
|
|
+ "rep": b,
|
|
|
+ })
|
|
|
+ }else {
|
|
|
+ //修改es
|
|
|
+ //client := elastic.GetEsConn()
|
|
|
+ //defer elastic.DestoryEsConn(client)
|
|
|
+ //_, err := client.Delete().Index(EsIndex).Type(EsType).Id(id).Refresh(true).Do()
|
|
|
+ //if err != nil {
|
|
|
+ // log.Println("delete es err:", err)
|
|
|
+ //}
|
|
|
+
|
|
|
+
|
|
|
+ //新增记录
|
|
|
+
|
|
|
+
|
|
|
+ jy.ServeJson(map[string]interface{}{
|
|
|
+ "rep": b,
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -62,17 +84,39 @@ func (jy *RepairRule) RepairSave() {
|
|
|
if jy.Method() == "POST" {
|
|
|
data := GetPostForm(jy.Request)
|
|
|
updata:=qu.ObjToMap(data["data"])
|
|
|
- log.Println(reflect.TypeOf(updata))
|
|
|
+ coll:=qu.ObjToString(data["coll"])
|
|
|
+ log.Println("当前更新的表:",coll)
|
|
|
id := qu.ObjToString((*updata)["_id"])
|
|
|
- log.Println("当前id",id)
|
|
|
query := bson.M{
|
|
|
"_id": qu.StringTOBsonId(id),
|
|
|
}
|
|
|
delete(*updata,"_id")
|
|
|
- rep := JYMgo.Update(JyCollName, query, bson.M{"$set": *updata}, false, true)
|
|
|
- jy.ServeJson(map[string]interface{}{
|
|
|
- "rep": rep,
|
|
|
- })
|
|
|
+
|
|
|
+ //修改mongo
|
|
|
+ rep := JYMgo.Update(coll, query, bson.M{"$set": *updata}, false, true)
|
|
|
+
|
|
|
+ if !rep {
|
|
|
+ jy.ServeJson(map[string]interface{}{
|
|
|
+ "rep": rep,
|
|
|
+ })
|
|
|
+ }else {
|
|
|
+ //修改es
|
|
|
+ //client := elastic.GetEsConn()
|
|
|
+ //defer elastic.DestoryEsConn(client)
|
|
|
+ //_, err := client.Update().Index(EsIndex).Type(EsType).Id(id).Doc(*updata).Refresh(true).Do()
|
|
|
+ //if err != nil {
|
|
|
+ // log.Println("update es err:", err)
|
|
|
+ //}
|
|
|
+
|
|
|
+
|
|
|
+ //新增记录
|
|
|
+
|
|
|
+
|
|
|
+ jy.ServeJson(map[string]interface{}{
|
|
|
+ "rep": rep,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -82,23 +126,35 @@ func (jy *RepairRule) SearchID() {
|
|
|
defer qu.Catch()
|
|
|
if jy.Method() == "POST" {
|
|
|
id := jy.GetString("_id")
|
|
|
- id = "5da3f2cba5cb26b9b7985f3f"
|
|
|
+
|
|
|
+ //先查one 没有在查two 5da3f2c5a5cb26b9b79847fc 5ea7d06c519cb1801b15385b
|
|
|
+ id = "5da3f2c5a5cb26b9b79847fc"
|
|
|
if !bson.IsObjectIdHex(id){
|
|
|
jy.ServeJson(map[string]interface{}{
|
|
|
"rep":false,
|
|
|
"msg":"id格式不正确",
|
|
|
})
|
|
|
}else {
|
|
|
- data, rep := JYMgo.Find(JyCollName, bson.M{"_id": qu.StringTOBsonId(id)}, nil, nil, false, -1, -1)
|
|
|
- if !rep ||len(*data)<=0 {
|
|
|
- jy.ServeJson(map[string]interface{}{
|
|
|
- "rep": false,
|
|
|
- "msg":"未查询到数据",
|
|
|
- })
|
|
|
+ data_one, rep_one := JYMgo.Find(JyCollNameOne, bson.M{"_id": qu.StringTOBsonId(id)}, nil, nil, false, -1, -1)
|
|
|
+ if !rep_one ||len(*data_one)<=0 {
|
|
|
+ data_two, rep_two := JYMgo.Find(JyCollNameTwo, bson.M{"_id": qu.StringTOBsonId(id)}, nil, nil, false, -1, -1)
|
|
|
+ if !rep_two ||len(*data_two)<=0 {
|
|
|
+ jy.ServeJson(map[string]interface{}{
|
|
|
+ "rep": false,
|
|
|
+ "msg":"未查询到数据",
|
|
|
+ })
|
|
|
+ }else {
|
|
|
+ jy.ServeJson(map[string]interface{}{
|
|
|
+ "orgColl":JyCollNameTwo,
|
|
|
+ "rep": rep_two,
|
|
|
+ "data": data_two,
|
|
|
+ })
|
|
|
+ }
|
|
|
}else {
|
|
|
jy.ServeJson(map[string]interface{}{
|
|
|
- "rep": rep,
|
|
|
- "data": data,
|
|
|
+ "orgColl":JyCollNameOne,
|
|
|
+ "rep": rep_one,
|
|
|
+ "data": data_one,
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -109,15 +165,28 @@ func (jy *RepairRule) SearchHref() {
|
|
|
defer qu.Catch()
|
|
|
if jy.Method() == "POST" {
|
|
|
href := jy.GetString("href")
|
|
|
- data, rep := JYMgo.Find(JyCollName, bson.M{"href": href}, nil, nil, false, -1, -1)
|
|
|
- if !rep ||len(*data)<=0 {
|
|
|
- jy.ServeJson(map[string]interface{}{
|
|
|
- "rep": false,
|
|
|
- })
|
|
|
+ href = "http://www.chinabidding.com/bidDetail/244286088.html"
|
|
|
+ //href = "http://rfq.ouyeelbuy.com/rfqNotice/bidListInfo?id=3d3e2154-c7a5-11e9-8d47-005056b17e0e"
|
|
|
+ data_one, rep_one := JYMgo.Find(JyCollNameOne, bson.M{"href": href}, 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)
|
|
|
+ if !rep_two ||len(*data_two)<=0 {
|
|
|
+ jy.ServeJson(map[string]interface{}{
|
|
|
+ "rep": false,
|
|
|
+ "msg":"未查询到数据",
|
|
|
+ })
|
|
|
+ }else {
|
|
|
+ jy.ServeJson(map[string]interface{}{
|
|
|
+ "orgColl":JyCollNameTwo,
|
|
|
+ "rep": rep_two,
|
|
|
+ "data": data_two,
|
|
|
+ })
|
|
|
+ }
|
|
|
}else {
|
|
|
jy.ServeJson(map[string]interface{}{
|
|
|
- "rep": rep,
|
|
|
- "data": data,
|
|
|
+ "orgColl":JyCollNameOne,
|
|
|
+ "rep": rep_one,
|
|
|
+ "data": data_one,
|
|
|
})
|
|
|
}
|
|
|
}
|