Selaa lähdekoodia

feat:增加方法

wangchuanjin 1 vuosi sitten
vanhempi
commit
f6dc3c09dc
1 muutettua tiedostoa jossa 15 lisäystä ja 0 poistoa
  1. 15 0
      p/struct.go

+ 15 - 0
p/struct.go

@@ -246,6 +246,21 @@ func NewMyUserInfo(Mgo *MongodbSim, Base_service, Mysql *Mysql, userId string) *
 	return NewUserInfo(*user, 0)
 }
 
+//
+func NewMyUserInfoByEntUserId(Mgo *MongodbSim, Base_service, Mysql *Mysql, userId string) *UserInfo {
+	var user *map[string]interface{}
+	if IsObjectIdHex(userId) {
+		user, _ = Mgo.FindById(Mgo_User, userId, UserCollFields)
+	} else {
+		user = GetAllByEntUserId(Mgo, Mysql, util.IntAll(userId))
+	}
+	if user == nil || len(*user) == 0 {
+		logger.Error(userId, "没有找到该用户信息")
+		return nil
+	}
+	return NewUserInfo(*user, 0)
+}
+
 // 解析用户的推送设置
 func (u *UserInfo) GetPushSet(obj map[string]interface{}) {
 	subSet, _ := obj["o_subset"].(map[string]interface{})