|
@@ -8,6 +8,7 @@ import (
|
|
|
qutil "qfw/util"
|
|
|
"reflect"
|
|
|
"strings"
|
|
|
+ "time"
|
|
|
"util"
|
|
|
|
|
|
"github.com/go-xweb/xweb"
|
|
@@ -41,8 +42,21 @@ func (ac *Action) Subscribe_index() error {
|
|
|
"model": entInfo.Ent.Model,
|
|
|
"subdis": entInfo.Dept.Subdis,
|
|
|
}
|
|
|
+ var o_entniche *map[string]interface{}
|
|
|
+ model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
|
|
|
+ if model == 1 {
|
|
|
+ o_entniche, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "i_deptid": entInfo.Dept.Id,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ })
|
|
|
+ } else if model == 2 {
|
|
|
+ o_entniche, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "s_userid": userId,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ })
|
|
|
+ }
|
|
|
//
|
|
|
- o_entniche, _ := util.MQFW.FindById("user", userId, `{"o_entniche":1}`)
|
|
|
+ // o_entniche, _ := util.MQFW.FindById("user", userId, `{"o_entniche":1}`)
|
|
|
delete(*o_entniche, "_id")
|
|
|
if len(*o_entniche) > 0 {
|
|
|
entniche := (*o_entniche)["o_entniche"].(map[string]interface{})
|
|
@@ -79,8 +93,23 @@ func (ac *Action) Subscribe_index() error {
|
|
|
//区域
|
|
|
func (ac *Action) Get_area() error {
|
|
|
userId := qutil.ObjToString(ac.GetSession("userId"))
|
|
|
- res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.o_area":1}`)
|
|
|
- if !ok || len(*res) == 0 || res == nil {
|
|
|
+ //res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.o_area":1}`)
|
|
|
+ entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
|
|
|
+ model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
|
|
|
+ var res *map[string]interface{}
|
|
|
+ switch model {
|
|
|
+ case 1:
|
|
|
+ res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "i_deptid": entInfo.Dept.Id,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ })
|
|
|
+ case 2:
|
|
|
+ res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "s_userid": userId,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if len(*res) == 0 || res == nil {
|
|
|
ac.ServeJson(Result{Error_code: util.Error_code})
|
|
|
return nil
|
|
|
}
|
|
@@ -91,8 +120,7 @@ func (ac *Action) Get_area() error {
|
|
|
log.Println("查看o_area:", data)
|
|
|
areacount := 0
|
|
|
newcitys := []string{}
|
|
|
- for k, v := range *data {
|
|
|
- log.Println(k, "---", v)
|
|
|
+ for _, v := range *data {
|
|
|
if len(v.([]interface{})) == 0 {
|
|
|
areacount++
|
|
|
} else {
|
|
@@ -115,7 +143,6 @@ func (ac *Action) Get_area() error {
|
|
|
|
|
|
//区域
|
|
|
func (ac *Action) Update_area() {
|
|
|
- userId := qutil.ObjToString(ac.GetSession("userId"))
|
|
|
status := 0
|
|
|
getarea := ac.Body()
|
|
|
area := map[string]interface{}{}
|
|
@@ -127,14 +154,12 @@ func (ac *Action) Update_area() {
|
|
|
return
|
|
|
}
|
|
|
log.Println("修改地区:", area)
|
|
|
- bl := util.MQFW.UpdateById("user", userId, bson.M{
|
|
|
- "$set": bson.M{"o_entniche.o_area": area},
|
|
|
- })
|
|
|
+ bl := ac.updateEntnicheRule("o_area", area)
|
|
|
+
|
|
|
if bl {
|
|
|
status = 1
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
ac.ServeJson(Result{Data: M{"status": status}})
|
|
|
return
|
|
|
}
|
|
@@ -143,8 +168,23 @@ func (ac *Action) Update_area() {
|
|
|
func (ac *Action) Get_buyerclass() {
|
|
|
userId := qutil.ObjToString(ac.GetSession("userId"))
|
|
|
data := []string{}
|
|
|
- res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.a_buyerclass":1}`)
|
|
|
- if !ok || len(*res) == 0 || res == nil {
|
|
|
+ entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
|
|
|
+ model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
|
|
|
+ // res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.a_buyerclass":1}`)
|
|
|
+ var res *map[string]interface{}
|
|
|
+ switch model {
|
|
|
+ case 1:
|
|
|
+ res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "i_deptid": entInfo.Dept.Id,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ })
|
|
|
+ case 2:
|
|
|
+ res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "s_userid": userId,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if len(*res) == 0 || res == nil {
|
|
|
ac.ServeJson(Result{Error_code: util.Error_code})
|
|
|
return
|
|
|
}
|
|
@@ -163,7 +203,6 @@ func (ac *Action) Get_buyerclass() {
|
|
|
|
|
|
//行业
|
|
|
func (ac *Action) Update_buyerclass() {
|
|
|
- userId := qutil.ObjToString(ac.GetSession("userId"))
|
|
|
status := 0
|
|
|
buyerclass_map := map[string]interface{}{}
|
|
|
buyerclass := []string{}
|
|
@@ -180,9 +219,7 @@ func (ac *Action) Update_buyerclass() {
|
|
|
buyerclass = qutil.ObjArrToStringArr(v.([]interface{}))
|
|
|
}
|
|
|
log.Println("修改行业:", buyerclass)
|
|
|
- bl := util.MQFW.UpdateById("user", userId, bson.M{
|
|
|
- "$set": bson.M{"o_entniche.a_buyerclass": buyerclass},
|
|
|
- })
|
|
|
+ bl := ac.updateEntnicheRule("a_buyerclass", buyerclass)
|
|
|
if bl {
|
|
|
status = 1
|
|
|
}
|
|
@@ -195,8 +232,23 @@ func (ac *Action) Update_buyerclass() {
|
|
|
func (ac *Action) Get_infotype() {
|
|
|
data := []string{}
|
|
|
userId := qutil.ObjToString(ac.GetSession("userId"))
|
|
|
- res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.a_infotype":1}`)
|
|
|
- if !ok || len(*res) == 0 || res == nil {
|
|
|
+ entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
|
|
|
+ model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
|
|
|
+ // res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.a_infotype":1}`)
|
|
|
+ var res *map[string]interface{}
|
|
|
+ switch model {
|
|
|
+ case 1:
|
|
|
+ res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "i_deptid": entInfo.Dept.Id,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ })
|
|
|
+ case 2:
|
|
|
+ res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "s_userid": userId,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if len(*res) == 0 || res == nil {
|
|
|
ac.ServeJson(Result{Error_code: util.Error_code})
|
|
|
return
|
|
|
}
|
|
@@ -215,7 +267,6 @@ func (ac *Action) Get_infotype() {
|
|
|
|
|
|
//信息类型
|
|
|
func (ac *Action) Update_infotype() {
|
|
|
- userId := qutil.ObjToString(ac.GetSession("userId"))
|
|
|
status := 0
|
|
|
infotype_map := map[string]interface{}{}
|
|
|
infotype := []string{}
|
|
@@ -231,9 +282,7 @@ func (ac *Action) Update_infotype() {
|
|
|
infotype = qutil.ObjArrToStringArr(v.([]interface{}))
|
|
|
}
|
|
|
log.Println("修改信息类型:", infotype)
|
|
|
- bl := util.MQFW.UpdateById("user", userId, bson.M{
|
|
|
- "$set": bson.M{"o_entniche.a_infotype": infotype},
|
|
|
- })
|
|
|
+ bl := ac.updateEntnicheRule("a_infotype", infotype)
|
|
|
if bl {
|
|
|
status = 1
|
|
|
}
|
|
@@ -244,17 +293,37 @@ func (ac *Action) Update_infotype() {
|
|
|
|
|
|
//关键词
|
|
|
func (ac *Action) Get_key() {
|
|
|
- //data:=[]string{}
|
|
|
data := []map[string]interface{}{}
|
|
|
status := 0 //显示快速导入关键词按钮 --0 不显示--1
|
|
|
userId := qutil.ObjToString(ac.GetSession("userId"))
|
|
|
- res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.a_items":1,"o_vipjy.a_items":1,"i_vip_status":1,"o_jy.a_key":1,"o_entniche.i_ent_fastimport":1}`)
|
|
|
+ // res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.a_items":1,"o_vipjy.a_items":1,"i_vip_status":1,"o_jy.a_key":1,"o_entniche.i_ent_fastimport":1}`)
|
|
|
+ res, ok := util.MQFW.FindById("user", userId, `{"o_vipjy.a_items":1,"i_vip_status":1,"o_jy.a_key":1}`)
|
|
|
if !ok || len(*res) == 0 || res == nil {
|
|
|
ac.ServeJson(Result{Error_code: util.Error_code})
|
|
|
return
|
|
|
}
|
|
|
delete(*res, "_id")
|
|
|
- o_entniche := qutil.ObjToMap((*res)["o_entniche"])
|
|
|
+ //查看是否使用过快速导入
|
|
|
+ entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
|
|
|
+ model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
|
|
|
+ var res_ *map[string]interface{}
|
|
|
+ switch model {
|
|
|
+ case 1:
|
|
|
+ res_, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "i_deptid": entInfo.Dept.Id,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ })
|
|
|
+ case 2:
|
|
|
+ res_, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "s_userid": userId,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if len(*res_) == 0 || res_ == nil {
|
|
|
+ ac.ServeJson(Result{Error_code: util.Error_code})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ o_entniche := qutil.ObjToMap((*res_)["o_entniche"])
|
|
|
i_ent_fastimport := qutil.IntAll((*o_entniche)["i_ent_fastimport"])
|
|
|
if i_ent_fastimport == 1 {
|
|
|
status = 1
|
|
@@ -328,10 +397,30 @@ func (ac *Action) Update_key() {
|
|
|
ac.ServeJson(Result{Data: M{"status": status}})
|
|
|
return
|
|
|
}
|
|
|
+ //分类名有分发规则
|
|
|
+ distribute_items := []string{}
|
|
|
+ list_items, _ := util.MQFW.Find(util.Entniche_distribute, map[string]interface{}{
|
|
|
+ "s_userid": userId,
|
|
|
+ }, nil, nil, false, -1, -1)
|
|
|
+ if len(*list_items) > 0 {
|
|
|
+ for _, n := range *list_items {
|
|
|
+ if len(n["a_items"].([]interface{})) > 0 {
|
|
|
+ for _, y := range n["a_items"].([]interface{}) {
|
|
|
+ distribute_items = append(distribute_items, qutil.ObjToString(y))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ isEqual := isEqualValue(new_item, deleteRepeat(distribute_items)) //查看分发规则库中是否有规则
|
|
|
+ if isEqual {
|
|
|
+ status = -2
|
|
|
+ ac.ServeJson(Result{Data: M{"status": status}})
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
- bl := util.MQFW.UpdateById("user", userId, bson.M{
|
|
|
- "$set": bson.M{"o_entniche.a_items": keywords["a_items"]},
|
|
|
- })
|
|
|
+
|
|
|
+ ac.updateEntnicheRule("a_items", keywords["a_items"])
|
|
|
+ bl := true
|
|
|
if bl {
|
|
|
status = 1
|
|
|
}
|
|
@@ -350,7 +439,7 @@ func (ac *Action) Get_fastimport() {
|
|
|
unclassified := "未分类"
|
|
|
a_items_ent := []map[string]interface{}{}
|
|
|
newOne := map[string]interface{}{}
|
|
|
- res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.a_items":1,"o_vipjy.a_items":1,"i_vip_status":1,"o_jy.a_key":1,"o_entniche.i_ent_fastimport":1}`)
|
|
|
+ res, ok := util.MQFW.FindById("user", userId, `{"o_vipjy.a_items":1,"i_vip_status":1,"o_jy.a_key":1}`)
|
|
|
if !ok || len(*res) == 0 || res == nil {
|
|
|
ac.ServeJson(Result{Error_code: util.Error_code})
|
|
|
return
|
|
@@ -361,8 +450,28 @@ func (ac *Action) Get_fastimport() {
|
|
|
a := map[string]int{} //分类 位置
|
|
|
b := map[string]bool{} //关键词
|
|
|
ent_hebing := []interface{}{}
|
|
|
+ //从entniche_rule中获取o_entniche
|
|
|
+ entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
|
|
|
+ model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
|
|
|
+ var res_ *map[string]interface{}
|
|
|
+ switch model {
|
|
|
+ case 1:
|
|
|
+ res_, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "i_deptid": entInfo.Dept.Id,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ })
|
|
|
+ case 2:
|
|
|
+ res_, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "s_userid": userId,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if len(*res_) == 0 || res_ == nil {
|
|
|
+ ac.ServeJson(Result{Error_code: util.Error_code})
|
|
|
+ return
|
|
|
+ }
|
|
|
//ent设置的关键词
|
|
|
- o_entniche := *qutil.ObjToMap((*res)["o_entniche"])
|
|
|
+ o_entniche := *qutil.ObjToMap((*res_)["o_entniche"])
|
|
|
i_ent_fastimport := o_entniche["i_ent_fastimport"]
|
|
|
//是否进行过快速导入
|
|
|
if i_ent_fastimport == 1 {
|
|
@@ -502,10 +611,33 @@ func (ac *Action) Get_fastimport() {
|
|
|
}
|
|
|
}
|
|
|
if canFastImport == 0 {
|
|
|
- ok := util.MQFW.UpdateById("user", userId, bson.M{
|
|
|
- "$set": bson.M{"o_entniche.a_items": a_items_ent, "o_entniche.i_ent_fastimport": 1},
|
|
|
- })
|
|
|
- if ok {
|
|
|
+ // ok := util.MQFW.UpdateById("user", userId, bson.M{
|
|
|
+ // "$set": bson.M{"o_entniche.a_items": a_items_ent, "o_entniche.i_ent_fastimport": 1},
|
|
|
+ // })
|
|
|
+ bl := false
|
|
|
+ if model == 1 {
|
|
|
+ bl = util.MQFW.Update("entniche_rule", bson.M{
|
|
|
+ "i_deptid": entInfo.Dept.Id,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ }, bson.M{
|
|
|
+ "$set": bson.M{
|
|
|
+ "o_entniche.a_items": a_items_ent,
|
|
|
+ "o_entniche.i_ent_fastimport": 1,
|
|
|
+ },
|
|
|
+ }, false, false)
|
|
|
+ } else if model == 2 {
|
|
|
+ bl = util.MQFW.Update("entniche_rule", bson.M{
|
|
|
+ "s_userid": userId,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ }, bson.M{
|
|
|
+ "$set": bson.M{
|
|
|
+ "o_entniche.a_items": a_items_ent,
|
|
|
+ "o_entniche.i_ent_fastimport": 1,
|
|
|
+ },
|
|
|
+ }, false, false)
|
|
|
+ }
|
|
|
+
|
|
|
+ if bl {
|
|
|
status = 1
|
|
|
}
|
|
|
}
|
|
@@ -514,13 +646,10 @@ func (ac *Action) Get_fastimport() {
|
|
|
|
|
|
//修改项目匹配设置
|
|
|
func (ac *Action) Update_projectmatch() {
|
|
|
- userId := qutil.ObjToString(ac.GetSession("userId"))
|
|
|
status := 0
|
|
|
projectmatch, _ := ac.GetInteger("projectmatch")
|
|
|
log.Println("修改项目匹配设置为:", projectmatch)
|
|
|
- bl := util.MQFW.UpdateById("user", userId, bson.M{
|
|
|
- "$set": bson.M{"o_entniche.i_projectmatch": projectmatch},
|
|
|
- })
|
|
|
+ bl := ac.updateEntnicheRule("i_projectmatch", projectmatch)
|
|
|
if bl {
|
|
|
status = 1
|
|
|
}
|
|
@@ -532,8 +661,23 @@ func (ac *Action) Update_projectmatch() {
|
|
|
func (ac *Action) Get_pushset() {
|
|
|
data := map[string]interface{}{}
|
|
|
userId := qutil.ObjToString(ac.GetSession("userId"))
|
|
|
- res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.i_ratemode":1,"o_entniche.i_apppush":1,"o_entniche.i_mailpush":1,"o_entniche.i_matchway":1}`)
|
|
|
- if !ok || len(*res) == 0 || res == nil {
|
|
|
+ // res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.i_ratemode":1,"o_entniche.i_apppush":1,"o_entniche.i_mailpush":1,"o_entniche.i_matchway":1}`)
|
|
|
+ entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
|
|
|
+ model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
|
|
|
+ var res *map[string]interface{}
|
|
|
+ switch model {
|
|
|
+ case 1:
|
|
|
+ res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "i_deptid": entInfo.Dept.Id,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ })
|
|
|
+ case 2:
|
|
|
+ res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "s_userid": userId,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if len(*res) == 0 || res == nil {
|
|
|
ac.ServeJson(Result{Error_code: util.Error_code})
|
|
|
return
|
|
|
}
|
|
@@ -551,19 +695,84 @@ func (ac *Action) Get_pushset() {
|
|
|
|
|
|
//推送设置
|
|
|
func (ac *Action) Update_pushset() {
|
|
|
+ bl := false
|
|
|
+ rules := map[string]interface{}{}
|
|
|
userId := qutil.ObjToString(ac.GetSession("userId"))
|
|
|
- log.Println(userId)
|
|
|
+ entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
|
|
|
+ model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
|
|
|
+ dept_id := entInfo.Dept.Id
|
|
|
status := 0
|
|
|
ratemode, _ := ac.GetInteger("ratemode")
|
|
|
apppush, _ := ac.GetInteger("apppush")
|
|
|
mailpush, _ := ac.GetInteger("mailpush")
|
|
|
matchway, _ := ac.GetInteger("matchway")
|
|
|
- bl := util.MQFW.UpdateById("user", userId, bson.M{"$set": bson.M{
|
|
|
- `o_entniche.i_ratemode`: ratemode,
|
|
|
- `o_entniche.i_apppush`: apppush,
|
|
|
- `o_entniche.i_mailpush`: mailpush,
|
|
|
- `o_entniche.i_matchway`: matchway,
|
|
|
- }})
|
|
|
+ switch model {
|
|
|
+ case 1:
|
|
|
+ rule, _ := util.MQFW.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "i_deptid": dept_id,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ })
|
|
|
+ if len(*rule) > 0 {
|
|
|
+ bl = util.MQFW.Update("entniche_rule", bson.M{
|
|
|
+ "i_deptid": entInfo.Dept.Id,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ }, bson.M{
|
|
|
+ "$set": bson.M{
|
|
|
+ `o_entniche.i_ratemode`: ratemode,
|
|
|
+ `o_entniche.i_apppush`: apppush,
|
|
|
+ `o_entniche.i_mailpush`: mailpush,
|
|
|
+ `o_entniche.i_matchway`: matchway,
|
|
|
+ },
|
|
|
+ }, false, false)
|
|
|
+ } else {
|
|
|
+ rules["s_userid"] = userId
|
|
|
+ rules["i_entid"] = qutil.IntAll(ac.GetSession("entId"))
|
|
|
+ rules["l_createtime"] = time.Now().Unix()
|
|
|
+ rules["o_entniche"] = bson.M{
|
|
|
+ `o_entniche.i_ratemode`: ratemode,
|
|
|
+ `o_entniche.i_apppush`: apppush,
|
|
|
+ `o_entniche.i_mailpush`: mailpush,
|
|
|
+ `o_entniche.i_matchway`: matchway,
|
|
|
+ } //entniche_rule
|
|
|
+ rules["i_deptid"] = dept_id
|
|
|
+
|
|
|
+ if util.MQFW.Save("entniche_rule", rules) != "" {
|
|
|
+ bl = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ case 2:
|
|
|
+ rule, _ := util.MQFW.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "s_userid": userId,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ })
|
|
|
+ if len(*rule) > 0 {
|
|
|
+ bl = util.MQFW.Update("entniche_rule", bson.M{
|
|
|
+ "s_userid": userId,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ }, bson.M{
|
|
|
+ "$set": bson.M{
|
|
|
+ `o_entniche.i_ratemode`: ratemode,
|
|
|
+ `o_entniche.i_apppush`: apppush,
|
|
|
+ `o_entniche.i_mailpush`: mailpush,
|
|
|
+ `o_entniche.i_matchway`: matchway,
|
|
|
+ },
|
|
|
+ }, false, false)
|
|
|
+ } else {
|
|
|
+ rules["s_userid"] = userId
|
|
|
+ rules["i_entid"] = qutil.IntAll(ac.GetSession("entId"))
|
|
|
+ rules["l_createtime"] = time.Now().Unix()
|
|
|
+ rules["o_entniche"] = bson.M{
|
|
|
+ `o_entniche.i_ratemode`: ratemode,
|
|
|
+ `o_entniche.i_apppush`: apppush,
|
|
|
+ `o_entniche.i_mailpush`: mailpush,
|
|
|
+ `o_entniche.i_matchway`: matchway,
|
|
|
+ } //entniche_rule
|
|
|
+ rules["i_deptid"] = dept_id
|
|
|
+ if util.MQFW.Save("entniche_rule", rules) != "" {
|
|
|
+ bl = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if bl {
|
|
|
status = 1
|
|
|
}
|
|
@@ -600,21 +809,34 @@ func isRepeat(slice1 []string) bool {
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
-//两个数组合并去重
|
|
|
-func removalRepeat(slice1, slice2 []interface{}) []interface{} {
|
|
|
+//去重
|
|
|
+func deleteRepeat(slice []string) []string {
|
|
|
+ m := make(map[string]int)
|
|
|
+ slice_repeat := []string{}
|
|
|
+ for _, v := range slice {
|
|
|
+ m[v]++
|
|
|
+ }
|
|
|
+ for x, _ := range m {
|
|
|
+ slice_repeat = append(slice_repeat, qutil.ObjToString(x))
|
|
|
+ }
|
|
|
+ return slice_repeat
|
|
|
+}
|
|
|
+
|
|
|
+//两个数组是否有相等的值
|
|
|
+func isEqualValue(slice1, slice2 []string) bool {
|
|
|
m := make(map[interface{}]int)
|
|
|
- slice := []interface{}{}
|
|
|
for _, v := range slice1 {
|
|
|
m[v]++
|
|
|
}
|
|
|
for _, v := range slice2 {
|
|
|
- //m[v]++
|
|
|
m[v]++
|
|
|
}
|
|
|
- for x, _ := range m {
|
|
|
- slice = append(slice, x)
|
|
|
+ for _, y := range m {
|
|
|
+ if y > 1 {
|
|
|
+ return true
|
|
|
+ }
|
|
|
}
|
|
|
- return slice
|
|
|
+ return false
|
|
|
}
|
|
|
|
|
|
//判断数组是否包含
|
|
@@ -626,3 +848,61 @@ func IsContain(slice []string, s string) bool {
|
|
|
}
|
|
|
return false
|
|
|
}
|
|
|
+
|
|
|
+//修改或新增 entniche_rule 表的 entinfo 信息 parameter_name参数名 parameter参数
|
|
|
+func (ac *Action) updateEntnicheRule(parameter_name string, parameter interface{}) bool {
|
|
|
+ bl := false
|
|
|
+ rules := map[string]interface{}{}
|
|
|
+ userId := qutil.ObjToString(ac.GetSession("userId"))
|
|
|
+ entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
|
|
|
+ model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
|
|
|
+ switch model {
|
|
|
+ case 1:
|
|
|
+ rule, _ := util.MQFW.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "i_deptid": entInfo.Dept.Id,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ })
|
|
|
+ if len(*rule) > 0 {
|
|
|
+ bl = util.MQFW.Update("entniche_rule", bson.M{
|
|
|
+ "i_deptid": entInfo.Dept.Id,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ }, bson.M{
|
|
|
+ "$set": bson.M{"o_entniche." + parameter_name: parameter},
|
|
|
+ }, false, false)
|
|
|
+ } else {
|
|
|
+ rules["s_userid"] = userId
|
|
|
+ rules["i_entid"] = qutil.IntAll(ac.GetSession("entId"))
|
|
|
+ rules["l_createtime"] = time.Now().Unix()
|
|
|
+ rules["o_entniche"] = bson.M{parameter_name: parameter} //entniche_rule
|
|
|
+ rules["i_deptid"] = entInfo.Dept.Id
|
|
|
+
|
|
|
+ if util.MQFW.Save("entniche_rule", rules) != "" {
|
|
|
+ bl = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ case 2:
|
|
|
+ rule, _ := util.MQFW.FindOne("entniche_rule", map[string]interface{}{
|
|
|
+ "s_userid": userId,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ })
|
|
|
+ if len(*rule) > 0 {
|
|
|
+ bl = util.MQFW.Update("entniche_rule", bson.M{
|
|
|
+ "s_userid": userId,
|
|
|
+ "i_entid": qutil.IntAll(ac.GetSession("entId")),
|
|
|
+ }, bson.M{
|
|
|
+ "$set": bson.M{"o_entniche." + parameter_name: parameter},
|
|
|
+ }, false, false)
|
|
|
+ } else {
|
|
|
+ rules["s_userid"] = userId
|
|
|
+ rules["i_entid"] = qutil.IntAll(ac.GetSession("entId"))
|
|
|
+ rules["l_createtime"] = time.Now().Unix()
|
|
|
+ rules["o_entniche"] = bson.M{parameter_name: parameter} //entniche_rule
|
|
|
+ rules["i_deptid"] = entInfo.Dept.Id
|
|
|
+
|
|
|
+ if util.MQFW.Save("entniche_rule", rules) != "" {
|
|
|
+ bl = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return bl
|
|
|
+}
|