Browse Source

fix:分组管理修改

duxin 6 months ago
parent
commit
50c22e2dd1

+ 39 - 28
src/jfw/modules/bigmember/src/entity/followEnterprise.go

@@ -137,10 +137,10 @@ type EntFollowGroup struct {
 // GetEntFollowList 我关注的企业列表
 // GetEntFollowList 我关注的企业列表
 // param A默认分组 B竞争对手 C合作伙伴 逗号分隔
 // param A默认分组 B竞争对手 C合作伙伴 逗号分隔
 // db  0||nil 默认分组、1 竞争对手、2 合作伙伴、3 竞争对手和合作伙伴
 // db  0||nil 默认分组、1 竞争对手、2 合作伙伴、3 竞争对手和合作伙伴
-func (this *EntFollow) GetEntFollowList(pNum, pSize int, match, groups string) (followData []map[string]interface{}, hasNext bool, count, total int, groupUserArr []EntFollowGroup, err error) {
+func (this *EntFollow) GetEntFollowList(pNum, pSize int, match, groups string) (followData []map[string]interface{}, hasNext bool, count, total int, err error) {
 	groupIds, groupErr := checkGroup(this.UserId, groups, true)
 	groupIds, groupErr := checkGroup(this.UserId, groups, true)
 	if groupErr != nil {
 	if groupErr != nil {
-		return nil, false, -1, -1, nil, fmt.Errorf("分组不存在")
+		return nil, false, -1, -1, fmt.Errorf("分组不存在")
 	}
 	}
 	flistSql := fmt.Sprintf(`SELECT  m.*,GROUP_CONCAT(g.id SEPARATOR ',') as gs  from follow_ent_monitor m inner join follow_ent_monitor_group g on(m.s_userid =g.s_userid and g.s_userid ='%s') INNER JOIN follow_ent_monitor_relationship r  on ( g.id=r.s_groupId and m.s_entId=r.s_entId ) GROUP BY s_entId  ORDER BY m.l_lastpushtime DESC,m.l_createtime DESC LIMIT %d,%d`, this.UserId, 0, this.MaxNum)
 	flistSql := fmt.Sprintf(`SELECT  m.*,GROUP_CONCAT(g.id SEPARATOR ',') as gs  from follow_ent_monitor m inner join follow_ent_monitor_group g on(m.s_userid =g.s_userid and g.s_userid ='%s') INNER JOIN follow_ent_monitor_relationship r  on ( g.id=r.s_groupId and m.s_entId=r.s_entId ) GROUP BY s_entId  ORDER BY m.l_lastpushtime DESC,m.l_createtime DESC LIMIT %d,%d`, this.UserId, 0, this.MaxNum)
 	log.Print("我关注的企业列表开始查询:", flistSql)
 	log.Print("我关注的企业列表开始查询:", flistSql)
@@ -155,13 +155,6 @@ func (this *EntFollow) GetEntFollowList(pNum, pSize int, match, groups string) (
 	var (
 	var (
 		followDataAll []map[string]interface{}
 		followDataAll []map[string]interface{}
 	)
 	)
-	groupMap := make(map[string]int)
-	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 {
-			groupMap[qutil.InterfaceToStr(m["id"])] = 0
-		}
-	}
 
 
 	for _, item := range *res {
 	for _, item := range *res {
 		//兼容从大会员变成免费用户时筛选条件数据错乱问题 取数据全部取出后在进行筛选过滤
 		//兼容从大会员变成免费用户时筛选条件数据错乱问题 取数据全部取出后在进行筛选过滤
@@ -173,17 +166,12 @@ func (this *EntFollow) GetEntFollowList(pNum, pSize int, match, groups string) (
 
 
 		var (
 		var (
 			enCodeGroups []string
 			enCodeGroups []string
-			groups       = strings.Split(gconv.String(item["gs"]), ",")
 		)
 		)
-		//数据存在于哪个分组中 计数
-		for _, group := range groups {
-			if _, ok := groupMap[group]; ok {
-				groupMap[qutil.InterfaceToStr(group)]++
-			}
-		}
+
 		if len(groupIds) > 0 {
 		if len(groupIds) > 0 {
 			var (
 			var (
-				has = false
+				has    = false
+				groups = strings.Split(gconv.String(item["gs"]), ",")
 			)
 			)
 			for _, group := range groups {
 			for _, group := range groups {
 				if group != "" {
 				if group != "" {
@@ -220,17 +208,6 @@ func (this *EntFollow) GetEntFollowList(pNum, pSize int, match, groups string) (
 		followDataAll = append(followDataAll, rowMap)
 		followDataAll = append(followDataAll, rowMap)
 	}
 	}
 
 
-	if data != nil && len(*data) > 0 {
-		for _, m := range *data {
-			groupUserArr = append(groupUserArr, EntFollowGroup{
-				util.EncodeId(qutil.InterfaceToStr(m["id"])),
-				qutil.InterfaceToStr(m["s_name"]),
-				qutil.IntAll(m["isPut"]),
-				groupMap[qutil.InterfaceToStr(m["id"])],
-			})
-		}
-	}
-
 	total = len(followDataAll)
 	total = len(followDataAll)
 	//分页
 	//分页
 	if total > 0 {
 	if total > 0 {
@@ -871,3 +848,37 @@ func (this *EntFollow) DelLabelGroup(groupId string) error {
 	}
 	}
 	return err
 	return err
 }
 }
+
+func (this *EntFollow) GetFollowGroupList() (groupUserArr []EntFollowGroup, err error) {
+	groupMap := make(map[int]int)
+	flistSql := fmt.Sprintf(`SELECT  m.s_entId,g.id as groupId  from follow_ent_monitor m inner join follow_ent_monitor_group g on(m.s_userid =g.s_userid and g.s_userid ='%s') INNER JOIN follow_ent_monitor_relationship r  on ( g.id=r.s_groupId and m.s_entId=r.s_entId ) GROUP BY s_entId  ORDER BY m.l_lastpushtime DESC,m.l_createtime DESC LIMIT %d,%d`, this.UserId, 0, this.MaxNum)
+	log.Print("我关注的企业列表开始查询:", flistSql)
+	res := db.Base.SelectBySql(flistSql)
+	if res != nil && len(*res) > 0 {
+		for _, m := range *res {
+			groupMap[qutil.IntAll(m["groupId"])]++
+		}
+	}
+	data := db.Base.SelectBySql(fmt.Sprintf(`SELECT
+	a.id,
+	a.isPut,
+	a.s_name
+FROM
+	follow_ent_monitor_group a
+WHERE
+	a.s_userid = '%s'
+ORDER BY
+	a.isdefGoup DESC,
+	a.create_time DESC`, this.UserId))
+	if data != nil && len(*data) > 0 {
+		for _, m := range *data {
+			groupUserArr = append(groupUserArr, EntFollowGroup{
+				util.EncodeId(qutil.InterfaceToStr(m["id"])),
+				qutil.InterfaceToStr(m["s_name"]),
+				qutil.IntAll(m["isPut"]),
+				groupMap[qutil.IntAll(m["id"])],
+			})
+		}
+	}
+	return
+}

+ 29 - 7
src/jfw/modules/bigmember/src/service/follow/enterprise.go

@@ -27,6 +27,7 @@ type FollowEnt struct {
 	entChangeList      xweb.Mapper `xweb:"/follow/ent/entChangeList"`      //企业变更记录
 	entChangeList      xweb.Mapper `xweb:"/follow/ent/entChangeList"`      //企业变更记录
 	pcSimpleFollowList xweb.Mapper `xweb:"/follow/ent/pcSimpleFollowList"` //pc关注企业列表(带变更)
 	pcSimpleFollowList xweb.Mapper `xweb:"/follow/ent/pcSimpleFollowList"` //pc关注企业列表(带变更)
 	labelGroup         xweb.Mapper `xweb:"/follow/ent/labelGroup"`         //关注标签分组
 	labelGroup         xweb.Mapper `xweb:"/follow/ent/labelGroup"`         //关注标签分组
+	labelGroupList     xweb.Mapper `xweb:"/follow/ent/labelGroupList"`     //标签分组列表
 }
 }
 
 
 // Association 中标企业联想
 // Association 中标企业联想
@@ -96,7 +97,7 @@ func (this *FollowEnt) List() {
 		if pSize == 0 || pSize > 100 {          //默认一页50条数据
 		if pSize == 0 || pSize > 100 {          //默认一页50条数据
 			pSize = 50
 			pSize = 50
 		}
 		}
-		entList, hasNext, count, total, groupUserArr, err := followEntManager.GetEntFollowList(pNum, pSize, this.GetString("match"), this.GetString("group"))
+		entList, hasNext, count, total, err := followEntManager.GetEntFollowList(pNum, pSize, this.GetString("match"), this.GetString("group"))
 		if err != nil {
 		if err != nil {
 			return nil, err
 			return nil, err
 		}
 		}
@@ -104,12 +105,11 @@ func (this *FollowEnt) List() {
 			entList = []map[string]interface{}{}
 			entList = []map[string]interface{}{}
 		}
 		}
 		return map[string]interface{}{
 		return map[string]interface{}{
-			"count":        count,                   //已关注数量
-			"total":        total,                   //筛选总数
-			"hasNext":      hasNext,                 //是否有下一页
-			"list":         entList,                 //我关注的企业信息
-			"followMax":    followEntManager.MaxNum, //最多关注企业数量
-			"groupUserArr": groupUserArr,            //关注分组列表
+			"count":     count,                   //已关注数量
+			"total":     total,                   //筛选总数
+			"hasNext":   hasNext,                 //是否有下一页
+			"list":      entList,                 //我关注的企业信息
+			"followMax": followEntManager.MaxNum, //最多关注企业数量
 		}, nil
 		}, nil
 	}()
 	}()
 	if errMsg != nil {
 	if errMsg != nil {
@@ -303,3 +303,25 @@ func (this *FollowEnt) LabelGroup() {
 	}
 	}
 	this.ServeJson(NewResult(rData, errMsg))
 	this.ServeJson(NewResult(rData, errMsg))
 }
 }
+
+// LabelGroupList 关注中标企业标签列表
+func (this *FollowEnt) LabelGroupList() {
+	userId := qutil.ObjToString(this.GetSession("userId"))
+	rData, errMsg := func() (interface{}, error) {
+		followEntManager, err := entity.CreateEntFollowManager(this.Session())
+		if err != nil {
+			return nil, err
+		}
+		groupUserArr, err := followEntManager.GetFollowGroupList()
+		if err != nil {
+			return nil, err
+		}
+		return map[string]interface{}{
+			"groupUserArr": groupUserArr, //关注分组列表
+		}, nil
+	}()
+	if errMsg != nil {
+		log.Printf("%s 企业关注列表查询出错:%s\n", userId, errMsg.Error())
+	}
+	this.ServeJson(NewResult(rData, errMsg))
+}