From 95a96e5dc5df8ea15e90ec97aeb2a05b14f612d1 Mon Sep 17 00:00:00 2001 From: youngS Date: Mon, 25 Jan 2021 10:31:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BA=94=E7=94=A8=E4=B8=8D?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fir_ser/api/utils/serializer.py | 9 +++++---- fir_ser/api/views/apps.py | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/fir_ser/api/utils/serializer.py b/fir_ser/api/utils/serializer.py index 64486ca..196335d 100644 --- a/fir_ser/api/utils/serializer.py +++ b/fir_ser/api/utils/serializer.py @@ -11,6 +11,11 @@ logger = logging.getLogger(__file__) token_obj = DownloadToken() +def get_head_img(obj): + storage = Storage(obj) + return storage.get_download_url(obj.head_img) + + class UserInfoSerializer(serializers.ModelSerializer): class Meta: model = models.UserInfo @@ -21,10 +26,6 @@ class UserInfoSerializer(serializers.ModelSerializer): head_img = serializers.SerializerMethodField() - def get_head_img(self, obj): - storage = Storage(obj) - return storage.get_download_url(obj.head_img) - class AppsSerializer(serializers.ModelSerializer): class Meta: diff --git a/fir_ser/api/views/apps.py b/fir_ser/api/views/apps.py index e92de81..2b24de3 100644 --- a/fir_ser/api/views/apps.py +++ b/fir_ser/api/views/apps.py @@ -99,15 +99,16 @@ class AppInfoView(APIView): if apps_obj: app_serializer = AppsSerializer(apps_obj, context={"storage": Storage(request.user)}) res.data = app_serializer.data + count = APPToDeveloper.objects.filter(app_id=apps_obj).count() + res.data["count"] = count else: logger.error("app_id:%s is not found in user:%s " % (app_id, request.user)) res.msg = "未找到该应用" res.code = 1003 + userserializer = UserInfoSerializer(request.user) res.userinfo = {} res.userinfo = userserializer.data - count = APPToDeveloper.objects.filter(app_id=apps_obj).count() - res.data["count"] = count return Response(res.dict)