def get(self, request, args: str = None):
        '''

        :argument 审核页面数据展示请求接口

        :param None

        :return 数据条数, 数据

        '''

        try:
            page = request.GET.get('page')
            username = request.GET.get('username')
        except KeyError as e:
            CUSTOM_ERROR.error(f'{e.__class__.__name__}: {e}')
            return HttpResponse(status=500)
        else:
            try:
                un_init = util.init_conf()
                custom_com = ast.literal_eval(un_init['other'])
                page_number = SqlOrder.objects.filter(
                    assigned=username).count()
                start = (int(page) - 1) * 20
                end = int(page) * 20
                info = SqlOrder.objects.raw('''
                    select o.id,o.work_id,o.text,o.backup,o.date,o.assigned,
                    o.username,o.real_name,o.status,o.basename,o.delay,core_databaselist.connection_name, \
                    core_databaselist.computer_room from core_sqlorder as o \
                    INNER JOIN core_databaselist on \
                    o.bundle_id = core_databaselist.id where o.assigned = '%s'\
                    ORDER BY o.id desc
                    ''' % username)[start:end]
                data = util.ser(info)
                info = Account.objects.filter(group='perform').all()
                ser = serializers.UserINFO(info, many=True)
                return Response({
                    'page': page_number,
                    'data': data,
                    'multi': custom_com['multi'],
                    'multi_list': ser.data
                })
            except Exception as e:
                CUSTOM_ERROR.error(f'{e.__class__.__name__}: {e}')
                return HttpResponse(status=500)
Exemple #2
0
    def get(self, request, args: str = None):
        '''

        :argument 审核页面数据展示请求接口

        :param None

        :return 数据条数, 数据

        '''

        try:
            page = request.GET.get('page')
            qurey = json.loads(request.GET.get('query'))
        except KeyError as e:
            CUSTOM_ERROR.error(f'{e.__class__.__name__}: {e}')
            return HttpResponse(status=500)
        else:
            try:
                un_init = util.init_conf()
                custom_com = ast.literal_eval(un_init['other'])
                start = (int(page) - 1) * 20
                end = int(page) * 20
                u_mulit = Account.objects.filter(username=request.user).first()
                if u_mulit.group == 'perform':
                    if qurey['valve']:
                        if len(qurey['picker']) == 0:
                            info = SqlOrder.objects.filter(
                                executor=request.user,
                                username__contains=qurey['user']).defer(
                                    'sql').order_by('-id')[start:end]
                            page_number = SqlOrder.objects.filter(
                                executor=request.user,
                                username__contains=qurey['user']).only(
                                    'id').count()
                        else:
                            picker = []
                            for i in qurey['picker']:
                                picker.append(i)
                            info = SqlOrder.objects.filter(
                                executor=request.user,
                                username__contains=qurey['user'],
                                date__gte=picker[0],
                                date__lte=picker[1]).defer('sql').order_by(
                                    '-id')[start:end]
                            page_number = SqlOrder.objects.filter(
                                executor=request.user,
                                username__contains=qurey['user'],
                                date__gte=picker[0],
                                date__lte=picker[1]).only('id').count()

                    else:
                        page_number = SqlOrder.objects.filter(
                            executor=request.user).only('id').count()
                        info = SqlOrder.objects.filter(
                            executor=request.user).defer('sql').order_by(
                                '-id')[start:end]
                else:
                    if qurey['valve']:
                        if len(qurey['picker']) == 0:
                            info = SqlOrder.objects.filter(
                                assigned=request.user,
                                username__contains=qurey['user']).defer(
                                    'sql').order_by('-id')[start:end]
                            page_number = SqlOrder.objects.filter(
                                assigned=request.user,
                                username__contains=qurey['user']).only(
                                    'id').count()
                        else:
                            picker = []
                            for i in qurey['picker']:
                                picker.append(i)
                            info = SqlOrder.objects.filter(
                                assigned=request.user,
                                username__contains=qurey['user'],
                                date__gte=picker[0],
                                date__lte=picker[1]).defer('sql').order_by(
                                    '-id')[start:end]
                            page_number = SqlOrder.objects.filter(
                                assigned=request.user,
                                username__contains=qurey['user'],
                                date__gte=picker[0],
                                date__lte=picker[1]).only('id').count()

                    else:
                        page_number = SqlOrder.objects.filter(
                            assigned=request.user).only('id').count()
                        info = SqlOrder.objects.filter(
                            assigned=request.user).defer('sql').order_by(
                                '-id')[start:end]
                data = util.ser(info)
                info = Account.objects.filter(group='perform').all()
                ser = serializers.UserINFO(info, many=True)
                return Response({
                    'page': page_number,
                    'data': data,
                    'multi': custom_com['multi'],
                    'multi_list': ser.data
                })
            except Exception as e:
                CUSTOM_ERROR.error(f'{e.__class__.__name__}: {e}')
                return HttpResponse(status=500)
