当代数据库管理系统课程实验二
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.4 KiB

  1. error_code = {
  2. 401: "authorization fail.",
  3. 511: "non exist user id {}",
  4. 512: "exist user id {}",
  5. 513: "non exist store id {}",
  6. 514: "exist store id {}",
  7. 515: "non exist book id {}",
  8. 516: "exist book id {}",
  9. 517: "stock level low, book id {}",
  10. 518: "invalid order id {}",
  11. 519: "not sufficient funds, order id {}",
  12. 520: "",
  13. 521: "",
  14. 522: "",
  15. 523: "",
  16. 524: "",
  17. 525: "",
  18. 526: "",
  19. 527: "",
  20. 528: "",
  21. }
  22. def error_non_exist_user_id(user_id):
  23. return 511, error_code[511].format(user_id)
  24. def error_exist_user_id(user_id):
  25. return 512, error_code[512].format(user_id)
  26. def error_non_exist_store_id(store_id):
  27. return 513, error_code[513].format(store_id)
  28. def error_exist_store_id(store_id):
  29. return 514, error_code[514].format(store_id)
  30. def error_non_exist_book_id(book_id):
  31. return 515, error_code[515].format(book_id)
  32. def error_exist_book_id(book_id):
  33. return 516, error_code[516].format(book_id)
  34. def error_stock_level_low(book_id):
  35. return 517, error_code[517].format(book_id)
  36. def error_invalid_order_id(order_id):
  37. return 518, error_code[518].format(order_id)
  38. def error_not_sufficient_funds(order_id):
  39. return 519, error_code[518].format(order_id)
  40. def error_authorization_fail():
  41. return 401, error_code[401]
  42. def error_and_message(code, message):
  43. return code, message