wangchuanjin 9 lat temu
rodzic
commit
3c3db72cc1

+ 34 - 20
core/src/qfw/member/yellowpage.go

@@ -94,25 +94,7 @@ func (yp *Yellowpage) Save() error {
 		data["i_area"] = area
 		data["s_address"] = Repl(yp.GetString("s_address"))
 		//权重
-		atrrTitle := coreconfig.SysConfig.AtrrTitle
-		web := mongodb.FindById(ESTYPE, entid, `{"_id":-1,"attrWeight":1}`)
-		var attrWeight []byte
-		if tmp, ok := (*web)["attrWeight"].(string); ok {
-			attrWeight, _ = hex.DecodeString(tmp)
-		} else {
-			attrWeight = make([]byte, 30)
-		}
-		for k, v := range atrrTitle {
-			arr, _ := v.([]interface{})
-			index := util.IntAll(arr[0])
-			weight := util.IntAll(arr[1])
-			if weight < int(attrWeight[index]) {
-				delete(data, k)
-			} else {
-				attrWeight[index] = byte(weight)
-			}
-		}
-		data["attrWeight"] = hex.EncodeToString(attrWeight)
+		setAttrWeight(entid, data, false)
 		dataSet := map[string]interface{}{
 			"$set": data,
 		}
@@ -219,7 +201,11 @@ func (yp *Yellowpage) UpLoadEntImg() error {
 	} else {
 		field = "s_qrcode"
 	}
-	bol := mongodb.Update("enterprise", "{'_id':'"+entid+"'}", map[string]interface{}{"$set": map[string]interface{}{field: yp.GetString("url")}}, false, false)
+	data := bson.M{field: yp.GetString("url")}
+	if field == "s_avatar" {
+		setAttrWeight(entid, data, true)
+	}
+	bol := mongodb.Update("enterprise", "{'_id':'"+entid+"'}", map[string]interface{}{"$set": data}, false, false)
 	redis.Del("enterprise", "enterpriseInfo_"+entid, "newIndentEnts")
 	if field == "s_avatar" {
 		redis.DelByCodePattern("enterprise", "ipcity_*")
@@ -307,3 +293,31 @@ func (yp *Yellowpage) IsFollowed() error {
 	yp.ServeJson(bson.M{"status": status})
 	return nil
 }
+
+//权重
+func setAttrWeight(entid string, data bson.M, flag bool) {
+	atrrTitle := coreconfig.SysConfig.AtrrTitle
+	web := mongodb.FindById(ESTYPE, entid, `{"_id":-1,"attrWeight":1}`)
+	var attrWeight []byte
+	if tmp, ok := (*web)["attrWeight"].(string); ok {
+		attrWeight, _ = hex.DecodeString(tmp)
+	} else {
+		attrWeight = make([]byte, 30)
+	}
+	for k, v := range atrrTitle {
+		if !flag && k == "s_avatar" {
+			continue
+		} else if flag && k != "s_avatar" {
+			continue
+		}
+		arr, _ := v.([]interface{})
+		index := util.IntAll(arr[0])
+		weight := util.IntAll(arr[1])
+		if weight < int(attrWeight[index]) {
+			delete(data, k)
+		} else {
+			attrWeight[index] = byte(weight)
+		}
+	}
+	data["attrWeight"] = hex.EncodeToString(attrWeight)
+}

+ 10 - 3
core/src/qfw/microwebsite/microwebsite.go

@@ -239,7 +239,7 @@ func (m *MicroWebsite) AjaxPorcess() error {
 			entObj["s_synopsis"] = fsw.Repl(m.GetStringComm("s_synopsis")) //修改企业简介
 			break
 		}
-		setAttrWeight(entId, entObj)
+		setAttrWeight(entId, entObj, false)
 		//修改企业信息
 		if len(entObj) > 0 && Update("enterprise", "{'_id':'"+entId+"'}", M{"$set": entObj}, false, false) {
 			redis.Del("enterprise", "enterpriseInfo_"+entId) //清除该企业的redis缓存
@@ -311,7 +311,9 @@ func (m *MicroWebsite) AjaxPorcess() error {
 			field = "s_qrcode"
 		}
 		data := M{field: m.GetString("src")}
-		setAttrWeight(entId, data)
+		if field == "s_avatar" {
+			setAttrWeight(entId, data, true)
+		}
 		b := Update("enterprise", "{'_id':'"+entId+"'}", M{"$set": data}, false, false)
 		if b {
 			redis.Del("enterprise", "enterpriseInfo_"+entId) //清除该企业的redis缓存
@@ -332,7 +334,7 @@ func (m *MicroWebsite) AjaxPorcess() error {
 }
 
 //权重
-func setAttrWeight(entid string, data M) {
+func setAttrWeight(entid string, data M, flag bool) {
 	atrrTitle := coreconfig.SysConfig.AtrrTitle
 	web := FindById("enterprise", entid, `{"_id":-1,"attrWeight":1}`)
 	var attrWeight []byte
@@ -342,6 +344,11 @@ func setAttrWeight(entid string, data M) {
 		attrWeight = make([]byte, 30)
 	}
 	for k, v := range atrrTitle {
+		if !flag && k == "s_avatar" {
+			continue
+		} else if flag && k != "s_avatar" {
+			continue
+		}
 		arr, _ := v.([]interface{})
 		index := IntAll(arr[0])
 		weight := IntAll(arr[1])