瀏覽代碼

方法封装

wangchuanjin 2 年之前
父節點
當前提交
03edea7366
共有 3 個文件被更改,包括 342 次插入256 次删除
  1. 21 0
      p/constant.go
  2. 0 252
      p/public.go
  3. 321 4
      p/struct.go

+ 21 - 0
p/constant.go

@@ -55,4 +55,25 @@ var (
 	KeyRetainReg     = regexp.MustCompile("[\\p{Han}a-zA-Z0-9]")
 	SaveBiddingField = []string{"_id", "area", "city", "buyerclass", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "buyer", "bidamount", "budget", "projectname", "projectcode", "s_winner", "agency", "bidopentime", "attachment_count", "site", "buyertel", "buyerperson", "agencyperson", "agencytel", "winnerperson", "winnertel", "signendtime", "bidendtime", "entidlist"}
 	SpaceReg         = regexp.MustCompile("\\s+")
+	UserCollFields   = map[string]interface{}{
+		"_id":                 1,
+		"o_jy":                1,
+		"i_vip_status":        1,
+		"o_vipjy":             1,
+		"i_member_status":     1,
+		"o_member_jy":         1,
+		"o_pushset":           1,
+		"s_m_openid":          1,
+		"a_m_openid":          1,
+		"s_phone":             1,
+		"s_m_phone":           1,
+		"s_jpushid":           1,
+		"s_opushid":           1,
+		"i_ispush":            1,
+		"s_appponetype":       1,
+		"base_user_id":        1,
+		"i_mainaccount":       1,
+		"s_member_mainid":     1,
+		"i_member_sub_status": 1,
+	}
 )

+ 0 - 252
p/public.go

@@ -211,258 +211,6 @@ func GetInfoTitle(info *map[string]interface{}) string {
 	return title
 }
 
