Browse Source

fix:企业关注展示关注信息

duxin 6 months ago
parent
commit
55ff84909e

+ 14 - 5
src/jfw/modules/bigmember/src/entity/followEnterprise.go

@@ -88,19 +88,28 @@ func (this *EntFollow) GetAssociationEnt(entName string) ([]map[string]interface
 // EntFollowedShow 详情页查询是否关注企业
 // followed 是否已关注
 // showFollow 是否展示关注(检索库存在相关企业信息时展示)
-func (this *EntFollow) EntFollowedShow(entId string) (followed, showFollow bool, err error) {
+func (this *EntFollow) EntFollowedShow(entId string) (followed, showFollow bool, followedGroup string, err error) {
 	if entId == "" {
 		err = errors.New("未查询到企业")
 		return
 	}
-	query := map[string]interface{}{"s_entId": entId, "s_userid": this.UserId}
-	fRes := db.Base.FindOne(this.SaveTable, query, "i_apppushunread", "")
+	//query := map[string]interface{}{"s_entId": entId, "s_userid": this.UserId}
+	//fRes := db.Base.FindOne(this.SaveTable, query, "i_apppushunread", "")
+	fRes := db.Base.SelectBySql(fmt.Sprintf(`SELECT a.i_apppushunread,c.s_name FROM %s a
+INNER  JOIN  follow_ent_monitor_relationship b on (a.s_entId = b.s_entId)
+INNER JOIN  follow_ent_monitor_group c on (b.s_groupId = c.id and a.s_userid = c.s_userid)
+WHERE a.s_entId = '%s' and a.s_userid = '%s'`, this.SaveTable, entId, this.UserId))
 	followed = false
 	if fRes != nil {
 		followed = true
+		var names []string
+		for _, m := range *fRes {
+			names = append(names, qutil.ObjToString(m["s_name"]))
+		}
+		followedGroup = strings.Join(names, ",")
 		//已关注,并且有未读标示
-		if qutil.IntAll((*fRes)["i_apppushunread"]) > 0 {
-			go db.Base.Update(this.SaveTable, query, map[string]interface{}{
+		if qutil.IntAll((*fRes)[0]["i_apppushunread"]) > 0 {
+			go db.Base.Update(this.SaveTable, map[string]interface{}{"s_entId": entId, "s_userid": this.UserId}, map[string]interface{}{
 				"i_apppushunread": 0,
 			})
 		}

+ 4 - 3
src/jfw/modules/bigmember/src/service/follow/enterprise.go

@@ -62,14 +62,15 @@ func (this *FollowEnt) FollowCheck() {
 		if err != nil {
 			return nil, err
 		}
-		followed, showFollow, err := followEntManager.EntFollowedShow(util.DecodeId(this.GetString("entId")))
+		followed, showFollow, followedGroup, err := followEntManager.EntFollowedShow(util.DecodeId(this.GetString("entId")))
 		if err != nil {
 			return nil, err
 		}
 		used, surplus := followEntManager.GetFollowEntInfo()
 		return map[string]interface{}{
-			"followed": followed,
-			"isShow":   showFollow,
+			"followed":      followed,
+			"isShow":        showFollow,
+			"followedGroup": followedGroup,
 			"info": map[string]interface{}{
 				"surplus": surplus,
 				"used":    used,