def enrichUserInfo(matchRet, teamName): teamData = matchRet[teamName] newTeamData = [] for teamObj in teamData: obj = teamObj if teamObj.get('user_id', None) is not None: user_id = teamObj['user_id'] userInfo = getUserInfo({'user_id':user_id}) obj['user_info'] = userInfo['result'] if teamObj.get('hero_id', None) is not None: hero_id = teamObj['hero_id'] heroInfo = getHeroInfo({'hero_id':hero_id}) obj['hero_info'] = heroInfo['result'] if teamObj.get('item_id', None) is not None: itemList = [] for item_id in teamObj['item_id']: itemInfo = getItemInfo({'item_id':item_id}) if itemInfo['status'] == 'ok': itemList.append(itemInfo['result']) del obj['item_id'] obj['item_info'] = itemList if teamObj.get('accessory_id', None) is not None: accessoryList = [] for accessory_id in teamObj['accessory_id']: accessoryInfo = getAccessoryInfo({'accessory_id':accessory_id}) if accessoryInfo['status'] == 'ok': accessoryList.append(accessoryInfo['result']) del obj['accessory_id'] obj['accessory_info'] = accessoryList newTeamData.append(obj) matchRet[teamName] = newTeamData return matchRet
def getPlayerInfoByUser(data): _ret = {} userInfoRet = getUserInfo(data) if userInfoRet['status'] == 'failed': return userInfoRet serverInfoRet = getServerInfo({'server_id':userInfoRet['result']['server_id']}) if serverInfoRet['status'] == 'failed': return serverInfoRet matchCountRet = getMatchCountByUser(data) if matchCountRet['status'] == 'failed': return matchCountRet _ret['status'] = 'ok' _ret['msg'] = '' _ret['result'] = userInfoRet['result'] _ret['result']['server_info']= serverInfoRet['result'] _ret['result']['match_count'] = matchCountRet['result']['match_count'] _ret['result']['win_rate'] = matchCountRet['result']['win_rate'] return _ret
def getUser(request): if request.method == 'GET': _ret = getUserInfo(request.GET) return process_ret_status(_ret) return json_response(failed_response("操作不支持"))