From b8ec60dea13296891663e90584f5915b5ad851e3 Mon Sep 17 00:00:00 2001 From: "Jiangjie.Bai" Date: Thu, 22 Sep 2022 14:51:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=20DB=20Listen=20Port?= =?UTF-8?q?=20=E6=98=A0=E5=B0=84=E8=A7=84=E5=88=99=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/applications/api/application.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/applications/api/application.py b/apps/applications/api/application.py index 3d9913b24..8aa9c0550 100644 --- a/apps/applications/api/application.py +++ b/apps/applications/api/application.py @@ -1,7 +1,7 @@ # coding: utf-8 # from orgs.mixins.api import OrgBulkModelViewSet -from rest_framework import generics, status +from rest_framework import status from rest_framework.decorators import action from rest_framework.response import Response from rest_framework.viewsets import GenericViewSet @@ -60,8 +60,11 @@ class DBListenPortViewSet(GenericViewSet): def db_info(self, request, *args, **kwargs): port = request.data.get("port") db, msg = db_port_manager.get_db_by_port(port) - if db is None: + if db: + serializer = serializers.AppSerializer(instance=db) + data = serializer.data + _status = status.HTTP_200_OK + else: data = {'error': msg} - return Response(data=data, status=status.HTTP_404_NOT_FOUND) - serializer = serializers.AppSerializer(instance=db) - return Response(data=serializer.data, status=status.HTTP_201_CREATED) + _status = status.HTTP_404_NOT_FOUND + return Response(data=data, status=_status)