def post(self, request): """ 导入swagger接口信息 :param request: :return: """ data = JSONParser().parse(request) result = self.parameter_check(data) if result: return result try: pro_data = Project.objects.get(id=data["project_id"]) if not request.user.is_superuser and pro_data.user.is_superuser: return JsonResponse(code="999983", msg="无操作权限!") except ObjectDoesNotExist: return JsonResponse(code="999995", msg="项目不存在!") pro_data = ProjectSerializer(pro_data) if not pro_data.data["status"]: return JsonResponse(code="999985", msg="该项目已禁用") try: swagger_api(data["url"], data["project_id"], request.user) return JsonResponse(code="999999", msg="成功!") except Exception as e: logging.exception(e) return JsonResponse(code="999998", msg="失败!")
def lead_swagger(request): """ 导入swagger接口信息 :param request: :return: """ project_id = request.POST.get("project_id") if not project_id.isdecimal(): return JsonResponse(code_msg=GlobalStatusCode.parameter_wrong()) url = request.POST.get("url") obi = Project.objects.filter(id=project_id) if obi: try: swagger_api(url, project_id, request.user) return JsonResponse(code_msg=GlobalStatusCode.success()) except: return JsonResponse(code_msg=GlobalStatusCode.fail()) else: return JsonResponse(code_msg=GlobalStatusCode.project_not_exist())