Browse Source

【FIX】修改查询plan接口software_id传参问题 /以及公司不存在的情况

bigcat 2 years ago
parent
commit
635c9e7a0a
2 changed files with 5 additions and 1 deletions
  1. 3 1
      apps/plan/views/planlistview.py
  2. 2 0
      apps/software/views/softwarelistview.py

+ 3 - 1
apps/plan/views/planlistview.py

@@ -37,6 +37,8 @@ class PlanListView(APIView):
         creator_id = request.POST.get('creator')
         type = request.POST.get('type')
         company_id = request.POST.get('company_id')
+        if company_id == '':
+            company_id = -1
         # step1:判断所属软件及版本是否存在
         software = Software.objects.filter(id=software_id, delete=False)
         if not software:
@@ -140,7 +142,7 @@ class PlanListView(APIView):
         if title:
             plan_all = plan_all.filter(title__contains=title)
         if software_id:
-            plan_all = plan_all.filter(software__id__contains=software_id)
+            plan_all = plan_all.filter(software__id=software_id)
         if state:
             plan_all = plan_all.filter(state=state)
         if creator_id:

+ 2 - 0
apps/software/views/softwarelistview.py

@@ -31,6 +31,8 @@ class SoftwareListView(APIView):
         creator_id = request.POST.get('creator_id')
         company_id = request.POST.get('company_id')
         file = request.FILES.get('file')
+        if company_id == '':
+            company_id = -1
         if not file:
             logger.error("软件上传失败")
             return HttpResponse(status=404, content='软件上传失败')