|
@@ -166,11 +166,11 @@ func (this *EntFollow) GetEntFollowList(pNum, pSize int, match, groups string) (
|
|
|
|
|
|
var (
|
|
|
enCodeGroups []string
|
|
|
+ has = true
|
|
|
)
|
|
|
-
|
|
|
if len(groupIds) > 0 {
|
|
|
+ has = false
|
|
|
var (
|
|
|
- has = false
|
|
|
groups = strings.Split(gconv.String(item["gs"]), ",")
|
|
|
)
|
|
|
for _, group := range groups {
|
|
@@ -181,9 +181,9 @@ func (this *EntFollow) GetEntFollowList(pNum, pSize int, match, groups string) (
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if !has {
|
|
|
- continue
|
|
|
- }
|
|
|
+ }
|
|
|
+ if !has {
|
|
|
+ continue
|
|
|
}
|
|
|
entId := qutil.ObjToString(item["s_entId"])
|
|
|
if entId == "" { //dev3.6.2 前关注企业未存入企业id
|
|
@@ -407,7 +407,14 @@ func getGroup(groupStr string) (s int) {
|
|
|
func checkGroup(userId, groupStr string, defaultGetAll ...bool) (map[int]bool, error) {
|
|
|
rData := db.Base.Query("SELECT id,s_name FROM follow_ent_monitor_group WHERE s_userid=?", userId)
|
|
|
if rData == nil || len(*rData) == 0 {
|
|
|
- return nil, fmt.Errorf("未查询到标签")
|
|
|
+ //新用户插入分组
|
|
|
+ if _, err := db.Base.ExecBySql(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);`, userId, userId, userId)); err != nil {
|
|
|
+ log.Printf("新用户 %s创建分组异常", userId)
|
|
|
+ }
|
|
|
+ return nil, nil
|
|
|
}
|
|
|
var (
|
|
|
hasGroupId = map[int]bool{}
|
|
@@ -701,6 +708,7 @@ func (this *EntFollow) GetFollowEntInfo() (used int64, surplus int64) {
|
|
|
|
|
|
func (this *EntFollow) GetLabelGroup() *[]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,
|
|
@@ -743,15 +751,8 @@ INNER JOIN follow_ent_monitor_group c on c.s_userid = '%s' and c.id = b.s_grou
|
|
|
}
|
|
|
|
|
|
func (this *EntFollow) AddLabelGroup(name string) error {
|
|
|
- if db.Base.Count("follow_ent_monitor_group", map[string]interface{}{
|
|
|
- "user_id": this.UserId,
|
|
|
- "isdefGoup": 1,
|
|
|
- }) == 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))
|
|
|
- }
|
|
|
+ //检测默认分组 初始花
|
|
|
+ DefaultGroupInit(this.UserId)
|
|
|
if db.Base.Count("follow_ent_monitor_group", map[string]interface{}{
|
|
|
"user_id": this.UserId,
|
|
|
"s_name": name,
|
|
@@ -851,12 +852,17 @@ func (this *EntFollow) DelLabelGroup(groupId string) error {
|
|
|
|
|
|
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)
|
|
|
+ DefaultGroupInit(this.UserId)
|
|
|
+ flistSql := fmt.Sprintf(`SELECT m.s_entId,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)
|
|
|
res := db.Base.SelectBySql(flistSql)
|
|
|
if res != nil && len(*res) > 0 {
|
|
|
for _, m := range *res {
|
|
|
- groupMap[qutil.IntAll(m["groupId"])]++
|
|
|
+ for _, gId := range strings.Split(gconv.String(m["gs"]), ",") {
|
|
|
+ if groupId := gconv.Int(gId); groupId > 0 {
|
|
|
+ groupMap[groupId]++
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
data := db.Base.SelectBySql(fmt.Sprintf(`SELECT
|
|
@@ -882,3 +888,15 @@ ORDER BY
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+func DefaultGroupInit(userId string) {
|
|
|
+ if db.Base.Count("follow_ent_monitor_group", map[string]interface{}{
|
|
|
+ "user_id": userId,
|
|
|
+ "isdefGoup": 1,
|
|
|
+ }) == 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);`, userId, userId, userId))
|
|
|
+ }
|
|
|
+}
|