浏览代码

feat:增加方法

wangchuanjin 1 年之前
父节点
当前提交
f6dc3c09dc
共有 1 个文件被更改,包括 15 次插入0 次删除
  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{})