|
@@ -14,6 +14,7 @@ import com.adealink.weparty.module.profile.data.UserConfigType
|
|
|
import com.adealink.weparty.module.profile.data.UserConfigType.Companion.NECESSARY_USER_ATTR_SET
|
|
import com.adealink.weparty.module.profile.data.UserConfigType.Companion.NECESSARY_USER_ATTR_SET
|
|
|
import com.adealink.weparty.module.profile.data.UserInfo
|
|
import com.adealink.weparty.module.profile.data.UserInfo
|
|
|
import com.adealink.weparty.module.profile.listener.IProfileListener
|
|
import com.adealink.weparty.module.profile.listener.IProfileListener
|
|
|
|
|
+import com.adealink.weparty.profile.data.GetUserinfoReq
|
|
|
import com.adealink.weparty.profile.datasource.remote.ProfileHttpService
|
|
import com.adealink.weparty.profile.datasource.remote.ProfileHttpService
|
|
|
import com.adealink.weparty.storage.AppPref
|
|
import com.adealink.weparty.storage.AppPref
|
|
|
|
|
|
|
@@ -117,15 +118,19 @@ class ProfileManager : BaseFrame<IProfileListener>(), IProfileManager {
|
|
|
"ProfileManager.getUserInfoByUid, uid:${uid}, reqAttrSet:${reqAttrSet.map { it.type }}"
|
|
"ProfileManager.getUserInfoByUid, uid:${uid}, reqAttrSet:${reqAttrSet.map { it.type }}"
|
|
|
)
|
|
)
|
|
|
return when (val result =
|
|
return when (val result =
|
|
|
- profileHttpService.getUserInfoByUid(uid, reqAttrSet.map { it.type })) {
|
|
|
|
|
|
|
+ profileHttpService.getUserInfosByUid(GetUserinfoReq(listOf(uid)))) {
|
|
|
is Rlt.Success -> {
|
|
is Rlt.Success -> {
|
|
|
- val info = result.data.data ?: return Rlt.Failed(CommonDataNullError())
|
|
|
|
|
|
|
+ val res = result.data.data ?: return Rlt.Failed(CommonDataNullError())
|
|
|
|
|
+ val userInfo = res.list.firstOrNull()
|
|
|
|
|
+ if (userInfo == null) {
|
|
|
|
|
+ return Rlt.Failed(CommonDataNullError())
|
|
|
|
|
+ }
|
|
|
if (uid == getMyUid()) {
|
|
if (uid == getMyUid()) {
|
|
|
- setMyUserInfo(info, reqAttrSet)
|
|
|
|
|
|
|
+ setMyUserInfo(userInfo, reqAttrSet)
|
|
|
} else {
|
|
} else {
|
|
|
- updateUserInfoCache(uid, info, reqAttrSet)//2
|
|
|
|
|
|
|
+ updateUserInfoCache(uid, userInfo, reqAttrSet)
|
|
|
}
|
|
}
|
|
|
- Rlt.Success(info)
|
|
|
|
|
|
|
+ Rlt.Success(userInfo)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
is Rlt.Failed -> {
|
|
is Rlt.Failed -> {
|
|
@@ -170,56 +175,21 @@ class ProfileManager : BaseFrame<IProfileListener>(), IProfileManager {
|
|
|
addAll(it)
|
|
addAll(it)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- val rlt = profileHttpService.getUserInfosByUid(reqUidList, reqAttrSet.map { it.type })
|
|
|
|
|
|
|
+ val rlt = profileHttpService.getUserInfosByUid(GetUserinfoReq(reqUidList))
|
|
|
if (rlt is Rlt.Success) {
|
|
if (rlt is Rlt.Success) {
|
|
|
- val getUserInfoResList = rlt.data.data
|
|
|
|
|
- getUserInfoResList?.forEach {
|
|
|
|
|
- userInfoMap[it.uid] = it.userInfo
|
|
|
|
|
- if (it.uid == AccountModule.uid) {
|
|
|
|
|
- setMyUserInfo(it.userInfo, reqAttrSet)
|
|
|
|
|
|
|
+ val getUserInfoResList = rlt.data.data?.list
|
|
|
|
|
+ getUserInfoResList?.forEach {userInfo->
|
|
|
|
|
+ userInfoMap[userInfo.uid] = userInfo
|
|
|
|
|
+ if (userInfo.uid == AccountModule.uid) {
|
|
|
|
|
+ setMyUserInfo(userInfo, reqAttrSet)
|
|
|
} else {
|
|
} else {
|
|
|
- updateUserInfoCache(it.uid, it.userInfo, reqAttrSet)//3
|
|
|
|
|
|
|
+ updateUserInfoCache(userInfo.uid, userInfo, reqAttrSet)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return Rlt.Success(userInfoMap)
|
|
return Rlt.Success(userInfoMap)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- override suspend fun getUserInfoByGoodOrShortId(id: String): Rlt<UserInfo> {
|
|
|
|
|
- return when (val result = profileHttpService.getUserInfoById(id)) {
|
|
|
|
|
- is Rlt.Success -> {
|
|
|
|
|
- val userInfo = result.data.data
|
|
|
|
|
- if (userInfo == null) {
|
|
|
|
|
- Rlt.Failed(CommonDataNullError())
|
|
|
|
|
- } else {
|
|
|
|
|
- Rlt.Success(userInfo)
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- is Rlt.Failed -> result
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- override suspend fun getUsersInfoBySids(
|
|
|
|
|
- sidList: List<String>,
|
|
|
|
|
- attrSet: Set<UserConfigType>?
|
|
|
|
|
- ): Rlt<List<UserInfo>> {
|
|
|
|
|
- return when (val result =
|
|
|
|
|
- profileHttpService.getUserInfoListBySids(sidList, attrSet?.map { it.type })) {
|
|
|
|
|
- is Rlt.Success -> {
|
|
|
|
|
- val data = result.data.data
|
|
|
|
|
- if (data == null) {
|
|
|
|
|
- Rlt.Failed(CommonDataNullError())
|
|
|
|
|
- } else {
|
|
|
|
|
- Rlt.Success(data.map { it.userInfo })
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- is Rlt.Failed -> result
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private fun updateUserInfoCache(
|
|
private fun updateUserInfoCache(
|
|
|
uid: String,
|
|
uid: String,
|
|
|
userInfo: UserInfo,
|
|
userInfo: UserInfo,
|