|
@@ -41,7 +41,7 @@ func FormatDate(src *interface{}) string {
|
|
|
return str
|
|
|
}
|
|
|
|
|
|
-func GetEntInfo(id string) interface{} {
|
|
|
+func GetEntInfo(id string) map[string]interface{} {
|
|
|
res := FindById("enterprise", id, `{"RegNo":1, "EntName":1, "EntType":1, "EntTypeName":1, "OpLocDistrict":1, "LeRep":1, "LegCerNO":1, "Tel":1, "Dom":1, "OpScope":1, "OpFrom":1, "OpTo":1, "RegCap":1, "EstDate":1, "CompForm":1, "CompFormName":1, "OpState":1, "OpStateName":1, "RegOrgName":1, "IssBLicDate":1, "Timestamp":1, "s_synopsis":1, "SourceType":1, "Nb_email":1,"IndustryPhyName":1,"investor":1,"alterInfo":1, "s_enturl, "i_province":1, "i_city":1, "i_area":1,"s_action":1,"s_persion":1,"s_mobile":1,"s_address":1,"s_avatar":1,"s_microwebsite":1,"s_qq":1,"s_submitid":1,"s_email":1,"staffinfo":1}`)
|
|
|
if res != nil && len(*res) > 0 {
|
|
|
id := (*res)["s_submitid"]
|
|
@@ -259,6 +259,43 @@ func (yp *Yellowpage) EnterpriseInfo(id string) error {
|
|
|
} else {
|
|
|
if info := GetEntInfo(id); info != nil {
|
|
|
yp.T["res"] = info
|
|
|
+ regNo, _ := info["RegNo"].(string)
|
|
|
+ entName, _ := info["EntName"].(string)
|
|
|
+ relation := redis.Get("enterprise", "relation-"+regNo)
|
|
|
+ if relation == nil {
|
|
|
+ relation = makeRelation(regNo, entName)
|
|
|
+ redis.Put("enterprise", "relation-"+regNo, relation, 7*ONEDAY)
|
|
|
+ }
|
|
|
+ r := relation.(map[string]interface{})
|
|
|
+ var nodes *[]map[string]interface{}
|
|
|
+ var relevantEnts []map[string]interface{}
|
|
|
+ if d, err := json.Marshal(r["nodes"]); err == nil && json.Unmarshal(d, &nodes) == nil && len(*nodes) > 0 {
|
|
|
+ var regNos []string
|
|
|
+ for _, v := range *nodes {
|
|
|
+ if v["type"] == "e" {
|
|
|
+ regNos = append(regNos, v["name"].(string))
|
|
|
+ relevantEnts = append(relevantEnts, v)
|
|
|
+ }
|
|
|
+ if len(regNos) == 6 {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(regNos) > 0 {
|
|
|
+ ents := Find("enterprise", M{"RegNo": regNos}, nil, `{"s_avatar":1}`, false, -1, -1)
|
|
|
+ if ents != nil && len(*ents) > 0 {
|
|
|
+ for _, relevantEnt := range relevantEnts {
|
|
|
+ for _, ent := range *ents {
|
|
|
+ if ent["RegNo"] == relevantEnt["name"] {
|
|
|
+ ent["s_avatar"] = ent["s_avatar"]
|
|
|
+ ent["_id"] = util.BsonIdToSId(ent["_id"])
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ yp.T["relevantEnts"] = relevantEnts
|
|
|
contentuser, erruser := yp.Render4Cache("/yellowpage/enterpriseinfo.html", &yp.T)
|
|
|
if erruser == nil {
|
|
|
redis.PutBytes("enterprise", "enterpriseInfo_"+id, &contentuser, 7*ONEDAY)
|
|
@@ -396,10 +433,10 @@ func (yp *Yellowpage) GetRelation() error {
|
|
|
if regNo == "" || entName == "" {
|
|
|
return nil
|
|
|
}
|
|
|
- relation := redis.Get("other", "relation-"+regNo)
|
|
|
+ relation := redis.Get("enterprise", "relation-"+regNo)
|
|
|
if relation == nil {
|
|
|
relation = makeRelation(regNo, entName)
|
|
|
- redis.Put("other", "relation-"+regNo, relation, 7*ONEDAY)
|
|
|
+ redis.Put("enterprise", "relation-"+regNo, relation, 7*ONEDAY)
|
|
|
}
|
|
|
yp.ServeJson(M{"flag": true, "relation": relation})
|
|
|
r := relation.(map[string]interface{})
|