def get(self, request): serializer = OrderSerializer(data=request.query_params) serializer.is_valid(raise_exception=True) instance = OrderService.getOrderDetail( order_id=serializer.data.get('order_id')) serializer = OrderSerializer(instance) return Response(serializer.data)
def get(self, request): qurey_params = request.query_params.copy() min_amount = qurey_params.get('min_amount') max_amount = qurey_params.get('max_amount') qurey_params.pop('min_amount') qurey_params.pop('max_amount') serializer = OrderSerializer(data=qurey_params) serializer.is_valid(raise_exception=True) query_criteria = serializer.data delete_null(query_criteria) query_criteria.update({ 'amount__gte': min_amount, 'amount__lte': max_amount }) if query_criteria.order_type == 0: query_set = OrderService.listBoughtOrder( query_criteria.get('user_id')) else: query_set = OrderService.listSoldOrder( query_criteria.get('user_id')) serializer = OrderSerializer(query_set, many=True) return Response(serializer.data)
def post(self, request): serializer = OrderSerializer(data=request.data) serializer.is_valid(raise_exception=True) OrderService.insertOrder(serializer.data) return Response(serializer.data)
def put(self, request): serializer = OrderSerializer(request.data) serializer.is_valid(raise_exception=True) OrderService.updateOrderState(serializer.data.order_id) return Response(serializer.data)
def get(self, request, seller): instance = OrderService.listSoldOrder(seller=seller) serializer = OrderSerializer(instance) return Response(serializer.data)
def get(self, request, buyer): instance = OrderService.listBoughtOrder(buyer=buyer) serializer = OrderSerializer(instance) return Response(serializer.data)
def get(self, request, order_id): instance = OrderService.getOrderDetail(order_id=order_id) serializer = OrderSerializer(instance) return Response(serializer.data)