Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
def getAccessory(request):
    if request.method == 'GET':
        _ret = getAccessoryInfo(request.GET)
        return process_ret_status(_ret)
    return json_response(failed_response("操作不支持"))