Browse Source

新增根据baseUid获取个人身份信息

zhangxinlei1996 2 years ago
parent
commit
f9948e9ebe
1 changed files with 21 additions and 0 deletions
  1. 21 0
      p/public.go

+ 21 - 0
p/public.go

@@ -745,3 +745,24 @@ func MonitorTimeOut(pool chan bool, timeout time.Duration, warn string, f func()
 	}
 	return true
 }
+
+//根据baseUserId获取个人身份信息
+func GetPersonalIdentityByBaseUserId(base, main *Mysql, baseUserId int64) *IdentityInfo {
+	if baseUserId == 0 {
+		return nil
+	}
+	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
+}