def getRecentMatchesByMode(request): if request.method == 'GET': user_id = request.GET.get('user_id', None) mode_id = request.GET.get('mode_id', None) limit = request.GET.get('limit', 10) offset = request.GET.get('offset', 0) if mode_id is None: mode_id = '0' _recentMatchRet = getMatchesInfoByUser({'user_id':user_id, 'limit':limit, 'mode_id':str(mode_id), 'offset':offset}) if _recentMatchRet['status'] == 'failed': return process_ret_status(_recentMatchRet) newMatchList = [] for match in _recentMatchRet['result']: if match.get('hero_id', None) is not None: hero_id = match.get('hero_id') heroInfo = getHeroInfo({'hero_id':hero_id}) if heroInfo['status'] == 'ok': match['hero_info'] = heroInfo['result'] newMatchList.append(match) _ret = {} _ret['msg'] = '' _ret['status'] = 'ok' _ret['result'] = {} _ret['result']['recent_matches'] = _recentMatchRet['result'] return process_ret_status(_ret) return json_response(failed_response("操作不支持"))
def getPlayerSummaryById(request): if request.method == 'GET': _playerInfoRet = getPlayerInfoByUser(request.GET) if _playerInfoRet['status'] == 'failed': return process_ret_status(_playerInfoRet) _recentMatchRet = getMatchesInfoByUser({'user_id':request.GET.get('user_id',None), 'limit':10}) if _recentMatchRet['status'] == 'failed': return process_ret_status(_recentMatchRet) newMatchList = [] for match in _recentMatchRet['result']: if match.get('hero_id', None) is not None: hero_id = match.get('hero_id') heroInfo = getHeroInfo({'hero_id':hero_id}) if heroInfo['status'] == 'ok': match['hero_info'] = heroInfo['result'] newMatchList.append(match) _ret = {} _ret['msg'] = '' _ret['status'] = 'ok' _ret['result'] = {} _ret['result']['player_info'] = _playerInfoRet['result'] _ret['result']['recent_matches'] = _recentMatchRet['result'] return process_ret_status(_ret) return json_response(failed_response("操作不支持"))
def getUserMatches(request): if request.method == 'GET': _ret = getMatchesInfoByUser(request.GET) return process_ret_status(_ret) return json_response(failed_response("操作不支持"))