浏览代码

feat: 新增获取个人信息的方法

zhangxinlei1996 2 年之前
父节点
当前提交
34152acf17
共有 1 个文件被更改,包括 26 次插入0 次删除
  1. 26 0
      p/public.go

+ 26 - 0
p/public.go

@@ -766,3 +766,29 @@ func GetPersonalIdentityByBaseUserId(base, main *Mysql, baseUserId int64) *Ident
 	}
 	return nil
 }
+
+//根据MONGOUSERID获取个人身份信息
+func GetPersonalIdentityByMgoId(base *Mysql, mgo *MongodbSim, userId string) *IdentityInfo {
+	if userId == "" {
+		return nil
+	}
+	data, ok := mgo.FindById("user", userId, `{"base_user_id":1}`)
+	if !ok || data == nil || len(*data) == 0 {
+		return nil
+	}
+	baseUserId := util.Int64All((*data)["base_user_id"])
+	list := base.SelectBySql(`select a.id as position_id , b.person_id ,a.type as position_type, a.account_id,a.person_name from base_position a 
+							inner join base_account b on (a.account_id=b.id  and a.user_id=? and a.type=0) limit 1`, baseUserId)
+	if list != nil && len(*list) == 1 {
+		identity := &IdentityInfo{
+			PersonId:     Int64All((*list)[0]["person_id"]),
+			UserName:     ObjToString((*list)[0]["person_name"]),
+			AccountId:    Int64All((*list)[0]["account_id"]),
+			PositionId:   Int64All((*list)[0]["position_id"]),
+			PositionType: Int64All((*list)[0]["position_type"]),
+			UserId:       baseUserId,
+		}
+		return identity
+	}
+	return nil
+}