internal 1.1.35__tar.gz → 1.1.35.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of internal might be problematic. Click here for more details.

Files changed (40) hide show
  1. {internal-1.1.35 → internal-1.1.35.2}/PKG-INFO +1 -1
  2. {internal-1.1.35 → internal-1.1.35.2}/pyproject.toml +1 -1
  3. {internal-1.1.35 → internal-1.1.35.2}/src/internal/model/base_model.py +20 -7
  4. {internal-1.1.35 → internal-1.1.35.2}/README.md +0 -0
  5. {internal-1.1.35 → internal-1.1.35.2}/src/internal/__init__.py +0 -0
  6. {internal-1.1.35 → internal-1.1.35.2}/src/internal/base_config.py +0 -0
  7. {internal-1.1.35 → internal-1.1.35.2}/src/internal/base_factory.py +0 -0
  8. {internal-1.1.35 → internal-1.1.35.2}/src/internal/cache_redis.py +0 -0
  9. {internal-1.1.35 → internal-1.1.35.2}/src/internal/common_enum/__init__.py +0 -0
  10. {internal-1.1.35 → internal-1.1.35.2}/src/internal/common_enum/car_relation_type.py +0 -0
  11. {internal-1.1.35 → internal-1.1.35.2}/src/internal/common_enum/description_type.py +0 -0
  12. {internal-1.1.35 → internal-1.1.35.2}/src/internal/common_enum/device_code.py +0 -0
  13. {internal-1.1.35 → internal-1.1.35.2}/src/internal/common_enum/event_code.py +0 -0
  14. {internal-1.1.35 → internal-1.1.35.2}/src/internal/common_enum/lpr_direction.py +0 -0
  15. {internal-1.1.35 → internal-1.1.35.2}/src/internal/common_enum/notify_type.py +0 -0
  16. {internal-1.1.35 → internal-1.1.35.2}/src/internal/common_enum/operator_type.py +0 -0
  17. {internal-1.1.35 → internal-1.1.35.2}/src/internal/common_enum/order_type.py +0 -0
  18. {internal-1.1.35 → internal-1.1.35.2}/src/internal/common_enum/point_type.py +0 -0
  19. {internal-1.1.35 → internal-1.1.35.2}/src/internal/common_enum/websocket_channel.py +0 -0
  20. {internal-1.1.35 → internal-1.1.35.2}/src/internal/const.py +0 -0
  21. {internal-1.1.35 → internal-1.1.35.2}/src/internal/database.py +0 -0
  22. {internal-1.1.35 → internal-1.1.35.2}/src/internal/exception/__init__.py +0 -0
  23. {internal-1.1.35 → internal-1.1.35.2}/src/internal/exception/app_exception.py +0 -0
  24. {internal-1.1.35 → internal-1.1.35.2}/src/internal/exception/base_exception.py +0 -0
  25. {internal-1.1.35 → internal-1.1.35.2}/src/internal/exception/internal_exception.py +0 -0
  26. {internal-1.1.35 → internal-1.1.35.2}/src/internal/ext/__init__.py +0 -0
  27. {internal-1.1.35 → internal-1.1.35.2}/src/internal/ext/amazon/__init__.py +0 -0
  28. {internal-1.1.35 → internal-1.1.35.2}/src/internal/ext/amazon/aws/__init__.py +0 -0
  29. {internal-1.1.35 → internal-1.1.35.2}/src/internal/ext/amazon/aws/const.py +0 -0
  30. {internal-1.1.35 → internal-1.1.35.2}/src/internal/http/__init__.py +0 -0
  31. {internal-1.1.35 → internal-1.1.35.2}/src/internal/http/requests.py +0 -0
  32. {internal-1.1.35 → internal-1.1.35.2}/src/internal/http/responses.py +0 -0
  33. {internal-1.1.35 → internal-1.1.35.2}/src/internal/interface/__init__.py +0 -0
  34. {internal-1.1.35 → internal-1.1.35.2}/src/internal/interface/base_interface.py +0 -0
  35. {internal-1.1.35 → internal-1.1.35.2}/src/internal/middleware/__init__.py +0 -0
  36. {internal-1.1.35 → internal-1.1.35.2}/src/internal/middleware/log_request.py +0 -0
  37. {internal-1.1.35 → internal-1.1.35.2}/src/internal/model/__init__.py +0 -0
  38. {internal-1.1.35 → internal-1.1.35.2}/src/internal/model/operate.py +0 -0
  39. {internal-1.1.35 → internal-1.1.35.2}/src/internal/utils.py +0 -0
  40. {internal-1.1.35 → internal-1.1.35.2}/src/internal/validator_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: internal
