Beispiel #1
0
def query_book_by_isbn(isbn):
    """
    根据 isbn 查询书目信息
    """
    if isbn:
        book_service = BookService()
        rv = book_service.book_query_by_isbn(isbn)
        if rv:
            return make_api_response(payload=rv, message='ok', statusCode=200)
        return make_api_response(message='没有对应书目', statusCode=500)

    return make_api_response(message='缺少isbn')
Beispiel #2
0
def query_book_by_isbn(isbn):
    """
    @api {GET} /book/query_book_by_isbn/<isbn> 根据 isbn 查询书目信息
    @apiGroup book
    @apiVersion 0.0.1
    @apiDescription 根据 isbn 查询书目信息
    @apiParam {int} isbn
    @apiSuccess (200) {String} msg 信息
    @apiSuccess (200) {int} code 0 代表无错误 1代表有错误
    @apiSuccessExample {json} 返回样例:
                        {
                        "status": "ok",
                        "payload": {
                            "1": {
                            "name": "论语",
                            "press": "北京教育出版社",
                            "id": 1,
                            "description": null,
                            "quantity": 100,
                            "price": 0.0,
                            "author": "周杰伦",
                            "isbn": 9203204223,
                            "supplier": "天人1",
                            "discount": 0.5
                            }
                        },
                        "message": "ok"
                        }
    @apiError (400) {String} msg 信息
    @apiErrorExample {json} 返回样例:
                   {"status": "fail", "message": "缺少isbn"}
    """
    if isbn:
        book_service = BookService()
        rv = book_service.book_query_by_isbn(isbn)

        # 去除自己的书目
        if current_user.id and rv:
            for k, v in rv.copy().items():
                if str(current_user.id) == str(v.get('supplier_id')):
                    rv.pop(k)

        return make_api_response(payload=rv, message='ok', statusCode=200)

    return make_api_response(message='缺少isbn')