Exemple #3
0
    def get(self, request, args: str = None):

        '''

        :argument 审核页面数据展示请求接口

        :param None

        :return 数据条数, 数据

        '''
        try:
            if request.GET.get('page') == 'n':
                mess = request.GET.get('mess')
                opt = request.GET.get('opt')
                un_init = util.init_conf()
                custom_com = ast.literal_eval(un_init['other'])
                if opt == 'u' :
                    page_number = SqlOrder.objects.filter(username__contains = mess).count()
                    sql = (
                        f'select core_sqlorder.*,core_databaselist.connection_name,\n'
                        f'core_databaselist.computer_room from core_sqlorder\n'
                        f'INNER JOIN core_databaselist on\n'
                        f'core_sqlorder.bundle_id = core_databaselist.id where core_sqlorder.username like %s\n'
                        f'ORDER BY core_sqlorder.id desc;')
                elif opt == 't':
                    page_number = SqlOrder.objects.filter(text__contains=mess).count()
                    sql = (
                        f'select core_sqlorder.*,core_databaselist.connection_name,\n'
                        f'core_databaselist.computer_room from core_sqlorder\n'
                        f'INNER JOIN core_databaselist on\n'
                        f'core_sqlorder.bundle_id = core_databaselist.id where core_sqlorder.text like %s\n'
                        f'ORDER BY core_sqlorder.id desc;')
                else:
                    page_number = SqlOrder.objects.filter(work_id__contains = mess).count()
                    sql = (
                        f'select core_sqlorder.*,core_databaselist.connection_name,\n'
                        f'core_databaselist.computer_room from core_sqlorder\n'
                        f'INNER JOIN core_databaselist on\n'
                        f'core_sqlorder.bundle_id = core_databaselist.id where core_sqlorder.work_id like %s\n'
                        f'ORDER BY core_sqlorder.id desc;')
                    # //where core_sqlorder.work_id like '%'''+mess+'''%'      ORDER BY core_sqlorder.id desc '''
                info = SqlOrder.objects.raw(sql, ["%"+mess+"%"])
                data = util.ser(info)
                info = Account.objects.filter(group='perform').all()
                ser = serializers.UserINFO(info, many=True)
                return Response(
                    {'page': page_number, 'data': data, 'multi': custom_com['multi'], 'multi_list': ser.data})

            else:
                try:
                    page = request.GET.get('page')
                    username = request.GET.get('username')
                except KeyError as e:
                    CUSTOM_ERROR.error(f'{e.__class__.__name__}: {e}')
                    return HttpResponse(status=500)
                else:
                    try:
                        un_init = util.init_conf()
                        custom_com = ast.literal_eval(un_init['other'])
                        page_number = SqlOrder.objects.filter(assigned=username).count()
                        start = (int(page) - 1) * 20
                        end = int(page) * 20
                        info = SqlOrder.objects.raw(
                            '''
                            select core_sqlorder.*,core_databaselist.connection_name, \
                            core_databaselist.computer_room from core_sqlorder \
                            INNER JOIN core_databaselist on \
                            core_sqlorder.bundle_id = core_databaselist.id where core_sqlorder.assigned = '%s'\
                            ORDER BY core_sqlorder.id desc
                            ''' % username
                        )[start:end]
                        data = util.ser(info)
                        info = Account.objects.filter(group='perform').all()
                        ser = serializers.UserINFO(info, many=True)
                        return Response(
                            {'page': page_number, 'data': data, 'multi': custom_com['multi'], 'multi_list': ser.data})
                    except Exception as e:
                        CUSTOM_ERROR.error(f'{e.__class__.__name__}: {e}')
                        return HttpResponse(status=500)
        except KeyError as e:
            CUSTOM_ERROR.error(f'{e.__class__.__name__}: {e}')
            return HttpResponse(status=500)