wangchuanjin 2 жил өмнө
parent
commit
e3bddd12e0
1 өөрчлөгдсөн 6 нэмэгдсэн , 5 устгасан
  1. 6 5
      public/public.go

+ 6 - 5
public/public.go

@@ -278,21 +278,22 @@ func isEmail(value string) bool {
 	return emailPattern.MatchString(value)
 }
 
-func GetCompatibleUser(mgo *MongodbSim, userId string, field map[string]int) *map[string]interface{} {
+func GetCompatibleUser(mgo *MongodbSim, sessVal map[string]interface{}, field map[string]int) *map[string]interface{} {
 	user := map[string]interface{}{}
 	if field == nil || len(field) == 0 {
 		return &user
 	}
 	field["_id"] = 0
-	if IsObjectIdHex(userId) {
-		temp, ok := mgo.FindById("user", userId, field)
+	if util.IntAll(sessVal["positionType"]) == 0 {
+		temp, ok := mgo.FindById("user", util.ObjToString(sessVal["userId"]), field)
 		if ok && temp != nil && len(*temp) > 0 {
 			user = *temp
 		}
 	} else {
+		entUserId := sessVal["entUserId"]
 		if field["o_entniche"] > 0 || field["o_vipjy"] > 0 || field["o_member_jy"] > 0 || field["o_jy"] > 0 {
 			entniche_rule, ok := mgo.Find("entniche_rule", map[string]interface{}{
-				"i_userid": util.IntAll(userId),
+				"i_userid": entUserId,
 			}, nil, `{"o_entniche":1}`, false, -1, -1)
 			if ok && entniche_rule != nil && len(*entniche_rule) > 0 {
 				for _, v := range *entniche_rule {
@@ -321,7 +322,7 @@ func GetCompatibleUser(mgo *MongodbSim, userId string, field map[string]int) *ma
 		delete(field, "o_member_jy")
 		delete(field, "o_entniche")
 		ent_user, ok := mgo.FindOneByField("ent_user", map[string]interface{}{
-			"i_userid": util.IntAll(userId),
+			"i_userid": entUserId,
 		}, field)
 		if ok && ent_user != nil && len(*ent_user) > 0 {
 			for k, v := range *ent_user {