예제 #1
0
    def taskList(self, data, kwarg={}, page=None, pageSize=None):
        id = data["projectId"]

        kwarg["projectId"] = id
        obj = models.SqlBox.objects.select_related(
            "projectId",
            "userId").filter(**kwarg).order_by("createTime").reverse()
        serializersObj = serializers.S_addSqlBox(obj, many=True)
        res_data = serializersObj.data
        total = None
        all_page = None
        if "page" in data.keys():
            page = data["page"]
            pageSize = data["pageSize"]
            total = len(res_data)  # 数据总数
            PaginationObj = Pagination(total,
                                       page,
                                       perPageNum=pageSize,
                                       allPageNum=11)
            all_page = PaginationObj.all_page()
            if int(all_page) >= int(page):
                print(PaginationObj.start(), PaginationObj.end())
                res_data = res_data[PaginationObj.start():PaginationObj.end()]
            else:
                PaginationObj = Pagination(total,
                                           int(page) - 1,
                                           perPageNum=pageSize,
                                           allPageNum=11)
                res_data = res_data[PaginationObj.start():PaginationObj.end()]
        return {"res_data": res_data, "total": total, "all_page": all_page}
예제 #2
0
    def get(self, req):
        id = req.query_params["projectId"]
        total = None
        all_page = None
        page = None
        pageSize = None
        if "page" in req.query_params:
            page = req.query_params["page"]
            pageSize = req.query_params["pageSize"]

        obj = models.CasePlan.objects.select_related(
            "projectId",
            "userId").filter(projectId=id).order_by("createTime").reverse()
        serializersObj = serializers.S_AddCasePlan(obj, many=True)
        res_data = serializersObj.data
        if page:  #如果传了分页 则返回分页数据--否则返回所有数据
            total = len(res_data)  #数据总数
            PaginationObj = Pagination(total,
                                       page,
                                       perPageNum=pageSize,
                                       allPageNum=11)
            all_page = PaginationObj.all_page()
            res_data = res_data[PaginationObj.start():PaginationObj.end()]

        return APIResponse(200,
                           "success",
                           results=res_data,
                           total=total,
                           allPage=all_page,
                           status=status.HTTP_200_OK)
예제 #3
0
 def page_c(self, data):
     type = data["type"]
     page = data["page"]
     pageSize = data["pageSize"]
     obj = models.CaseResult.objects.filter(
         c_id=data["c_id"], type=type).order_by("createTime").reverse()
     serializersObj = serializers.S_CaseResults(obj, many=True)
     res_data = serializersObj.data
     total = len(res_data)  # 数据总数
     PaginationObj = Pagination(total,
                                page,
                                perPageNum=pageSize,
                                allPageNum=11)
     all_page = PaginationObj.all_page()
     res_data = res_data[PaginationObj.start():PaginationObj.end()]
     return res_data, all_page, total
예제 #4
0
 def listPlan(self, req):
     id = req.data["projectId"]
     page = req.data["page"]
     pageSize = req.data["pageSize"]
     obj = models.CasePlan.objects.select_related(
         "projectId",
         "userId").filter(projectId=id).order_by("createTime").reverse()
     serializersObj = serializers.S_AddCasePlan(obj, many=True)
     res_data = serializersObj.data
     total = len(res_data)  # 数据总数
     PaginationObj = Pagination(total,
                                page,
                                perPageNum=pageSize,
                                allPageNum=11)
     all_page = PaginationObj.all_page()
     res_data = res_data[PaginationObj.start():PaginationObj.end()]
     return {"res_data": res_data, "total": total, "all_page": all_page}
예제 #5
0
 def get(self, req):
     data = req.query_params
     projectId = data["projectId"]
     kwargs = {}
     if "name" in data.keys():
         kwargs["name__icontains"] = data["name"]
     if "isInterface" in data.keys():
         kwargs["CaseGroupId__name__icontains"] = data["isInterface"]
     if "postMethods" in data.keys():
         kwargs["postMethod"] = data["postMethods"]
     if "ctime" in data.keys():
         kwargs["createTime__gt"] = json.loads(data["ctime"])[0]
         kwargs["createTime__lt"] = json.loads(data["ctime"])[1]
     if "utime" in data.keys():
         kwargs["updateTime__gt"] = json.loads(data["utime"])[0]
         kwargs["updateTime__lt"] = json.loads(data["utime"])[1]
     kwargs["CaseGroupId__CaseGroupFilesId__projectId"] = projectId
     obj=models.CaseFile.objects.select_related\
         ("CaseGroupId","userId","postMethod","environmentId","update_userId","CaseGroupId__CaseGroupFilesId","CaseGroupId__CaseGroupFilesId__projectId")\
         .filter(**kwargs).order_by("CaseGroupId__order","order")
     serializersObj = serializers.S_GetCaseList(obj, many=True)
     res_data = serializersObj.data
     page = req.query_params["page"]
     pageSize = req.query_params["pageSize"]
     total = len(res_data)  # 数据总数
     PaginationObj = Pagination(total,
                                page,
                                perPageNum=pageSize,
                                allPageNum=11)
     all_page = PaginationObj.all_page()
     if int(all_page) < int(page):
         PaginationObj = Pagination(total,
                                    all_page,
                                    perPageNum=pageSize,
                                    allPageNum=11)
     res_data = res_data[PaginationObj.start():PaginationObj.end()]
     return APIResponse(200,
                        "success",
                        results=res_data,
                        total=total,
                        allPage=all_page,
                        status=status.HTTP_200_OK)