|
@@ -278,30 +278,56 @@ func isEmail(value string) bool {
|
|
|
return emailPattern.MatchString(value)
|
|
|
}
|
|
|
|
|
|
-func GetAllSubSet(mgo *MongodbSim, userId string) *map[string]interface{} {
|
|
|
+func GetAllSubSet(mgo *MongodbSim, userId string, 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, `{"o_member_jy":1,"o_vipjy":1,"o_jy":1}`)
|
|
|
+ temp, ok := mgo.FindById("user", userId, field)
|
|
|
if ok && temp != nil && len(*temp) > 0 {
|
|
|
user = *temp
|
|
|
}
|
|
|
} else {
|
|
|
- entniche_rule, ok := mgo.Find("entniche_rule", map[string]interface{}{
|
|
|
- "i_userid": util.IntAll(userId),
|
|
|
- }, nil, `{"o_entniche":1}`, false, -1, -1)
|
|
|
- if ok && entniche_rule != nil && len(*entniche_rule) > 0 {
|
|
|
- for _, v := range *entniche_rule {
|
|
|
- i_type := util.IntAll(v["i_type"])
|
|
|
- if i_type == 0 {
|
|
|
- user["o_entniche"] = v["o_entniche"]
|
|
|
- } else if i_type == 1 {
|
|
|
- user["o_vipjy"] = v["o_entniche"]
|
|
|
- user["o_member_jy"] = v["o_entniche"]
|
|
|
- } else if i_type == 2 {
|
|
|
- user["o_jy"] = v["o_entniche"]
|
|
|
+ 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),
|
|
|
+ }, nil, `{"o_entniche":1}`, false, -1, -1)
|
|
|
+ if ok && entniche_rule != nil && len(*entniche_rule) > 0 {
|
|
|
+ for _, v := range *entniche_rule {
|
|
|
+ i_type := util.IntAll(v["i_type"])
|
|
|
+ if i_type == 0 {
|
|
|
+ if field["o_entniche"] > 0 {
|
|
|
+ user["o_entniche"] = v["o_entniche"]
|
|
|
+ }
|
|
|
+ } else if i_type == 1 {
|
|
|
+ if field["o_vipjy"] > 0 {
|
|
|
+ user["o_vipjy"] = v["o_entniche"]
|
|
|
+ }
|
|
|
+ if field["o_member_jy"] > 0 {
|
|
|
+ user["o_member_jy"] = v["o_entniche"]
|
|
|
+ }
|
|
|
+ } else if i_type == 2 {
|
|
|
+ if field["o_jy"] > 0 {
|
|
|
+ user["o_jy"] = v["o_entniche"]
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ delete(field, "o_jy")
|
|
|
+ delete(field, "o_vipjy")
|
|
|
+ delete(field, "o_member_jy")
|
|
|
+ delete(field, "o_entniche")
|
|
|
+ ent_user, ok := mgo.FindOneByField("ent_user", map[string]interface{}{
|
|
|
+ "i_userid": util.IntAll(userId),
|
|
|
+ }, field)
|
|
|
+ if ok && ent_user != nil && len(*ent_user) > 0 {
|
|
|
+ for k, v := range *ent_user {
|
|
|
+ user[k] = v
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return &user
|
|
|
}
|