3
- Version: 1.1.35
3
+ Version: 1.1.35.2
4
4
  Summary:
5
5
  Author: Ray
6
6
  Author-email: ray@cruisys.com
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "internal"
3
- version = "1.1.35"
3
+ version = "1.1.35.2"
4
4
  description = ""
5
5
  authors = [{ name = "Ray", email = "ray@cruisys.com" }]
6
6
  readme = "README.md"
@@ -27,8 +27,8 @@ class InternalBaseDocument(Document):
27
27
  @classmethod
28
28
  async def get_pagination_list(cls, app: FastAPI, query: list = None, sort: List[Tuple] = None,
29
29
  page_size: int = DEF_PAGE_SIZE, page_no: int = DEF_PAGE_NO,
30
- ignore_cache: bool = False,
31
- fetch_links: bool = False):
30
+ ignore_cache: bool = False, fetch_links: bool = False,
31
+ exclude_fields: List[str] = None):
32
32
  if not query:
33
33
  final_query = []
34
34
  else:
@@ -59,8 +59,15 @@ class InternalBaseDocument(Document):
59
59
  else:
60
60
  page_no = max(1, min(page_no, total_pages))
61
61
 
62
- page_data = await cls.find(*final_query, ignore_cache=ignore_cache, fetch_links=fetch_links).sort(
63
- *final_sort).limit(page_size).skip((page_no - 1) * page_size).to_list()
62
+ # 建立查詢物件用於取得分頁資料
63
+ data_query = cls.find(*final_query, ignore_cache=ignore_cache, fetch_links=fetch_links)
64
+
65
+ # 如果有指定要排除的欄位,使用 project() 方法
66
+ if exclude_fields:
67
+ projection = {field: 0 for field in exclude_fields}
68
+ data_query = data_query.project(projection)
69
+
70
+ page_data = await data_query.sort(*final_sort).limit(page_size).skip((page_no - 1) * page_size).to_list()
64
71
 
65
72
  return page_no, page_size, total_num, page_data
66
73
 
@@ -89,7 +96,7 @@ class InternalBaseDocument(Document):
89
96
 
90
97
  @classmethod
91
98
  async def get_list(cls, app: FastAPI, query: list = None, sort: List[Tuple] = None, ignore_cache: bool = False,
92
- fetch_links: bool = False):
99
+ fetch_links: bool = False, exclude_fields: List[str] = None):
93
100
  if not query:
94
101
  final_query = []
95
102
  else:
@@ -109,9 +116,15 @@ class InternalBaseDocument(Document):
109
116
  continue
110
117
  final_sort.append((cls.id, pymongo.ASCENDING))
111
118
 
112
- data = await cls.find(*final_query, ignore_cache=ignore_cache, fetch_links=fetch_links).sort(
113
- *final_sort).to_list()
119
+ # 建立查詢物件
120
+ query_obj = cls.find(*final_query, ignore_cache=ignore_cache, fetch_links=fetch_links)
121
+
122
+ # 如果有指定要排除的欄位,使用 project() 方法
123
+ if exclude_fields:
124
+ projection = {field: 0 for field in exclude_fields}
125
+ query_obj = query_obj.project(projection)
114
126
 
127
+ data = await query_obj.sort(*final_sort).to_list()
115
128
  return data
116
129
 
117
130
  def model_dump(
File without changes