Răsfoiți Sursa

修改objectId转换方法引用包

xuzhiheng 5 ani în urmă
părinte
comite
60a9c6bced

+ 7 - 6
src/front/front.go

@@ -1,6 +1,7 @@
 package front
 
 import (
+	mgoutil "qfw/mongodb"
 	qu "qfw/util"
 	"strconv"
 	"time"
@@ -35,7 +36,7 @@ type Front struct {
 	personalMenu   xweb.Mapper `xweb:"/front/personalMenu"`
 	//role
 	roleManager    xweb.Mapper `xweb:"/front/role"`             //角色权限管理
-	roleNew		   xweb.Mapper `xweb:"/front/role/save"`		   //新增角色
+	roleNew        xweb.Mapper `xweb:"/front/role/save"`        //新增角色
 	roleEdit       xweb.Mapper `xweb:"/front/role/edit/(.*)"`   //角色权限查看
 	roleFirst      xweb.Mapper `xweb:"/front/role/first"`       //一级权限的查看
 	roleSecond     xweb.Mapper `xweb:"/front/role/second"`      //二级权限的查看
@@ -65,7 +66,7 @@ func (f *Front) Login() {
 				"role":  (*user)["s_role"],
 				"pwd":   password,
 				"email": email,
-				"id":    qu.BsonIdToSId((*user)["_id"]),
+				"id":    mgoutil.BsonIdToSId((*user)["_id"]),
 			})
 			UserMenu[email] = GetUserMenu(qu.ObjToString((*user)["s_role"]))
 		}
