示例#1
0
    def get(self, request, args: str = None):

        '''

        :argument 详细信息数据展示

        :param args: 根据获得的work_id  status order_id 查找相关数据并返回

        :return:

        '''
        try:
            work_id = request.GET.get('workid')
            status = request.GET.get('status')
            order_id = request.GET.get('id')
        except KeyError as e:
            CUSTOM_ERROR.error(f'{e.__class__.__name__}: {e}')
        else:
            type_id = SqlOrder.objects.filter(id=order_id).first()
            try:
                if status == '1':
                    data = SqlRecord.objects.filter(workid=work_id).all()
                    _serializers = Record(data, many=True)
                    return Response({'data':_serializers.data, 'type':type_id.type})
                else:
                    data = SqlOrder.objects.filter(work_id=work_id).first()
                    _in = {'data':[{'sql': x} for x in data.sql.split(';')], 'type':type_id.type}
                    return Response(_in)
            except Exception as e:
                CUSTOM_ERROR.error(f'{e.__class__.__name__} : {e}')
                return HttpResponse(status=500)
示例#2
0
    def get(self, request, args: str = None):
        '''

        :argument 详细信息数据展示

        :param args: 根据获得的work_id  status order_id 查找相关数据并返回

        :return:

        '''
        try:
            work_id = request.GET.get('workid')
            status = request.GET.get('status')
            order_id = request.GET.get('id')
        except KeyError as e:
            CUSTOM_ERROR.error(f'{e.__class__.__name__}: {e}')
        else:
            order = SqlOrder.objects.filter(id=order_id).first()

            if order.type == 2:
                try:
                    if status == '1' or status == '4':
                        data = querypermissions.objects.filter(
                            work_id=work_id).first()
                        if data:
                            _in = {
                                "data": data.answer,
                                "filename": data.filename,
                                "export": order.export,
                                'type': order.type
                            }
                        else:
                            _in = {
                                "data": None,
                                "filename": "",
                                "export": order.export,
                                'type': order.type
                            }
                        return Response(_in)
                    else:
                        data = querypermissions.objects.filter(
                            work_id=work_id).first()
                        _in = {
                            'data': data.answer,
                            'filename': data.filename,
                            "export": order.export,
                            'type': order.type
                        }
                        return Response(_in)
                except Exception as e:
                    CUSTOM_ERROR.error(f'{e.__class__.__name__} : {e}')
                    return HttpResponse(status=500)
            else:
                try:
                    if status == '1' or status == '4':
                        data = SqlRecord.objects.filter(workid=work_id).all()
                        _serializers = Record(data, many=True)
                        return Response({
                            'data': _serializers.data,
                            'type': order.type
                        })
                    else:
                        data = SqlOrder.objects.filter(work_id=work_id).first()
                        _in = {
                            'data': [{
                                'sql': x
                            } for x in data.sql.split(';')],
                            'type': order.type
                        }
                        return Response(_in)
                except Exception as e:
                    CUSTOM_ERROR.error(f'{e.__class__.__name__} : {e}')
                    return HttpResponse(status=500)