|
@@ -544,3 +544,63 @@ func (this *EntFollow) GetFollowEntInfo() (used int64, surplus int64) {
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func (this *EntFollow) GetLabelGroup() *[]map[string]interface{} {
|
|
|
|
+ if db.Base.Count("follow_ent_monitor_group", map[string]interface{}{
|
|
|
|
+ "user_id": this.UserId,
|
|
|
|
+ "isDefGroup": 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))
|
|
|
|
+ }
|
|
|
|
+ data := db.Base.SelectBySql(fmt.Sprintf(`SELECT id,s_name,isPut from follow_ent_monitor_group WHERE s_userid = '%s' ORDER BY isDefGroup desc , create_time desc`, this.UserId))
|
|
|
|
+ if data != nil && len(*data) > 0 {
|
|
|
|
+ for _, m := range *data {
|
|
|
|
+ m["id"] = util.EncodeId(qutil.InterfaceToStr(m["id"]))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return data
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (this *EntFollow) AddLabelGroup(name string) error {
|
|
|
|
+ if db.Base.Count("follow_ent_monitor_group", map[string]interface{}{
|
|
|
|
+ "user_id": this.UserId,
|
|
|
|
+ "isDefGroup": 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))
|
|
|
|
+ }
|
|
|
|
+ if db.Base.Count("follow_ent_monitor_group", map[string]interface{}{
|
|
|
|
+ "user_id": this.UserId,
|
|
|
|
+ "s_name": name,
|
|
|
|
+ }) > 0 { //是否重名
|
|
|
|
+ return errors.New("分组名称已存在")
|
|
|
|
+ }
|
|
|
|
+ db.Base.Insert("follow_ent_monitor_group", map[string]interface{}{
|
|
|
|
+ "s_name": name,
|
|
|
|
+ "s_userid": this.UserId,
|
|
|
|
+ "create_time": time.Now(),
|
|
|
|
+ "update_time": time.Now(),
|
|
|
|
+ "isPut": 1,
|
|
|
|
+ "isdefGoup": 0,
|
|
|
|
+ })
|
|
|
|
+ return nil
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (this *EntFollow) PutLabelGroup(name string, groupId string) error {
|
|
|
|
+ if db.Base.Count("follow_ent_monitor_group", map[string]interface{}{
|
|
|
|
+ "user_id": this.UserId,
|
|
|
|
+ "s_name": name,
|
|
|
|
+ }) > 0 { //是否重名
|
|
|
|
+ return errors.New("分组名称已存在")
|
|
|
|
+ }
|
|
|
|
+ db.Base.Update("follow_ent_monitor_group", map[string]interface{}{
|
|
|
|
+ "s_userid": this.UserId,
|
|
|
|
+ "id": groupId,
|
|
|
|
+ }, map[string]interface{}{"s_name": name})
|
|
|
|
+ return nil
|
|
|
|
+}
|