data_store_interface.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. from abc import ABC, abstractmethod
  2. from models.area_email import AreaEmail
  3. from models.collect_data import CollectData
  4. from models.process_data import ProcessData
  5. from models.process_result_data import ProcessResultData
  6. class IDataStore(ABC):
  7. """
  8. 定义数据保存接口
  9. """
  10. @abstractmethod
  11. def query_one_collect_url(self, url: str) -> str | None:
  12. raise NotImplementedError("insert 应由子类重写。")
  13. @abstractmethod
  14. def insert_collect_data(self, data: CollectData, is_batch=True) -> None:
  15. raise NotImplementedError("insert 应由子类重写。")
  16. @abstractmethod
  17. def save_collect_data(self, is_force=False):
  18. raise NotImplementedError("save 应由子类重写。")
  19. @abstractmethod
  20. def set_collect_process(self, url):
  21. raise NotImplementedError("set_collect_process 应由子类重写。")
  22. @abstractmethod
  23. def query_urls_to_process(self):
  24. raise NotImplementedError("query_to_process 应由子类重写。")
  25. @abstractmethod
  26. def query_one_collect_by_url(self, url):
  27. raise NotImplementedError("query_one_collect_by_url 应由子类重写。")
  28. @abstractmethod
  29. def query_one_process_by_no(self, no):
  30. raise NotImplementedError("query_one_process_by_no 应由子类重写。")
  31. @abstractmethod
  32. def query_one_process_by_url(self, no):
  33. raise NotImplementedError("query_one_process_by_url 应由子类重写。")
  34. @abstractmethod
  35. def insert_process_data(self, data: ProcessData):
  36. raise NotImplementedError("insert_process_data 应由子类重写。")
  37. @abstractmethod
  38. def save_process_data(self, is_force=False):
  39. raise NotImplementedError("save_process_data 应由子类重写。")
  40. @abstractmethod
  41. def set_process_other_urls(self, url, other_urls: str):
  42. raise NotImplementedError("save_process_data 应由子类重写。")
  43. @abstractmethod
  44. def query_one_process_result_by_url(self, url):
  45. raise NotImplementedError("query_one_process_result_by_url 应由子类重写。")
  46. @abstractmethod
  47. def query_one_process_result_by_no(self, no):
  48. raise NotImplementedError("query_one_process_result_by_no 应由子类重写。")
  49. @abstractmethod
  50. def insert_process_result_data(self,
  51. data: ProcessResultData,
  52. is_batch=True):
  53. raise NotImplementedError("insert_process_result_data 应由子类重写。")
  54. @abstractmethod
  55. def save_process_result_data(self, is_force=False):
  56. raise NotImplementedError("save_process_result_data 应由子类重写。")
  57. @abstractmethod
  58. def set_process_result_other_urls(self, url, other_urls: str):
  59. raise NotImplementedError("set_process_result_other_urls 应由子类重写。")
  60. @abstractmethod
  61. def query_to_send(self):
  62. raise NotImplementedError("query_to_send 应由子类重写。")
  63. @abstractmethod
  64. def query_to_report_by_date(self, start_date, end_date):
  65. raise NotImplementedError("query_to_report_by_date 应由子类重写。")
  66. @abstractmethod
  67. def set_send(self, no: str):
  68. raise NotImplementedError("set_send 应由子类重写。")
  69. @abstractmethod
  70. def query_all_emails(self) -> list[AreaEmail]:
  71. raise NotImplementedError("get_emails 应由子类重写。")
  72. @abstractmethod
  73. def query_all_virtual_emails(self):
  74. raise NotImplementedError("get_email_by_area 应由子类重写。")
  75. @abstractmethod
  76. def query_master_email(self) -> str:
  77. raise NotImplementedError("get_master_email 应由子类重写。")
  78. @abstractmethod
  79. def get_email_by_area(self, area: str):
  80. raise NotImplementedError("get_email_by_area 应由子类重写。")
  81. @abstractmethod
  82. def update_area_email_area_by_name(self, name: str, area: str):
  83. raise NotImplementedError("update_area_email_area_by_name 应由子类重写。")