|
@@ -6,10 +6,12 @@ package microwebsite
|
|
|
|
|
|
import (
|
|
import (
|
|
"encoding/base64"
|
|
"encoding/base64"
|
|
|
|
+ "encoding/hex"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"github.com/go-xweb/xweb"
|
|
"github.com/go-xweb/xweb"
|
|
. "gopkg.in/mgo.v2/bson"
|
|
. "gopkg.in/mgo.v2/bson"
|
|
. "qfw/coreconfig"
|
|
. "qfw/coreconfig"
|
|
|
|
+ coreconfig "qfw/coreconfig"
|
|
. "qfw/util"
|
|
. "qfw/util"
|
|
elastic "qfw/util/elastic"
|
|
elastic "qfw/util/elastic"
|
|
"qfw/util/fsw"
|
|
"qfw/util/fsw"
|
|
@@ -237,11 +239,12 @@ func (m *MicroWebsite) AjaxPorcess() error {
|
|
entObj["s_synopsis"] = fsw.Repl(m.GetStringComm("s_synopsis")) //修改企业简介
|
|
entObj["s_synopsis"] = fsw.Repl(m.GetStringComm("s_synopsis")) //修改企业简介
|
|
break
|
|
break
|
|
}
|
|
}
|
|
- if len(entObj) > 0 {
|
|
|
|
- Update("enterprise", "{'_id':'"+entId+"'}", M{"$set": entObj}, false, false)
|
|
|
|
- }
|
|
|
|
|
|
+ setAttrWeight(entId, entObj)
|
|
//修改企业信息
|
|
//修改企业信息
|
|
- elastic.UpdateEntDoc(entId) //更新该企业的elastic数据
|
|
|
|
|
|
+ if len(entObj) > 0 && Update("enterprise", "{'_id':'"+entId+"'}", M{"$set": entObj}, false, false) {
|
|
|
|
+ redis.Del("enterprise", "enterpriseInfo_"+entId) //清除该企业的redis缓存
|
|
|
|
+ elastic.UpdateEntDoc(entId) //更新该企业的elastic数据
|
|
|
|
+ }
|
|
} else if reqType == "addService" {
|
|
} else if reqType == "addService" {
|
|
tempId := m.GetString("tempId")
|
|
tempId := m.GetString("tempId")
|
|
serviceObj := make(M)
|
|
serviceObj := make(M)
|
|
@@ -307,9 +310,12 @@ func (m *MicroWebsite) AjaxPorcess() error {
|
|
} else {
|
|
} else {
|
|
field = "s_qrcode"
|
|
field = "s_qrcode"
|
|
}
|
|
}
|
|
- b := Update("enterprise", "{'_id':'"+entId+"'}", M{"$set": M{field: m.GetString("src")}}, false, false)
|
|
|
|
|
|
+ data := M{field: m.GetString("src")}
|
|
|
|
+ setAttrWeight(entId, data)
|
|
|
|
+ b := Update("enterprise", "{'_id':'"+entId+"'}", M{"$set": data}, false, false)
|
|
if b {
|
|
if b {
|
|
- elastic.UpdateEntDoc(entId) //更新该企业的elastic数据
|
|
|
|
|
|
+ redis.Del("enterprise", "enterpriseInfo_"+entId) //清除该企业的redis缓存
|
|
|
|
+ elastic.UpdateEntDoc(entId) //更新该企业的elastic数据
|
|
result["status"] = "y"
|
|
result["status"] = "y"
|
|
}
|
|
}
|
|
} else if reqType == "serviceImg" { //修改服务图片
|
|
} else if reqType == "serviceImg" { //修改服务图片
|
|
@@ -321,7 +327,29 @@ func (m *MicroWebsite) AjaxPorcess() error {
|
|
result["status"] = "y"
|
|
result["status"] = "y"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- redis.Del("enterprise", "enterpriseInfo_"+entId) //清除该企业的redis缓存
|
|
|
|
m.ServeJson(result)
|
|
m.ServeJson(result)
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+//权重
|
|
|
|
+func setAttrWeight(entid string, data M) {
|
|
|
|
+ atrrTitle := coreconfig.SysConfig.AtrrTitle
|
|
|
|
+ web := FindById("enterprise", 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 := IntAll(arr[0])
|
|
|
|
+ weight := IntAll(arr[1])
|
|
|
|
+ if weight < int(attrWeight[index]) {
|
|
|
|
+ delete(data, k)
|
|
|
|
+ } else {
|
|
|
|
+ attrWeight[index] = byte(weight)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ data["attrWeight"] = hex.EncodeToString(attrWeight)
|
|
|
|
+}
|