@@ -108,7 +109,7 @@ func (f *Front) User() {
 	defer qu.Catch()
 	role, _ := Mgo.Find("role", nil, nil, nil, false, -1, -1)
 	roleMap := make(map[string]string)
-	for _, v := range *role{
+	for _, v := range *role {
 		level := qu.ObjToString(v["level"])
 		if level != "" {
 			roleMap[level] = qu.ObjToString(v["name"])
@@ -138,7 +139,7 @@ func (f *Front) UserDel() {
 	defer qu.Catch()
 	_id := f.GetString("_id")
 	query := bson.M{
-		"_id": qu.StringTOBsonId(_id),
+		"_id": mgoutil.StringTOBsonId(_id),
 	}
 	b := Mgo.Del("user", query)
 	f.ServeJson(map[string]interface{}{
@@ -162,7 +163,7 @@ func (f *Front) UserSave() {
 		},
 	}
 	query := bson.M{
-		"_id": qu.StringTOBsonId(_id),
+		"_id": mgoutil.StringTOBsonId(_id),
 	}
 	if _id == "" {
 		query = bson.M{
@@ -198,7 +199,7 @@ func GetUserMenu(role string) []map[string]interface{} {
 		_id := d["_id"]
 		maps = map[string]interface{}{
 			"delete": false,
-			"s_pid":  qu.BsonIdToSId(_id),
+			"s_pid":  mgoutil.BsonIdToSId(_id),
 		}
 		if role != "0" {
 			maps["role."+role] = true

+ 5 - 4
src/front/menu.go

@@ -4,6 +4,7 @@ import (
 	qu "qfw/util"
 	"time"
 
+	mgoutil "qfw/mongodb"
 	. "util"
 
 	"gopkg.in/mgo.v2/bson"
@@ -28,7 +29,7 @@ func (f *Front) MenuSave() {
 	css := f.GetString("css")
 	id := f.GetString("id")
 	query := bson.M{
-		"_id":    qu.StringTOBsonId(id),
+		"_id":    mgoutil.StringTOBsonId(id),
 		"delete": false,
 	}
 	if id == "" {
@@ -58,7 +59,7 @@ func (f *Front) MenuDel() {
 	defer qu.Catch()
 	_id := f.GetString("_id")
 	query := bson.M{
-		"_id": qu.StringTOBsonId(_id),
+		"_id": mgoutil.StringTOBsonId(_id),
 	}
 	set := bson.M{
 		"$set": bson.M{
@@ -96,7 +97,7 @@ func (f *Front) MenuSecondSave() {
 	id := f.GetString("id")
 	pid := f.GetString("pid")
 	query := bson.M{
-		"_id":    qu.StringTOBsonId(id),
+		"_id":    mgoutil.StringTOBsonId(id),
 		"delete": false,
 	}
 	if id == "" {
@@ -127,7 +128,7 @@ func (f *Front) MenuSecondDel() {
 	defer qu.Catch()
 	_id := f.GetString("_id")
 	query := bson.M{
-		"_id": qu.StringTOBsonId(_id),
+		"_id": mgoutil.StringTOBsonId(_id),
 	}
 	set := bson.M{
 		"$set": bson.M{

+ 7 - 7
src/front/role.go

@@ -2,8 +2,8 @@ package front
 
 import (
 	"encoding/json"
+	mgoutil "qfw/mongodb"
 	qu "qfw/util"
-
 	. "util"
 
 	"gopkg.in/mgo.v2/bson"
@@ -12,11 +12,11 @@ import (
 func (f *Front) RoleManager() {
 	defer qu.Catch()
 	if f.Method() == "POST" {
-		data, _ := Mgo.Find("role", nil, nil, nil, false, -1, -1);
+		data, _ := Mgo.Find("role", nil, nil, nil, false, -1, -1)
 		f.ServeJson(map[string]interface{}{
 			"data": data,
 		})
-	}else {
+	} else {
 		f.Render("com/role.html")
 	}
 }
@@ -30,17 +30,17 @@ func (f *Front) RoleNew() {
 		if _id != "" {
 			set := bson.M{
 				"$set": bson.M{
-					"name": name,
+					"name":  name,
 					"level": level,
 				},
 			}
-			bol := Mgo.UpdateById("role", qu.StringTOBsonId(_id), set)
+			bol := Mgo.UpdateById("role", mgoutil.StringTOBsonId(_id), set)
 			if bol {
 				f.ServeJson(map[string]interface{}{
 					"rep": true,
 				})
 			}
-		}else {
+		} else {
 			_id := Mgo.Save("role", bson.M{"name": name, "level": level})
 			if _id != "" {
 				f.ServeJson(map[string]interface{}{
@@ -48,7 +48,7 @@ func (f *Front) RoleNew() {
 				})
 			}
 		}
-	}else {
+	} else {
 		f.Render("com/role.html")
 	}
 }

+ 5 - 4
src/history/historytask.go

@@ -2,6 +2,7 @@ package history
 
 import (
 	"log"
+	mgoutil "qfw/mongodb"
 	qu "qfw/util"
 	"strings"
 	. "util"
@@ -19,10 +20,10 @@ func (this *HistoryData) HistoryTask(history_id string) {
 	log.Println("开始历史任务...")
 	go UpdateHistoryState(1, history_id, 0)
 	//加载一个客户
-	customer, _ := Mgo.Find("historylog", map[string]interface{}{"_id": qu.StringTOBsonId(history_id)}, nil, nil, false, -1, -1)
+	customer, _ := Mgo.Find("historylog", map[string]interface{}{"_id": mgoutil.StringTOBsonId(history_id)}, nil, nil, false, -1, -1)
 	if len(*customer) == 1 {
 		c := (*customer)[0]
-		customerId := qu.BsonIdToSId(c["_id"])
+		customerId := mgoutil.BsonIdToSId(c["_id"])
 		customer_name := qu.ObjToString(c["s_name"]) //客户名称
 		appId := qu.ObjToString(c["s_appid"])        //appid
 		extends := qu.ObjToString(c["s_extends"])    //扩展信息
@@ -82,7 +83,7 @@ func (this *HistoryData) HistoryList() {
 
 func UpdateHistoryState(state int, history_id string, count int) {
 	if state == 2 {
-		Mgo.Update("historylog", map[string]interface{}{"_id": qu.StringTOBsonId(history_id)}, map[string]interface{}{
+		Mgo.Update("historylog", map[string]interface{}{"_id": mgoutil.StringTOBsonId(history_id)}, map[string]interface{}{
 			"$set": map[string]interface{}{
 				"state":        state,
 				"result_count": count,
@@ -90,7 +91,7 @@ func UpdateHistoryState(state int, history_id string, count int) {
 		}, false, false)
 		return
 	}
-	Mgo.Update("historylog", map[string]interface{}{"_id": qu.StringTOBsonId(history_id)}, map[string]interface{}{
+	Mgo.Update("historylog", map[string]interface{}{"_id": mgoutil.StringTOBsonId(history_id)}, map[string]interface{}{
 		"$set": map[string]interface{}{
 			"state": state,
 		},

+ 3 - 2
src/history/task.go

@@ -11,6 +11,7 @@ import (
 
 	"gopkg.in/mgo.v2/bson"
 
+	mgoutil "qfw/mongodb"
 	. "util"
 
 	"go.mongodb.org/mongo-driver/bson/primitive"
@@ -27,7 +28,7 @@ func (c *Customer) GetTagRules(tagRules []map[string]interface{}) {
 			TR := &TagRule{}
 			TR.Fields = make(map[string]interface{})
 			TR.DepartRuleIds = make(map[string]bool)
-			id := qu.BsonIdToSId(tr["_id"])
+			id := mgoutil.BsonIdToSId(tr["_id"])
 			name := qu.ObjToString(tr["s_name"])
 			TR.ID = id
 			TR.Name = name
@@ -430,7 +431,7 @@ func (d *Department) GetSearchRules(cid, stype string, idRange bson.M, searchRul
 			SR := &SearchRule{}
 			SR.Fields = make(map[string]interface{})
 
-			id := qu.BsonIdToSId(sr["_id"])
+			id := mgoutil.BsonIdToSId(sr["_id"])
 			name := qu.ObjToString(sr["s_name"])
 			SR.ID = id
 			SR.Name = name

+ 43 - 41
src/service/customer_service.go

@@ -11,6 +11,8 @@ import (
 	"time"
 	. "util"
 
+	mgoutil "qfw/mongodb"
+
 	"github.com/go-xweb/xweb"
 	"github.com/lauyoume/gopinyin"
 	"gopkg.in/mgo.v2/bson"
@@ -107,10 +109,10 @@ func (c *Customer) CustomerEdit() {
 	defer qu.Catch()
 	id := c.GetString("id")
 	query := bson.M{}
-	query["_id"] = qu.StringTOBsonId(id)
+	query["_id"] = mgoutil.StringTOBsonId(id)
 	data, _ := Mgo.FindOneByField("cuser", query, `{}`)
 	depart, _ := Mgo.Find("cuserdepart", bson.M{"s_userid": id, "b_delete": false}, nil, nil, false, -1, -1)
-	(*data)["_id"] = qu.BsonIdToSId((*data)["_id"])
+	(*data)["_id"] = mgoutil.BsonIdToSId((*data)["_id"])
 	if (*data)["i_state"] == 1 {
 		tagRule, _ := Mgo.Find("eusertagrule", bson.M{"s_userid": id, "b_delete": false}, nil, nil, false, -1, -1)
 		c.T["tagrule"] = *tagRule
@@ -124,10 +126,10 @@ func (c *Customer) CustomerEuser() {
 	defer qu.Catch()
 	id := c.GetString("id")
 	query := bson.M{}
-	query["_id"] = qu.StringTOBsonId(id)
+	query["_id"] = mgoutil.StringTOBsonId(id)
 	data, _ := Mgo.FindOneByField("euser", query, `{}`)
 	depart, _ := Mgo.Find("euserdepart", bson.M{"s_userid": id, "b_delete": false}, nil, nil, false, -1, -1)
-	(*data)["_id"] = qu.BsonIdToSId((*data)["_id"])
+	(*data)["_id"] = mgoutil.BsonIdToSId((*data)["_id"])
 	if (*data)["i_state"] == 1 {
 		tagRule, _ := Mgo.Find("eusertagrule", bson.M{"s_userid": id, "b_delete": false}, nil, nil, false, -1, -1)
 		c.T["tagrule"] = *tagRule
@@ -173,7 +175,7 @@ func (c *Customer) CustomerSave() {
 			}
 		} else {
 			query := bson.M{
-				"_id": qu.StringTOBsonId(id),
+				"_id": mgoutil.StringTOBsonId(id),
 			}
 			rep = Mgo.Update("cuser", query, bson.M{"$set": data}, false, false)
 		}
@@ -296,7 +298,7 @@ func (c *Customer) CuserToEuser() {
 			"i_state":         1,
 		},
 	}
-	b := Mgo.Update("cuser", bson.M{"_id": qu.StringTOBsonId(_id)}, set, false, false)
+	b := Mgo.Update("cuser", bson.M{"_id": mgoutil.StringTOBsonId(_id)}, set, false, false)
 	if !b {
 		c.ServeJson(map[string]interface{}{
 			"rep": b,
@@ -304,7 +306,7 @@ func (c *Customer) CuserToEuser() {
 		return
 	}
 	//2、复制信息(部门、规则)
-	b = Mgo.Update("euser", bson.M{"_id": qu.StringTOBsonId(_id)}, cuser, true, false)
+	b = Mgo.Update("euser", bson.M{"_id": mgoutil.StringTOBsonId(_id)}, cuser, true, false)
 	if !b {
 		c.ServeJson(map[string]interface{}{
 			"rep": b,
@@ -374,14 +376,14 @@ func (c *Customer) SynEuser() {
 			"i_lastsynctime": nowTime,
 		},
 	}
-	b := Mgo.Update("cuser", bson.M{"_id": qu.StringTOBsonId(_id)}, set, false, false)
+	b := Mgo.Update("cuser", bson.M{"_id": mgoutil.StringTOBsonId(_id)}, set, false, false)
 	if !b {
 		c.ServeJson(map[string]interface{}{
 			"rep": b,
 		})
 		return
 	}
-	b = Mgo.Update("euser", bson.M{"_id": qu.StringTOBsonId(_id)}, cuser, true, false)
+	b = Mgo.Update("euser", bson.M{"_id": mgoutil.StringTOBsonId(_id)}, cuser, true, false)
 	if !b {
 		c.ServeJson(map[string]interface{}{
 			"rep": b,
@@ -552,7 +554,7 @@ func (c *Customer) CuserRuleCreate() {
 			}
 		} else {
 			query := bson.M{
-				"_id": qu.StringTOBsonId(id),
+				"_id": mgoutil.StringTOBsonId(id),
 			}
 			rep = Mgo.Update("cuserdepartrule", query, bson.M{"$set": data}, false, false)
 		}
@@ -584,9 +586,9 @@ func (c *Customer) CuserRuleCreate() {
 func (c *Customer) CuserRuleEdit() {
 	defer qu.Catch()
 	id := c.GetString("id")
-	query := bson.M{"_id": qu.StringTOBsonId(id)}
+	query := bson.M{"_id": mgoutil.StringTOBsonId(id)}
 	data, _ := Mgo.FindOneByField("cuserdepartrule", query, `{}`)
-	(*data)["id"] = qu.BsonIdToSId((*data)["_id"])
+	(*data)["id"] = mgoutil.BsonIdToSId((*data)["_id"])
 	c.T["cid"] = (*data)["s_userid"]
 	c.T["ids"] = qu.ObjToString((*data)["s_departid"]) + "," + qu.ObjToString((*data)["s_userid"])
 	c.T["data"] = *data
@@ -606,9 +608,9 @@ func (c *Customer) CuserRuleEdit() {
 func (c *Customer) EuserRule1() {
 	defer qu.Catch()
 	id := c.GetString("id")
-	query := bson.M{"_id": qu.StringTOBsonId(id)}
+	query := bson.M{"_id": mgoutil.StringTOBsonId(id)}
 	data, _ := Mgo.FindOneByField("euserdepartrule", query, `{}`)
-	(*data)["id"] = qu.BsonIdToSId((*data)["_id"])
+	(*data)["id"] = mgoutil.BsonIdToSId((*data)["_id"])
 	c.T["cid"] = (*data)["s_userid"]
 	c.T["ids"] = qu.ObjToString((*data)["s_departid"]) + "," + qu.ObjToString((*data)["s_userid"])
 	c.T["data"] = *data
@@ -694,7 +696,7 @@ func (c *Customer) EuserTagEdit() {
 				_id = Mgo.Save("eusertagrule", data)
 			} else {
 				query := bson.M{
-					"_id": qu.StringTOBsonId(_id),
+					"_id": mgoutil.StringTOBsonId(_id),
 				}
 				rep = Mgo.Update("eusertagrule", query, bson.M{"$set": data}, false, false)
 			}
@@ -708,7 +710,7 @@ func (c *Customer) EuserTagEdit() {
 				rep = AddHistoryLogTag(data, false, _id)
 			} else {
 				query := bson.M{
-					"_id": qu.StringTOBsonId(_id),
+					"_id": mgoutil.StringTOBsonId(_id),
 				}
 				reps := Mgo.Update("eusertagrule", query, bson.M{"$set": data}, false, false)
 				if reps {
@@ -752,7 +754,7 @@ func (c *Customer) EuserTag() {
 			_id = Mgo.Save("eusertagrule", data)
 		} else {
 			query := bson.M{
-				"_id": qu.StringTOBsonId(_id),
+				"_id": mgoutil.StringTOBsonId(_id),
 			}
 			rep = Mgo.Update("eusertagrule", query, bson.M{"$set": data}, false, false)
 		}
@@ -881,13 +883,13 @@ func (c *Customer) CustomerHistory() {
 	id := c.GetString("id")
 	user := c.GetSession("user").(map[string]interface{})
 	query := bson.M{}
-	query["_id"] = qu.StringTOBsonId(id)
+	query["_id"] = mgoutil.StringTOBsonId(id)
 
 	hid := c.GetString("hid")
 	history_id := ""
 	if hid != "" {
 		history_id = hid
-		hData, ok := Mgo.FindOne("historylog", bson.M{"_id": qu.StringTOBsonId(history_id)})
+		hData, ok := Mgo.FindOne("historylog", bson.M{"_id": mgoutil.StringTOBsonId(history_id)})
 		if ok && hData != nil && len(*hData) > 0 {
 			c.T["history_rule"] = (*hData)["dep_rules"]
 			c.T["tagrule"] = (*hData)["tag_rules"]
@@ -924,7 +926,7 @@ func (c *Customer) CustomerAllRule() {
 	}
 	inc_query := bson.M{
 		"user_id": customerId,
-		"_id":     qu.StringTOBsonId(history_id),
+		"_id":     mgoutil.StringTOBsonId(history_id),
 	}
 	//获取新增历史规则
 	inc_rules := []map[string]interface{}{}
@@ -985,7 +987,7 @@ func (c *Customer) SaveHistoryRule() {
 	// userid := c.GetString("userid")
 	if history_id != "" {
 		user_history, _ := Mgo.FindOne("historylog", map[string]interface{}{
-			"_id": qu.StringTOBsonId(history_id),
+			"_id": mgoutil.StringTOBsonId(history_id),
 		})
 		if *user_history != nil && user_history != nil {
 			//获取私有标签
@@ -997,21 +999,21 @@ func (c *Customer) SaveHistoryRule() {
 				if len(dep_rules) > 0 {
 					for _, r := range dep_rules {
 						dep_new_rules = append(dep_new_rules, r)
-						ruleMap[qu.BsonIdToSId(r["_id"])] = true
+						ruleMap[mgoutil.BsonIdToSId(r["_id"])] = true
 					}
 				}
 				rules_id_list := strings.Split(rules_id, ",")
 				for _, rule := range rules_id_list {
 					if !ruleMap[rule] {
 						query := bson.M{
-							"_id":      qu.StringTOBsonId(rule),
+							"_id":      mgoutil.StringTOBsonId(rule),
 							"b_delete": false,
 						}
 						res, _ := Mgo.FindOne("euserdepartrule", query)
 						if res != nil && len(*res) != 0 {
 							//获取规则所属部门信息
 							department_info, _ := Mgo.FindOne("euserdepart", map[string]interface{}{
-								"_id":      qu.StringTOBsonId((*res)["s_departid"].(string)),
+								"_id":      mgoutil.StringTOBsonId((*res)["s_departid"].(string)),
 								"b_delete": false,
 							})
 							(*res)["is_new"] = false
@@ -1028,7 +1030,7 @@ func (c *Customer) SaveHistoryRule() {
 					},
 				}
 				ok := Mgo.Update("historylog", map[string]interface{}{
-					"_id": qu.StringTOBsonId(history_id),
+					"_id": mgoutil.StringTOBsonId(history_id),
 				}, set, false, false)
 				log.Println("ok", ok)
 				c.ServeJson(map[string]interface{}{
@@ -1040,14 +1042,14 @@ func (c *Customer) SaveHistoryRule() {
 				dep_rules := []map[string]interface{}{}
 				for _, rule := range rules_id_list {
 					query := bson.M{
-						"_id":      qu.StringTOBsonId(rule),
+						"_id":      mgoutil.StringTOBsonId(rule),
 						"b_delete": false,
 					}
 					res, _ := Mgo.FindOne("euserdepartrule", query)
 					if res != nil && *res != nil {
 						//获取规则所属部门信息
 						department_info, _ := Mgo.FindOne("euserdepart", map[string]interface{}{
-							"_id":      qu.StringTOBsonId((*res)["s_departid"].(string)),
+							"_id":      mgoutil.StringTOBsonId((*res)["s_departid"].(string)),
 							"b_delete": false,
 						})
 						(*res)["is_new"] = false
@@ -1063,7 +1065,7 @@ func (c *Customer) SaveHistoryRule() {
 					},
 				}
 				isupdata := Mgo.Update("historylog", map[string]interface{}{
-					"_id": qu.StringTOBsonId(history_id),
+					"_id": mgoutil.StringTOBsonId(history_id),
 				}, set, false, false)
 				c.ServeJson(map[string]interface{}{
 					"status": isupdata,
@@ -1116,7 +1118,7 @@ func (c *Customer) HistoryRuleCreate() {
 				}
 				s_id = Mgo.Save("euserdepart", d_data)
 			} else {
-				s_id = qu.BsonIdToSId((*dData)["_id"])
+				s_id = mgoutil.BsonIdToSId((*dData)["_id"])
 			}
 			data["s_userid"] = user_id
 			data["s_departid"] = s_id
@@ -1135,7 +1137,7 @@ func (c *Customer) HistoryRuleCreate() {
 			}
 		} else {
 			query := bson.M{
-				"_id": qu.StringTOBsonId(id),
+				"_id": mgoutil.StringTOBsonId(id),
 			}
 			reps := Mgo.Update("euserdepartrule", query, bson.M{"$set": data}, false, false)
 			if reps {
@@ -1179,14 +1181,14 @@ func (c *Customer) HistoryTagAssociated() {
 
 	if userid != "" {
 		user_info, _ := Mgo.FindOne("historylog", map[string]interface{}{
-			"_id": qu.StringTOBsonId(hid),
+			"_id": mgoutil.StringTOBsonId(hid),
 		})
 		if user_info != nil && *user_info != nil {
 			tagrules := (*user_info)["tag_rules"]
 			if tagrules != nil {
 				tagrulesArr := qu.ObjArrToMapArr(tagrules.([]interface{}))
 				for _, m := range tagrulesArr {
-					if rule_id == qu.BsonIdToSId(m["_id"]) {
+					if rule_id == mgoutil.BsonIdToSId(m["_id"]) {
 						m["o_departruleids"] = tags
 					}
 				}
@@ -1196,7 +1198,7 @@ func (c *Customer) HistoryTagAssociated() {
 					},
 				}
 				is_updata := Mgo.Update("historylog", map[string]interface{}{
-					"_id": qu.StringTOBsonId(hid),
+					"_id": mgoutil.StringTOBsonId(hid),
 				}, set, false, false)
 				c.ServeJson(map[string]interface{}{
 					"rep": is_updata,
@@ -1212,7 +1214,7 @@ func getTserTag(userid string) *[]map[string]interface{} {
 }
 
 func AddHistoryLogDep(ruleData map[string]interface{}, isUpdate bool, id string) bool {
-	history_id := qu.StringTOBsonId(ruleData["history_id"].(string))
+	history_id := mgoutil.StringTOBsonId(ruleData["history_id"].(string))
 	hData, ok := Mgo.FindOne("historylog", bson.M{"_id": history_id})
 	if ok && hData != nil && *hData != nil && len(*hData) > 0 {
 		dep_rules := []map[string]interface{}{}
@@ -1222,7 +1224,7 @@ func AddHistoryLogDep(ruleData map[string]interface{}, isUpdate bool, id string)
 		ruleData["is_new"] = true
 		if isUpdate {
 			for k, v := range dep_rules {
-				if qu.BsonIdToSId(v["_id"]) == id {
+				if mgoutil.BsonIdToSId(v["_id"]) == id {
 					dep_rules[k] = ruleData
 				}
 			}
@@ -1237,7 +1239,7 @@ func AddHistoryLogDep(ruleData map[string]interface{}, isUpdate bool, id string)
 }
 
 func AddHistoryLogTag(ruleData map[string]interface{}, isUpdate bool, id string) bool {
-	history_id := qu.StringTOBsonId(qu.ObjToString(ruleData["hid"]))
+	history_id := mgoutil.StringTOBsonId(qu.ObjToString(ruleData["hid"]))
 	hData, ok := Mgo.FindOne("historylog", bson.M{"_id": history_id})
 	if ok && hData != nil && *hData != nil && len(*hData) > 0 {
 		tag_rules := []map[string]interface{}{}
@@ -1247,7 +1249,7 @@ func AddHistoryLogTag(ruleData map[string]interface{}, isUpdate bool, id string)
 		ruleData["is_new"] = true
 		if isUpdate {
 			for k, v := range tag_rules {
-				if qu.BsonIdToSId(v["_id"]) == id {
+				if mgoutil.BsonIdToSId(v["_id"]) == id {
 					tag_rules[k] = ruleData
 				}
 			}
@@ -1267,18 +1269,18 @@ func (c *Customer) HistoryTagDel() {
 	// userid := c.GetString("userid")
 	tagid := c.GetString("tagid")
 	hid := c.GetString("hid")
-	user_info, _ := Mgo.FindOne("historylog", bson.M{"_id": qu.StringTOBsonId(hid)})
+	user_info, _ := Mgo.FindOne("historylog", bson.M{"_id": mgoutil.StringTOBsonId(hid)})
 	if user_info != nil && *user_info != nil {
 		if (*user_info)["tag_rules"] != nil {
 			user_tag_rules := qu.ObjArrToMapArr((*user_info)["tag_rules"].([]interface{}))
 			ruleMap := map[string]bool{tagid: true}
 			ruleArr := []map[string]interface{}{}
 			for _, m := range user_tag_rules {
-				if !ruleMap[qu.BsonIdToSId(m["_id"])] {
+				if !ruleMap[mgoutil.BsonIdToSId(m["_id"])] {
 					ruleArr = append(ruleArr, m)
 				}
 			}
-			is_updata := Mgo.Update("historylog", bson.M{"_id": qu.StringTOBsonId(hid)}, bson.M{"$set": bson.M{"tag_rules": ruleArr}}, false, false)
+			is_updata := Mgo.Update("historylog", bson.M{"_id": mgoutil.StringTOBsonId(hid)}, bson.M{"$set": bson.M{"tag_rules": ruleArr}}, false, false)
 			c.ServeJson(map[string]interface{}{
 				"rep": is_updata,
 			})
@@ -1338,7 +1340,7 @@ func (c *Customer) Addhistoryrule() {
 					"i_updatetime":   c.GetString("i_updatetime"),
 				},
 			}
-			isupdata := Mgo.UpdateById("historylog", qu.StringTOBsonId(his_id), set)
+			isupdata := Mgo.UpdateById("historylog", mgoutil.StringTOBsonId(his_id), set)
 			if isupdata {
 				c.ServeJson(map[string]interface{}{
 					"history_id": his_id,

+ 3 - 1
src/service/feedback_service.go

@@ -6,6 +6,8 @@ import (
 
 	. "util"
 
+	mgoutil "qfw/mongodb"
+
 	"github.com/go-xweb/xweb"
 	"gopkg.in/mgo.v2/bson"
 )
@@ -81,7 +83,7 @@ func (f *Feedback) FeedbackDetail() {
 	} else {
 		id := f.GetString("_id")
 		query := bson.M{
-			"_id": qu.StringTOBsonId(id),
+			"_id": mgoutil.StringTOBsonId(id),
 		}
 		data, _ := Mgo.FindOne("feedback", query)
 		f.T["id"] = id

+ 8 - 11
src/web/templates/private/customer_history.html

@@ -264,11 +264,8 @@
                 $(".selected-rules").html(html);
                 for (var i=0;i<selected_rules.length;i++){
                     html += '<tr><td>'+num+'</td><td>'+selected_rules[i].department_name+'</td><td>'+selected_rules[i].rule_name+'</td><td>'+selected_rules[i].update_time+'</td>'+'<td>'+selected_rules[i].department_status+'</td>'+'<td>'+selected_rules[i].rule_status+'</td>';
-                    if (selected_rules[i].isinc == "true"){
-                        html += '<td><span onclick="del_selected_rule(\''+selected_rules[i].rule_id+'\')">删除</span></td>'
-                    }else{
-                        html += "<td></td>"
-                    }
+                    // if (selected_rules[i].isinc == "true"){
+                    html += '<td><button class="btn btn-danger" onclick="del_selected_rule(\''+selected_rules[i].rule_id+'\')">删除</button></td>'
                     num++
                 }
             }
@@ -646,7 +643,7 @@
                     selected_rule.update_time = $(this).find('td').eq(4).text();
                     selected_rule.department_status = $(this).find('td').eq(5).text();
                     selected_rule.rule_status = $(this).find('td').eq(6).text();
-                    selected_rule.isinc = $(this).find('td').eq(8).text();
+                    // selected_rule.isinc = $(this).find('td').eq(8).text();
                     selected_rule.create_time = nowDate.getFullYear()+"-"+(nowDate.getMonth()+1)+"-"+nowDate.getDate()+" "+nowDate.getHours()+":"+nowDate.getMinutes()+":"+nowDate.getSeconds();
                     selected_rule.rule_id = rule_id
                     rules_id.push(rule_id);
@@ -662,11 +659,11 @@
             $(".selected-rules").html(html);
             for (var i=0;i<selected_rules.length;i++){
                 html += '<tr><td>'+num+'</td><td>'+selected_rules[i].department_name+'</td><td>'+selected_rules[i].rule_name+'</td><td>'+selected_rules[i].update_time+'</td>'+'<td>'+selected_rules[i].department_status+'</td>'+'<td>'+selected_rules[i].rule_status+'</td>';
-                if (selected_rules[i].isinc == "true"){
-                    html += '<td><span onclick="del_selected_rule(\''+selected_rules[i].rule_id+'\')">删除</span></td>'
-                }else{
-                    html += "<td></td>"
-                }
+                // if (selected_rules[i].isinc == "true"){
+                html += '<td><button class="btn btn-danger" onclick="del_selected_rule(\''+selected_rules[i].rule_id+'\')">删除</button></td>'
+                // }else{
+                    // html += "<td></td>"
+                // }
                 num++
             }
         }