当代数据库管理系统课程实验二
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 

51 satır
1.7 KiB

from flask import Blueprint
from flask import request
from flask import jsonify
from be.model import seller
import json
bp_seller = Blueprint("seller",__name__,url_prefix="/seller")
@bp_seller.route("/create_store", methods=["POST"])
def seller_create_store():
user_id: str = request.json.get("user_id")
store_id: str = request.json.get("store_id")
s = seller.Seller()
code, message = s.create_store(user_id, store_id)
return jsonify({"message": message}), code
@bp_seller.route("/add_book", methods=["POST"])
def seller_add_book():
user_id: str = request.json.get("user_id")
store_id: str = request.json.get("store_id")
book_info: str = request.json.get("book_info")
stock_level: str = request.json.get("stock_level", 0)
s = seller.Seller()
code, message = s.add_book(user_id, store_id, book_info.get("id"), json.dumps(book_info), stock_level)
return jsonify({"message": message}), code
@bp_seller.route("/add_stock_level", methods=["POST"])
def add_stock_level():
user_id: str = request.json.get("user_id")
store_id: str = request.json.get("store_id")
book_id: str = request.json.get("book_id")
add_num: str = request.json.get("add_stock_level", 0)
s = seller.Seller()
code, message = s.add_stock_level(user_id, store_id, book_id, add_num)
return jsonify({"message": message}), code
@bp_seller.route("/send_out",methods=["POST"])
def send_out():
order_id: str = request.json.get("order_id")
user_id: str = request.json.get("user_id")
s = seller.Seller()
code, message = s.send_out(order_id,user_id)
return jsonify({"message": message}), code