瀏覽代碼

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

duxin 6 月之前
父節點
當前提交
4bffe110fb
共有 1 個文件被更改,包括 24 次插入2 次删除
  1. 24 2
      src/jfw/modules/bigmember/src/entity/followEnterprise.go

+ 24 - 2
src/jfw/modules/bigmember/src/entity/followEnterprise.go

@@ -686,21 +686,43 @@ func (this *EntFollow) GetFollowEntInfo() (used int64, surplus int64) {
 }
 
 func (this *EntFollow) GetLabelGroup() *[]map[string]interface{} {
-	if db.Base.Count("follow_ent_monitor_group", map[string]interface{}{
+	defIdMap := make(map[int]bool)
+	count := db.Base.Count("follow_ent_monitor_group", map[string]interface{}{
 		"s_userid":  this.UserId,
 		"isdefGoup": 1,
-	}) == 0 { //初始化默认分组
+	})
+	if count == 0 { //初始化默认分组
 		db.Base.SelectBySql(fmt.Sprintf(`INSERT INTO follow_ent_monitor_group (s_name, s_userid, create_time, update_time, isPut, isdefGoup) VALUES
 ('默认分组', '%s',  '2025-01-03 12:00:00', '2025-01-13 12:00:00', 0, 1),
 ('竞争对手', '%s',  '2024-01-02 12:00:00', '2025-01-13 12:00:00', 1, 0),
 ('合作伙伴', '%s',  '2024-01-01 12:00:00', '2025-01-13 12:00:00', 1, 0);`, this.UserId, this.UserId, this.UserId))
+	} else {
+		data := db.Base.SelectBySql(fmt.Sprintf(`SELECT b.s_groupId FROM follow_ent_monitor a
+INNER  JOIN  follow_ent_monitor_relationship b on (a.s_entId = b.s_entId)
+WHERE a.s_userid = '%s'
+ORDER BY a.l_createtime desc`, this.UserId))
+		if data != nil && len(*data) > 0 {
+			for _, m := range *data {
+				defIdMap[qutil.IntAll(m["s_groupId"])] = true
+			}
+		}
 	}
+
 	data := db.Base.SelectBySql(fmt.Sprintf(`SELECT id,s_name,isPut from follow_ent_monitor_group  WHERE s_userid = '%s'  ORDER BY isdefGoup desc , create_time desc`, this.UserId))
 	if data != nil && len(*data) > 0 {
 		for _, m := range *data {
+			//最近一次分组
+			if len(defIdMap) == 0 && m["s_name"] == "默认分组" {
+				m["isSelect"] = true
+			} else if defIdMap[qutil.IntAll(m["id"])] {
+				m["isSelect"] = true
+			} else {
+				m["isSelect"] = false
+			}
 			m["id"] = util.EncodeId(qutil.InterfaceToStr(m["id"]))
 		}
 	}
+
 	return data
 }