Example #1
0
    def get(request):
        banner_list = Banner.objects.all()
        topic_list = Topic.objects.all()

        if not banner_list and not topic_list:
            return error_request(ErrBaseNotData)

        return_data = dict_success()
        return_data['data']['banner'] = serializer_list_data(
            banner_list, BannerSerializer, request)
        return_data['data']['topic'] = serializer_list_data(
            topic_list, TopicSerializer, request)
        return success_request(return_data)
Example #2
0
 def get(request):
     br_list = BidRecord.objects.filter(
         profile__username=request.user).all()
     if not br_list:
         return error_request(ErrBaseNotData)
     return_data = array_success()
     return_data['data'] = serializer_list_data(br_list,
                                                IAmShootingSerializer,
                                                request)
     return success_request(return_data)
Example #3
0
    def get(request):
        goods_list = Goods.objects.filter(is_new=True).all()

        if not goods_list:
            return error_request(ErrBaseNotData)

        return_data = array_success()
        return_data['data'] = serializer_list_data(goods_list,
                                                   RecommendSerializer,
                                                   request)
        return success_request(return_data)
Example #4
0
    def get(request):
        goods_list = Goods.objects.all()

        if not goods_list:
            return error_request(ErrGoodsNotFound)

        return_data = array_success()
        return_data['data'] = serializer_list_data(goods_list,
                                                   GoodsDetailSerializer,
                                                   request)
        return success_request(return_data)
Example #5
0
    def get(request):
        collection = Collection.objects.filter(
            user__username=request.user).all()

        if not collection:
            return error_request(ErrBaseNotData)

        return_data = array_success()
        data = serializer_list_data(collection, MyCollectionSerializer,
                                    request)
        print(data)
        return_data['data'] = None
        return success_request(return_data)
Example #6
0
    def get(request):
        try:
            category_id = request.query_params['category_id']
        except KeyError:
            return error_request(ErrBaseParams)

        goods_list = Goods.objects.filter(category_id=int(category_id))
        if not goods_list:
            return error_request(ErrBaseNotData)

        return_data = array_success()
        return_data['data'] = serializer_list_data(goods_list,
                                                   GoodsCategorySerializer,
                                                   request)
        return success_request(return_data)
Example #7
0
    def get(request):
        try:
            goods_id = request.query_params['goods_id']
        except KeyError:
            return error_request(ErrBaseParams)

        goods = Goods.objects.filter(goods_id=goods_id).first()

        if not goods:
            return error_request(ErrBaseNotData)

        goods_image_list = GoodsImage.objects.filter(goods_id=goods.id).all()
        return_data = dict_success()
        return_data['data'] = serializer_data(goods, GoodsDetailSerializer,
                                              request)
        return_data['data']['goods_images'] = serializer_list_data(
            goods_image_list, GoodsImageSerializer, request)
        return success_request(return_data)