当代数据库管理系统课程实验二
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

51 linhas
1.7 KiB

  1. from flask import Blueprint
  2. from flask import request
  3. from flask import jsonify
  4. from be.model import seller
  5. import json
  6. bp_seller = Blueprint("seller",__name__,url_prefix="/seller")
  7. @bp_seller.route("/create_store", methods=["POST"])
  8. def seller_create_store():
  9. user_id: str = request.json.get("user_id")
  10. store_id: str = request.json.get("store_id")
  11. s = seller.Seller()
  12. code, message = s.create_store(user_id, store_id)
  13. return jsonify({"message": message}), code
  14. @bp_seller.route("/add_book", methods=["POST"])
  15. def seller_add_book():
  16. user_id: str = request.json.get("user_id")
  17. store_id: str = request.json.get("store_id")
  18. book_info: str = request.json.get("book_info")
  19. stock_level: str = request.json.get("stock_level", 0)
  20. s = seller.Seller()
  21. code, message = s.add_book(user_id, store_id, book_info.get("id"), json.dumps(book_info), stock_level)
  22. return jsonify({"message": message}), code
  23. @bp_seller.route("/add_stock_level", methods=["POST"])
  24. def add_stock_level():
  25. user_id: str = request.json.get("user_id")
  26. store_id: str = request.json.get("store_id")
  27. book_id: str = request.json.get("book_id")
  28. add_num: str = request.json.get("add_stock_level", 0)
  29. s = seller.Seller()
  30. code, message = s.add_stock_level(user_id, store_id, book_id, add_num)
  31. return jsonify({"message": message}), code
  32. @bp_seller.route("/send_out",methods=["POST"])
  33. def send_out():
  34. order_id: str = request.json.get("order_id")
  35. user_id: str = request.json.get("user_id")
  36. s = seller.Seller()
  37. code, message = s.send_out(order_id,user_id)
  38. return jsonify({"message": message}), code