-//得到用户的关键词
-func GetKeySets(a_key interface{}) ([]*KeySet, error) {
-	var keySets []*KeySet
-	if a_key == nil {
-		return keySets, nil
-	}
-	_bs, err := json.Marshal(a_key)
-	if err == nil {
-		err = json.Unmarshal(_bs, &keySets)
-	}
-	if err != nil {
-		return keySets, err
-	}
-	for _, v := range keySets {
-		if v == nil {
-			continue
-		}
-		keys, appendKeys, notKeys := []string{}, []string{}, []string{}
-		for _, vv := range v.Keys {
-			keys = append(keys, SpaceReg.Split(strings.TrimSpace(vv), -1)...)
-		}
-		for _, vv := range v.AppendKeys {
-			appendKeys = append(appendKeys, SpaceReg.Split(strings.TrimSpace(vv), -1)...)
-		}
-		for _, vv := range v.NotKeys {
-			notKeys = append(notKeys, SpaceReg.Split(strings.TrimSpace(vv), -1)...)
-		}
-		v.Keys = keys
-		v.AppendKeys = appendKeys
-		v.NotKeys = notKeys
-	}
-	return keySets, err
-}
-
-//解析用户的推送设置
-func GetPushSet(userId string, obj map[string]interface{}) *PushSet {
-	subSet, _ := obj["o_subset"].(map[string]interface{})
-	times, _ := subSet["a_times"].([]interface{})
-	weekReport, _ := obj["o_week_report"].(map[string]interface{})
-	monthReport, _ := obj["o_month_report"].(map[string]interface{})
-	newprojectForecast, _ := obj["o_newproject_forecast"].(map[string]interface{})
-	entInfo, _ := obj["o_entinfo"].(map[string]interface{})
-	followProject, _ := obj["o_follow_project"].(map[string]interface{})
-	followEnt, _ := obj["o_follow_ent"].(map[string]interface{})
-	pushSet := &PushSet{
-		Email: strings.TrimSpace(util.ObjToString(obj["s_email"])),
-		SubSet: &PushSetChild{
-			WxPush:   util.IntAllDef(subSet["i_wxpush"], 1),
-			AppPush:  util.IntAllDef(subSet["i_apppush"], 1),
-			MailPush: util.IntAll(subSet["i_mailpush"]),
-			RateMode: util.IntAllDef(subSet["i_ratemode"], 5),
-			Times:    util.ObjArrToStringArr(times),
-		},
-		WeekReport: &PushSetChild{
-			WxPush:   util.IntAllDef(weekReport["i_wxpush"], 1),
-			AppPush:  util.IntAllDef(weekReport["i_apppush"], 1),
-			MailPush: util.IntAll(weekReport["i_mailpush"]),
-		},
-		MonthReport: &PushSetChild{
-			WxPush:   util.IntAllDef(monthReport["i_wxpush"], 1),
-			AppPush:  util.IntAllDef(monthReport["i_apppush"], 1),
-			MailPush: util.IntAll(monthReport["i_mailpush"]),
-		},
-		NewprojectForecast: &PushSetChild{
-			WxPush:   util.IntAllDef(newprojectForecast["i_wxpush"], 1),
-			AppPush:  util.IntAllDef(newprojectForecast["i_apppush"], 1),
-			MailPush: util.IntAll(newprojectForecast["i_mailpush"]),
-		},
-		EntInfo: &PushSetChild{
-			WxPush:   util.IntAllDef(entInfo["i_wxpush"], 1),
-			AppPush:  util.IntAllDef(entInfo["i_apppush"], 1),
-			MailPush: util.IntAll(entInfo["i_mailpush"]),
-		},
-		FollowProject: &PushSetChild{
-			WxPush:   util.IntAllDef(followProject["i_wxpush"], 1),
-			AppPush:  util.IntAllDef(followProject["i_apppush"], 1),
-			MailPush: util.IntAll(followProject["i_mailpush"]),
-		},
-		FollowEnt: &PushSetChild{
-			WxPush:   util.IntAllDef(followEnt["i_wxpush"], 1),
-			AppPush:  util.IntAllDef(followEnt["i_apppush"], 1),
-			MailPush: util.IntAll(followEnt["i_mailpush"]),
-		},
-	}
-	if !MailReg.MatchString(pushSet.Email) {
-		pushSet.SubSet.MailPush = -1
-		pushSet.WeekReport.MailPush = -1
-		pushSet.MonthReport.MailPush = -1
-		pushSet.NewprojectForecast.MailPush = -1
-		pushSet.EntInfo.MailPush = -1
-		pushSet.FollowProject.MailPush = -1
-		pushSet.FollowEnt.MailPush = -1
-	}
-	return pushSet
-}
-
-//解析用户的订阅设置
-func GetSubSet(isFreeUser bool, userId string, obj map[string]interface{}) *SubSet {
-	subSet := &SubSet{
-		Keys:                  []string{},
-		Notkeys:               []string{},
-		Key_item:              map[string]string{},
-		Key_notkey:            map[string]map[string]bool{},
-		Key_area:              map[string]map[string]bool{},
-		Key_subtype:           map[string]map[string]bool{},
-		OriginalKeys:          []string{},
-		Areas:                 []string{},
-		Subtypes:              []string{},
-		Buyerclasss:           []string{},
-		MatchWay:              util.IntAllDef(obj["i_matchway"], 1),
-		Matchbuyerclass_other: util.IntAllDef(obj["i_matchbuyerclass_other"], 1),
-		ProjectMatch:          util.IntAll(obj["i_projectmatch"]),
-		MaxPushSize:           util.IntAll(obj["i_maxpushsize"]),
-		MaxMailSize:           util.IntAll(obj["i_maxmailsize"]),
-	}
-	var keySets []*KeySet
-	if isFreeUser {
-		var err error
-		keySets, err = GetKeySets(obj["a_key"])
-		if err != nil {
-			logger.Error("获取用户关键词错误!", userId, obj["a_key"], err)
-			return subSet
-		}
-		area := obj["o_area"]
-		if ppStatus := util.IntAll(obj["i_ppstatus"]); ppStatus == 1 {
-			area = obj["o_area_p"]
-		}
-		if newFree := util.IntAll(obj["i_newfree"]); newFree == 1 && area != nil {
-			subSet.IsUpgrade = true
-			subSet.Subtype, _ = obj["a_infotype"].([]interface{})
-			subSet.Area, _ = area.(map[string]interface{})
-		}
-	} else {
-		items, _ := obj["a_items"].([]interface{})
-		for _, v := range items {
-			item, _ := v.(map[string]interface{})
-			itemName := strings.TrimSpace(util.ObjToString(item["s_item"]))
-			subSet.Items = append(subSet.Items, itemName)
-			kss, err := GetKeySets(item["a_key"])
-			if err != nil {
-				logger.Error("获取用户关键词错误!", userId, item["a_key"], err)
-				continue
-			}
-			for _, vv := range kss {
-				if vv == nil {
-					continue
-				}
-				if vv.MatchWay == 1 {
-					for _, vvv := range vv.Keys {
-						keySets = append(keySets, &KeySet{
-							Item:    itemName,
-							Keys:    []string{vvv},
-							NotKeys: vv.NotKeys,
-						})
-					}
-					for _, vvv := range vv.AppendKeys {
-						keySets = append(keySets, &KeySet{
-							Item:    itemName,
-							Keys:    []string{vvv},
-							NotKeys: vv.NotKeys,
-						})
-					}
-				} else {
-					vv.Item = itemName
-					keySets = append(keySets, vv)
-				}
-			}
-		}
-		subSet.Buyerclass, _ = obj["a_buyerclass"].([]interface{})
-		subSet.Subtype, _ = obj["a_infotype"].([]interface{})
-		subSet.Area, _ = obj["o_area"].(map[string]interface{})
-	}
-	for _, v := range subSet.Buyerclass {
-		s_v, _ := v.(string)
-		if s_v == "" {
-			continue
-		}
-		subSet.Buyerclasss = append(subSet.Buyerclasss, s_v)
-	}
-	for _, v := range subSet.Subtype {
-		s_v, _ := v.(string)
-		if s_v == "" {
-			continue
-		}
-		subSet.Subtypes = append(subSet.Subtypes, s_v)
-	}
-	for area, _ := range subSet.Area {
-		if area == "" {
-			continue
-		}
-		subSet.Areas = append(subSet.Areas, area)
-	}
-	////////////////
-	for _, vs := range keySets {
-		if vs == nil {
-			logger.Error(userId, "关键词设置异常")
-			continue
-		}
-		var vs_keys []string
-		for _, vs_v := range [][]string{vs.Keys, vs.AppendKeys} {
-			for _, vs_vv := range vs_v {
-				vs_vv = strings.TrimSpace(vs_vv)
-				if vs_vv == "" {
-					continue
-				}
-				vs_keys = append(vs_keys, vs_vv)
-			}
-		}
-		if len(vs_keys) == 0 {
-			continue
-		}
-		key := strings.Join(vs_keys, "+")
-		subSet.OriginalKeys = append(subSet.OriginalKeys, key)
-		if KeyFilterReg.MatchString(key) {
-			continue
-		} else if !KeyRetainReg.MatchString(key) {
-			continue
-		}
-		subSet.Keys = append(subSet.Keys, key)
-		subSet.Notkeys = append(subSet.Notkeys, vs.NotKeys...)
-		//转大写
-		upperKey := strings.ToUpper(key)
-		subSet.Key_item[upperKey] = vs.Item
-		//建立与排除词的对应关系
-		for _, notkey := range vs.NotKeys {
-			upperNotkey := strings.ToUpper(notkey)
-			if subSet.Key_notkey[upperKey] == nil {
-				subSet.Key_notkey[upperKey] = map[string]bool{}
-			}
-			subSet.Key_notkey[upperKey][upperNotkey] = true
-		}
-		//免费用户需要进行映射
-		if isFreeUser {
-			//建立与信息范围的对应关系
-			for _, area := range vs.Areas {
-				if subSet.Key_area[upperKey] == nil {
-					subSet.Key_area[upperKey] = map[string]bool{}
-				}
-				subSet.Key_area[upperKey][area] = true
-			}
-			//建立与信息类型的对应关系
-			for _, subtype := range vs.SubTypes {
-				if subSet.Key_subtype[upperKey] == nil {
-					subSet.Key_subtype[upperKey] = map[string]bool{}
-				}
-				subSet.Key_subtype[upperKey][subtype] = true
-			}
-		}
-	}
-	return subSet
-}
-
 //加载数据到内存中
 func LoadBidding(mgo *MongodbSim, dbName, coll string, startTime int64, redisCache bool) (*[]map[string]interface{}, int64) {
 	defer util.Catch()

+ 321 - 4
p/struct.go

@@ -1,10 +1,13 @@
 package p
 
 import (
+	"encoding/json"
 	"strings"
 
 	util "app.yhyue.com/moapp/jybase/common"
+	. "app.yhyue.com/moapp/jybase/mongodb"
 	"bp.jydev.jianyu360.cn/BaseService/pushpkg/dfa"
+	"github.com/donnie4w/go-logger/logger"
 )
 
 //
@@ -132,12 +135,326 @@ type UserInfo struct {
 	Extend           *UserInfoExtend
 }
 
+/*
+ *获取用户信息
+ *temp 用户数据
+ *tp 1-免费 2-超级订阅 3-大会员
+ */
+func NewUserInfo(temp map[string]interface{}, tp int) *UserInfo {
+	ui := &UserInfo{
+		Id:           BsonIdToSId(temp["_id"]),
+		BaseUserId:   util.Int64All(temp["base_user_id"]),
+		S_m_openid:   util.ObjToString(temp["s_m_openid"]),
+		A_m_openid:   util.ObjToString(temp["a_m_openid"]),
+		Phone:        GetPhone(temp),
+		Jpushid:      util.ObjToString(temp["s_jpushid"]),
+		Opushid:      util.ObjToString(temp["s_opushid"]),
+		AppPhoneType: util.ObjToString(temp["s_appponetype"]),
+		Subscribe:    util.IntAllDef(temp["i_ispush"], 1),
+		VipStatus:    util.IntAll(temp["i_vip_status"]),
+		MemberStatus: util.IntAll(temp["i_member_status"]),
+	}
+	if ui.MemberStatus > 0 {
+		ui.IsMainAccount = util.IntAll(temp["i_mainaccount"]) == 1
+		ui.SonAccountStatus = util.IntAllDef(temp["i_member_sub_status"], -1)
+		ui.MemberMainid = util.ObjToString(temp["s_member_mainid"])
+	}
+	var obj map[string]interface{}
+	if tp == 3 {
+		obj, _ = temp["o_member_jy"].(map[string]interface{})
+	} else if tp == 2 {
+		obj, _ = temp["o_vipjy"].(map[string]interface{})
+	} else {
+		obj, _ = temp["o_jy"].(map[string]interface{})
+	}
+	ui.GetSubSet(tp == 1, ui.Id, obj)
+	o_pushset, _ := temp["o_pushset"].(map[string]interface{})
+	ui.GetPushSet(o_pushset)
+	return ui
+}
+
+//解析用户的推送设置
+func (u *UserInfo) GetPushSet(obj map[string]interface{}) {
+	subSet, _ := obj["o_subset"].(map[string]interface{})
+	times, _ := subSet["a_times"].([]interface{})
+	weekReport, _ := obj["o_week_report"].(map[string]interface{})
+	monthReport, _ := obj["o_month_report"].(map[string]interface{})
+	newprojectForecast, _ := obj["o_newproject_forecast"].(map[string]interface{})
+	entInfo, _ := obj["o_entinfo"].(map[string]interface{})
+	followProject, _ := obj["o_follow_project"].(map[string]interface{})
+	followEnt, _ := obj["o_follow_ent"].(map[string]interface{})
+	u.PushSet = &PushSet{
+		Email: strings.TrimSpace(util.ObjToString(obj["s_email"])),
+		SubSet: &PushSetChild{
+			WxPush:   util.IntAllDef(subSet["i_wxpush"], 1),
+			AppPush:  util.IntAllDef(subSet["i_apppush"], 1),
+			MailPush: util.IntAll(subSet["i_mailpush"]),
+			RateMode: util.IntAllDef(subSet["i_ratemode"], 5),
+			Times:    util.ObjArrToStringArr(times),
+		},
+		WeekReport: &PushSetChild{
+			WxPush:   util.IntAllDef(weekReport["i_wxpush"], 1),
+			AppPush:  util.IntAllDef(weekReport["i_apppush"], 1),
+			MailPush: util.IntAll(weekReport["i_mailpush"]),
+		},
+		MonthReport: &PushSetChild{
+			WxPush:   util.IntAllDef(monthReport["i_wxpush"], 1),
+			AppPush:  util.IntAllDef(monthReport["i_apppush"], 1),
+			MailPush: util.IntAll(monthReport["i_mailpush"]),
+		},
+		NewprojectForecast: &PushSetChild{
+			WxPush:   util.IntAllDef(newprojectForecast["i_wxpush"], 1),
+			AppPush:  util.IntAllDef(newprojectForecast["i_apppush"], 1),
+			MailPush: util.IntAll(newprojectForecast["i_mailpush"]),
+		},
+		EntInfo: &PushSetChild{
+			WxPush:   util.IntAllDef(entInfo["i_wxpush"], 1),
+			AppPush:  util.IntAllDef(entInfo["i_apppush"], 1),
+			MailPush: util.IntAll(entInfo["i_mailpush"]),
+		},
+		FollowProject: &PushSetChild{
+			WxPush:   util.IntAllDef(followProject["i_wxpush"], 1),
+			AppPush:  util.IntAllDef(followProject["i_apppush"], 1),
+			MailPush: util.IntAll(followProject["i_mailpush"]),
+		},
+		FollowEnt: &PushSetChild{
+			WxPush:   util.IntAllDef(followEnt["i_wxpush"], 1),
+			AppPush:  util.IntAllDef(followEnt["i_apppush"], 1),
+			MailPush: util.IntAll(followEnt["i_mailpush"]),
+		},
+	}
+	if u.Subscribe == 0 || u.S_m_openid == "" {
+		u.PushSet.SubSet.WxPush = -1
+		u.PushSet.WeekReport.WxPush = -1
+		u.PushSet.MonthReport.WxPush = -1
+		u.PushSet.NewprojectForecast.WxPush = -1
+		u.PushSet.EntInfo.WxPush = -1
+		u.PushSet.FollowProject.WxPush = -1
+		u.PushSet.FollowEnt.WxPush = -1
+	}
+	if u.Jpushid == "" && u.Opushid == "" {
+		u.PushSet.SubSet.AppPush = -1
+		u.PushSet.WeekReport.AppPush = -1
+		u.PushSet.MonthReport.AppPush = -1
+		u.PushSet.NewprojectForecast.AppPush = -1
+		u.PushSet.EntInfo.AppPush = -1
+		u.PushSet.FollowProject.AppPush = -1
+		u.PushSet.FollowEnt.AppPush = -1
+	}
+	mailPush := true
+	if (u.S_m_openid == "" || (u.S_m_openid != "" && u.Subscribe == 0)) && u.Phone == "" && u.A_m_openid == "" {
+		mailPush = false
+	} else if (u.S_m_openid == "" || (u.S_m_openid != "" && u.Subscribe == 0)) && u.Phone == "" && u.A_m_openid != "" && u.Jpushid == "" && u.Opushid == "" {
+		mailPush = false
+	} else if !MailReg.MatchString(u.PushSet.Email) {
+		mailPush = false
+	}
+	if !mailPush {
+		u.PushSet.SubSet.MailPush = -1
+		u.PushSet.WeekReport.MailPush = -1
+		u.PushSet.MonthReport.MailPush = -1
+		u.PushSet.NewprojectForecast.MailPush = -1
+		u.PushSet.EntInfo.MailPush = -1
+		u.PushSet.FollowProject.MailPush = -1
+		u.PushSet.FollowEnt.MailPush = -1
+	}
+}
+
+//解析用户的订阅设置
+func (u *UserInfo) GetSubSet(isFreeUser bool, userId string, obj map[string]interface{}) {
+	subSet := &SubSet{
+		Keys:                  []string{},
+		Notkeys:               []string{},
+		Key_item:              map[string]string{},
+		Key_notkey:            map[string]map[string]bool{},
+		Key_area:              map[string]map[string]bool{},
+		Key_subtype:           map[string]map[string]bool{},
+		OriginalKeys:          []string{},
+		Areas:                 []string{},
+		Subtypes:              []string{},
+		Buyerclasss:           []string{},
+		MatchWay:              util.IntAllDef(obj["i_matchway"], 1),
+		Matchbuyerclass_other: util.IntAllDef(obj["i_matchbuyerclass_other"], 1),
+		ProjectMatch:          util.IntAll(obj["i_projectmatch"]),
+		MaxPushSize:           util.IntAll(obj["i_maxpushsize"]),
+		MaxMailSize:           util.IntAll(obj["i_maxmailsize"]),
+	}
+	var keySets []*KeySet
+	if isFreeUser {
+		var err error
+		keySets, err = u.GetKeySets(obj["a_key"])
+		if err != nil {
+			logger.Error("获取用户关键词错误!", userId, obj["a_key"], err)
+			return
+		}
+		area := obj["o_area"]
+		if ppStatus := util.IntAll(obj["i_ppstatus"]); ppStatus == 1 {
+			area = obj["o_area_p"]
+		}
+		if newFree := util.IntAll(obj["i_newfree"]); newFree == 1 && area != nil {
+			subSet.IsUpgrade = true
+			subSet.Subtype, _ = obj["a_infotype"].([]interface{})
+			subSet.Area, _ = area.(map[string]interface{})
+		}
+	} else {
+		items, _ := obj["a_items"].([]interface{})
+		for _, v := range items {
+			item, _ := v.(map[string]interface{})
+			itemName := strings.TrimSpace(util.ObjToString(item["s_item"]))
+			subSet.Items = append(subSet.Items, itemName)
+			kss, err := u.GetKeySets(item["a_key"])
+			if err != nil {
+				logger.Error("获取用户关键词错误!", userId, item["a_key"], err)
+				continue
+			}
+			for _, vv := range kss {
+				if vv == nil {
+					continue
+				}
+				if vv.MatchWay == 1 {
+					for _, vvv := range vv.Keys {
+						keySets = append(keySets, &KeySet{
+							Item:    itemName,
+							Keys:    []string{vvv},
+							NotKeys: vv.NotKeys,
+						})
+					}
+					for _, vvv := range vv.AppendKeys {
+						keySets = append(keySets, &KeySet{
+							Item:    itemName,
+							Keys:    []string{vvv},
+							NotKeys: vv.NotKeys,
+						})
+					}
+				} else {
+					vv.Item = itemName
+					keySets = append(keySets, vv)
+				}
+			}
+		}
+		subSet.Buyerclass, _ = obj["a_buyerclass"].([]interface{})
+		subSet.Subtype, _ = obj["a_infotype"].([]interface{})
+		subSet.Area, _ = obj["o_area"].(map[string]interface{})
+	}
+	for _, v := range subSet.Buyerclass {
+		s_v, _ := v.(string)
+		if s_v == "" {
+			continue
+		}
+		subSet.Buyerclasss = append(subSet.Buyerclasss, s_v)
+	}
+	for _, v := range subSet.Subtype {
+		s_v, _ := v.(string)
+		if s_v == "" {
+			continue
+		}
+		subSet.Subtypes = append(subSet.Subtypes, s_v)
+	}
+	for area, _ := range subSet.Area {
+		if area == "" {
+			continue
+		}
+		subSet.Areas = append(subSet.Areas, area)
+	}
+	////////////////
+	for _, vs := range keySets {
+		if vs == nil {
+			logger.Error(userId, "关键词设置异常")
+			continue
+		}
+		var vs_keys []string
+		for _, vs_v := range [][]string{vs.Keys, vs.AppendKeys} {
+			for _, vs_vv := range vs_v {
+				vs_vv = strings.TrimSpace(vs_vv)
+				if vs_vv == "" {
+					continue
+				}
+				vs_keys = append(vs_keys, vs_vv)
+			}
+		}
+		if len(vs_keys) == 0 {
+			continue
+		}
+		key := strings.Join(vs_keys, "+")
+		subSet.OriginalKeys = append(subSet.OriginalKeys, key)
+		if KeyFilterReg.MatchString(key) {
+			continue
+		} else if !KeyRetainReg.MatchString(key) {
+			continue
+		}
+		subSet.Keys = append(subSet.Keys, key)
+		subSet.Notkeys = append(subSet.Notkeys, vs.NotKeys...)
+		//转大写
+		upperKey := strings.ToUpper(key)
+		subSet.Key_item[upperKey] = vs.Item
+		//建立与排除词的对应关系
+		for _, notkey := range vs.NotKeys {
+			upperNotkey := strings.ToUpper(notkey)
+			if subSet.Key_notkey[upperKey] == nil {
+				subSet.Key_notkey[upperKey] = map[string]bool{}
+			}
+			subSet.Key_notkey[upperKey][upperNotkey] = true
+		}
+		//免费用户需要进行映射
+		if isFreeUser {
+			//建立与信息范围的对应关系
+			for _, area := range vs.Areas {
+				if subSet.Key_area[upperKey] == nil {
+					subSet.Key_area[upperKey] = map[string]bool{}
+				}
+				subSet.Key_area[upperKey][area] = true
+			}
+			//建立与信息类型的对应关系
+			for _, subtype := range vs.SubTypes {
+				if subSet.Key_subtype[upperKey] == nil {
+					subSet.Key_subtype[upperKey] = map[string]bool{}
+				}
+				subSet.Key_subtype[upperKey][subtype] = true
+			}
+		}
+	}
+	u.SubSet = subSet
+}
+
+//得到用户的关键词
+func (u *UserInfo) GetKeySets(a_key interface{}) ([]*KeySet, error) {
+	var keySets []*KeySet
+	if a_key == nil {
+		return keySets, nil
+	}
+	_bs, err := json.Marshal(a_key)
+	if err == nil {
+		err = json.Unmarshal(_bs, &keySets)
+	}
+	if err != nil {
+		return keySets, err
+	}
+	for _, v := range keySets {
+		if v == nil {
+			continue
+		}
+		keys, appendKeys, notKeys := []string{}, []string{}, []string{}
+		for _, vv := range v.Keys {
+			keys = append(keys, SpaceReg.Split(strings.TrimSpace(vv), -1)...)
+		}
+		for _, vv := range v.AppendKeys {
+			appendKeys = append(appendKeys, SpaceReg.Split(strings.TrimSpace(vv), -1)...)
+		}
+		for _, vv := range v.NotKeys {
+			notKeys = append(notKeys, SpaceReg.Split(strings.TrimSpace(vv), -1)...)
+		}
+		v.Keys = keys
+		v.AppendKeys = appendKeys
+		v.NotKeys = notKeys
+	}
+	return keySets, err
+}
+
 //
 type Entniche struct {
-	EntId   int    //企业id
-	EntName string //企业名称
-	DeptId  int    //部门id
-	//DeptName     string //部门名称
+	EntId       int    //企业id
+	EntName     string //企业名称
+	DeptId      int    //部门id
 	DisId       string //分发id
 	UserId      int
 	Unique      string