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 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 uploadMatch(request): if request.method == 'POST': _ret = {} if request.FILES is not None and len(request.FILES) > 0: _ret = uploadMatchInfoByFile(request.FILES) else: _ret = uploadMatchInfo(request.POST) return process_ret_status(_ret) return json_response(failed_response("操作不支持"))
def uploadAccessoryIcon(request): if request.method == 'POST': data = request.FILES data['upfiletype'] = 'accessory' data['id'] = request.POST.get('accessory_id', None) _ret = uploadImage(data) if _ret['status'] == 'ok': updateAccessoryInfo({'accessory_id':data['id'], 'accessory_icon':_ret['result']['url']}) return process_ret_status(_ret) return json_response(failed_response("操作不支持"))
def uploadHeroAvatar(request): if request.method == 'POST': data = request.FILES data['upfiletype'] = 'hero' data['id'] = request.POST.get('hero_id', None) _ret = uploadImage(data) if _ret['status'] == 'ok': updateHeroInfo({'hero_id':data['id'], 'hero_avatar':_ret['result']['url']}) return process_ret_status(_ret) return json_response(failed_response("操作不支持"))
def getMatchSummaryById(request): if request.method == 'GET': _matchRet = getMatchDetailInfo(request.GET) if _matchRet['status'] == 'failed': return process_ret_status(_matchRet) # print _matchRet matchInfo = _matchRet['result'] matchInfo = enrichUserInfo(matchInfo, 'allies') matchInfo = enrichUserInfo(matchInfo, 'rebels') _matchRet['result'] = matchInfo return process_ret_status(_matchRet) return json_response(failed_response("操作不支持"))
def updateServer(request): if request.method == 'POST': _ret = updateServerInfo(request.POST) return process_ret_status(_ret) return json_response(failed_response("操作不支持"))
def getAccessory(request): if request.method == 'GET': _ret = getAccessoryInfo(request.GET) return process_ret_status(_ret) return json_response(failed_response("操作不支持"))
def registerAccessory(request): if request.method == 'POST': _ret = addAccessoryInfo(request.POST) 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("操作不支持"))