|
@@ -127,13 +127,19 @@ WHERE a.s_entId = '%s' and a.s_userid = '%s'`, this.SaveTable, entId, this.UserI
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+type EntFollowGroup struct {
|
|
|
+ Id string `json:"id"`
|
|
|
+ Name string `json:"name"`
|
|
|
+ Count int `json:"count"`
|
|
|
+}
|
|
|
+
|
|
|
// GetEntFollowList 我关注的企业列表
|
|
|
// param A默认分组 B竞争对手 C合作伙伴 逗号分隔
|
|
|
// 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, err error) {
|
|
|
+func (this *EntFollow) GetEntFollowList(pNum, pSize int, match, groups string) (followData []map[string]interface{}, hasNext bool, count, total int, groupUserArr []EntFollowGroup, err error) {
|
|
|
groupIds, groupErr := checkGroup(this.UserId, groups, true)
|
|
|
if groupErr != nil {
|
|
|
- return nil, false, -1, -1, fmt.Errorf("分组不存在")
|
|
|
+ return nil, false, -1, -1, nil, 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)
|
|
|
log.Print("我关注的企业列表开始查询:", flistSql)
|
|
@@ -144,8 +150,18 @@ func (this *EntFollow) GetEntFollowList(pNum, pSize int, match, groups string) (
|
|
|
}
|
|
|
log.Print("我关注的企业列表查询结束")
|
|
|
count = len(*res)
|
|
|
+ //获取用户分组列表
|
|
|
+ var (
|
|
|
+ followDataAll []map[string]interface{}
|
|
|
+ )
|
|
|
+ groupMap := make(map[string]int)
|
|
|
+ data := db.Base.SelectBySql(fmt.Sprintf(`SELECT id,s_name 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
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- var followDataAll []map[string]interface{}
|
|
|
for _, item := range *res {
|
|
|
//兼容从大会员变成免费用户时筛选条件数据错乱问题 取数据全部取出后在进行筛选过滤
|
|
|
if match != "" {
|
|
@@ -153,12 +169,20 @@ func (this *EntFollow) GetEntFollowList(pNum, pSize int, match, groups string) (
|
|
|
continue
|
|
|
}
|
|
|
}
|
|
|
- var enCodeGroups []string
|
|
|
|
|
|
+ var (
|
|
|
+ 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 {
|
|
|
var (
|
|
|
- groups = strings.Split(gconv.String(item["gs"]), ",")
|
|
|
- has = false
|
|
|
+ has = false
|
|
|
)
|
|
|
for _, group := range groups {
|
|
|
if group != "" {
|
|
@@ -194,6 +218,17 @@ func (this *EntFollow) GetEntFollowList(pNum, pSize int, match, groups string) (
|
|
|
}
|
|
|
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"]),
|
|
|
+ groupMap[qutil.InterfaceToStr(m["id"])],
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
total = len(followDataAll)
|
|
|
//分页
|
|
|
if total > 0 {
|
|
@@ -697,12 +732,14 @@ func (this *EntFollow) GetLabelGroup() *[]map[string]interface{} {
|
|
|
('竞争对手', '%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 {
|
|
|
+ //获取最近一次关注的分组
|
|
|
+ groupIdData := db.Base.SelectBySql(fmt.Sprintf(fmt.Sprintf(`SELECT b.s_groupId FROM follow_ent_monitor_relationship b
|
|
|
+INNER JOIN (
|
|
|
+SELECT s_entId FROM follow_ent_monitor WHERE s_userid = '%s' ORDER BY l_createtime desc limit 1
|
|
|
+) a on a.s_entId = b.s_entId
|
|
|
+INNER JOIN follow_ent_monitor_group c on c.s_userid = '%s' and c.id = b.s_groupId`, this.UserId, this.UserId)))
|
|
|
+ if groupIdData != nil && len(*groupIdData) > 0 {
|
|
|
+ for _, m := range *groupIdData {
|
|
|
defIdMap[qutil.IntAll(m["s_groupId"])] = true
|
|
|
}
|
|
|
}
|
|
@@ -711,12 +748,12 @@ ORDER BY a.l_createtime desc`, this.UserId))
|
|
|
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"] == "默认分组" {
|
|
|
+ switch { //最近一次分组
|
|
|
+ case len(defIdMap) == 0 && m["s_name"] == "默认分组": //最近没有关注 分配到默认分组
|
|
|
m["isSelect"] = true
|
|
|
- } else if defIdMap[qutil.IntAll(m["id"])] {
|
|
|
+ case defIdMap[qutil.IntAll(m["id"])]:
|
|
|
m["isSelect"] = true
|
|
|
- } else {
|
|
|
+ default:
|
|
|
m["isSelect"] = false
|
|
|
}
|
|
|
m["id"] = util.EncodeId(qutil.InterfaceToStr(m["id"]))
|