示例#1
0
    def get(self, request):
        """
        获取接口列表
        :param request:
        :return:
        """

        # 搜索数据
        # data = request.data
        # logger.info("搜索数据:{}".format(data))
        data = request.GET.get('search_data')
        logger.info("获取接口列表,搜索数据:{}".format(data))
        try:
            if data:
                search_data = {}
                data = eval(data)
                if data.__contains__('project__parent__id__in'):
                    data['project__parent__id__in'] = eval(
                        data['project__parent__id__in'])
                for key, value in data.items():
                    if bool(key) and bool(value):
                        search_data[key] = data[key]
                roles = RequestsForResources.objects.filter(
                    **search_data).order_by('-abandon_flag', '-id')
                # 自定义分页实例化
                page = GoodsPagination()
                # 根据分页查询数据
                page_roles = page.paginate_queryset(queryset=roles,
                                                    request=request,
                                                    view=self)
                # 对查询数据进行序列化
                roles_ser = RequestsListSerializer(instance=page_roles,
                                                   many=True)
                # 返回数据,以及前后页的url
                result_info = page.get_paginated_response(roles_ser.data)
                # return Response(roles_ser.data)  # 只返回数据
                return result_info

            else:
                # 没有搜索条件和搜索类型,那么默认为显示全部信息
                # 根据id排序,搜索数据
                # roles = RequestsForResources.objects.get_queryset().order_by('-id').filter(abandon_flag=1)
                roles = RequestsForResources.objects.order_by('-id').filter(
                    abandon_flag=1)
                # 自定义分页实例化
                page = GoodsPagination()
                # 根据分页处理数据
                page_roles = page.paginate_queryset(queryset=roles,
                                                    request=request,
                                                    view=self)
                # 查询数据序列化处理
                roles_ser = RequestsListSerializer(instance=page_roles,
                                                   many=True)
                # 返回数据,以及前后页的url
                result_info = page.get_paginated_response(roles_ser.data)
                # return Response(roles_ser.data)  # 只返回数据
                return result_info
        except Exception as e:
            logger.error(e)
            return ReturnJson.faile(ResourceEnumeration.SYS_ERROE.value)
示例#2
0
    def get(self, request):
        """
        项目的版本号配置,列表和搜索
        :param request:
        :return:
        """
        data = request.GET.get('search_data')
        logger.info("系统参数配置列表,搜索数据:{}".format(data))
        try:
            if data:
                search_data = {}
                data = eval(data)
                for key, value in data.items():
                    if bool(key) and bool(value):
                        search_data[key] = data[key]
                roles = VersionForProject.objects.filter(
                    **search_data).order_by('-abandon_flag', '-id')
                # 自定义分页实例化
                page = GoodsPagination()
                # 根据分页查询数据
                page_roles = page.paginate_queryset(queryset=roles,
                                                    request=request,
                                                    view=self)
                # 对查询数据进行序列化
                roles_ser = VersionForProjectListSerializer(
                    instance=page_roles, many=True)
                # 返回数据,以及前后页的url
                result_info = page.get_paginated_response(roles_ser.data)
                # return Response(roles_ser.data)  # 只返回数据
                return result_info

            else:
                # 没有搜索条件和搜索类型,那么默认为显示全部信息
                # 根据id排序,搜索数据
                # roles = VersionForProject.objects.get_queryset().order_by('-id')
                roles = VersionForProject.objects.get_queryset().order_by(
                    '-abandon_flag', '-id')
                # 自定义分页实例化
                page = GoodsPagination()
                # 根据分页处理数据
                page_roles = page.paginate_queryset(queryset=roles,
                                                    request=request,
                                                    view=self)
                # 查询数据序列化处理
                roles_ser = VersionForProjectListSerializer(
                    instance=page_roles, many=True)
                # 返回数据,以及前后页的url
                result_info = page.get_paginated_response(roles_ser.data)
                # return Response(roles_ser.data)  # 只返回数据
                return result_info
        except Exception as e:
            logger.error(e)
            return ReturnJson.faile(BaseEnumeration.SYS_PARAM_ID_ERROR.value)
示例#3
0
    def get(self, requests):
        """
        获取迭代执行记录,包含查询
        :param requests:
        :return:
        """
        data = requests.GET.get('search_data')
        logger.info("获取迭代执行列表,搜索数据:{}".format(data))
        try:
            if data:
                search_data = {}
                data = eval(data)
                data['it__pro__id__in'] = eval(data['it__pro__id__in'])
                if data.__contains__('it__id'):
                    data['it_id'] = int(data['it_id'])
                for key, value in data.items():
                    if bool(key) and bool(value):
                        search_data[key] = data[key]
                roles = IterationRecordForJobCenter.objects.filter(**search_data).order_by('-abandon_flag', '-id')
                # 自定义分页实例化
                page = GoodsPagination()
                # 根据分页查询数据
                page_roles = page.paginate_queryset(queryset=roles, request=requests, view=self)
                # 对查询数据进行序列化
                roles_ser = IterationListRecordSerializer(instance=page_roles, many=True)
                # 返回数据,以及前后页的url
                result_info = page.get_paginated_response(roles_ser.data)
                # return Response(roles_ser.data)  # 只返回数据
                return result_info

            else:
                # 没有搜索条件和搜索类型,那么默认为显示全部信息
                # 根据id排序,搜索数据
                roles = IterationRecordForJobCenter.objects.get_queryset().order_by('-abandon_flag', '-id').filter(abandon_flag=1)
                # 自定义分页实例化
                page = GoodsPagination()
                # 根据分页处理数据
                page_roles = page.paginate_queryset(queryset=roles, request=requests, view=self)
                # 查询数据序列化处理
                roles_ser = IterationListRecordSerializer(instance=page_roles, many=True)
                # 返回数据,以及前后页的url
                result_info = page.get_paginated_response(roles_ser.data)
                # return Response(roles_ser.data)  # 只返回数据
                return result_info
        except Exception as e:
            logger.error(e)
            return ReturnJson.faile(JobCenterEnumeration.GET_INFO_ERROR.value)