示例#1
0
def operationInterfaceByInterfaceId(request):
    try:
        interfaceId = request.GET.get("interfaceId")
        interObj = DubboInterfaceService.getInterfaceByInterfaceId(interfaceId)
        return redirect("/dubbo/operationInterface?id=%s&option=%s" % (interObj.id,request.GET.get("option")))
    except:
        return render(request, "permission/page_404.html")
def operationInterface(request, context):
    langDict = getLangTextDict(request)
    context["id"] = request.GET.get("id", -1)
    context["option"] = request.GET.get("option")
    try:
        if int(context["id"]) <= 0:
            interfaceId = request.GET.get("interfaceId")
            interObj = DubboInterfaceService.getInterfaceByInterfaceId(
                interfaceId)
            return redirect("/dubbo/operationInterface?id=%s&option=%s" %
                            (interObj.id, context["option"]))
    except:
        return render(request, "permission/page_404.html")

    context["addHTTPInterface"] = "current-page"

    if not isRelease:
        context["env"] = "test"
    try:
        if VersionService.isCurrentVersion(request):
            context["addBy"] = DubboInterfaceService.getInterfaceById(
                request.GET.get("id")).addBy.loginName
        else:
            context["addBy"] = DubboInterfaceService.getInterfaceById(
                request.GET.get("id")).addBy.loginName

    except Exception as e:
        return HttpResponse("参数id错误 %s" % e)
    ####httoConfList
    ##dubugInfos

    envConfList = DubboInterfaceService.queryDubboConfSort(request)
    context["envConfList"] = envConfList
    ###################################################
    # if context["option"] == 'edit' and request.session.get("loginName") != context["dataAddBy"]:
    #     return HttpResponse("只能修改自己创建的接口")
    # 文本
    text = {}
    try:
        text["pageTitle"] = langDict["dubbo"]["interfacePageHeadings_%s" %
                                              context["option"]]
        text["subPageTitle"] = langDict["dubbo"]["interfaceSubPageTitle_%s" %
                                                 context["option"]]
    except Exception as e:
        return HttpResponse("参数错误 %s" % e)
    context["text"] = text

    # 页面所需参数
    context.update(ConfigServiceForDubbo.getConfigs(request))
    context.update(getServiceConf(request))
    context["debugBtnCount"] = commonWebConfig.debugBtnCount
    # 调试按钮
    getDebugBtnList = ConfigServiceForDubbo.getDebugBtn(request)
    context.update(getDebugBtnList)
    addUserLog(request, "DUBBO单接口管理->%s用例->页面展示->成功" % context["option"],
               "PASS")
    context["serviceJson"] = json.dumps(
        ServiceConfService.queryServiceConfSort(request))
    context["title"] = "DUBBO接口-" + request.GET.get("id")
    return render(request, "dubbo/interface/interfaceAddPage.html", context)