internal 1.1.39.2__py3-none-any.whl → 1.1.45__py3-none-any.whl
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.
- internal/http/responses.py +38 -3
- internal/model/base_model.py +6 -2
- internal/utils.py +30 -3
- internal/validator_utils.py +5 -1
- {internal-1.1.39.2.dist-info → internal-1.1.45.dist-info}/METADATA +1 -1
- {internal-1.1.39.2.dist-info → internal-1.1.45.dist-info}/RECORD +7 -7
- {internal-1.1.39.2.dist-info → internal-1.1.45.dist-info}/WHEEL +0 -0
internal/http/responses.py
CHANGED
|
@@ -2,6 +2,7 @@ import json
|
|
|
2
2
|
import arrow
|
|
3
3
|
|
|
4
4
|
from datetime import datetime, date
|
|
5
|
+
from pydantic import BaseModel
|
|
5
6
|
|
|
6
7
|
import httpx
|
|
7
8
|
|
|
@@ -16,23 +17,29 @@ async def async_response(data=None, message=None, code=None, page_no=None, total
|
|
|
16
17
|
time_zone="UTC", time_format=ARR_HUMAN_READ_FMT, date_format=ARR_DATE_FMT,
|
|
17
18
|
status_code=status.HTTP_200_OK):
|
|
18
19
|
def _serialize(data):
|
|
19
|
-
if issubclass(type(data), Document):
|
|
20
|
+
if issubclass(type(data), Document) or issubclass(type(data), BaseModel):
|
|
20
21
|
link_field_list = []
|
|
21
22
|
datetime_field_list = []
|
|
22
23
|
date_field_list = []
|
|
24
|
+
replace_dict = {}
|
|
23
25
|
for field_name in data.__annotations__:
|
|
24
26
|
field_type = getattr(data, field_name)
|
|
27
|
+
if field_name in ["contact", "pick_up", "car", "customer"]:
|
|
28
|
+
if field_type:
|
|
29
|
+
replace_dict[field_name] = _serialize(field_type)
|
|
30
|
+
|
|
25
31
|
if isinstance(field_type, Link):
|
|
26
32
|
link_field_list.append(field_name)
|
|
27
33
|
|
|
28
|
-
if field_name.endswith('_date') or field_name == "birthday":
|
|
34
|
+
if field_name.endswith('_date') or field_name == "birthday" or field_name.endswith('_birthday'):
|
|
29
35
|
date_field_list.append(field_name)
|
|
30
36
|
elif isinstance(field_type, datetime):
|
|
31
37
|
datetime_field_list.append(field_name)
|
|
32
38
|
elif isinstance(field_type, date):
|
|
33
39
|
date_field_list.append(field_name)
|
|
34
40
|
|
|
35
|
-
data = json.loads(
|
|
41
|
+
data = json.loads(
|
|
42
|
+
data.model_dump_json(exclude={"password", "metadata", "otp_code_universal"}, by_alias=False))
|
|
36
43
|
if link_field_list:
|
|
37
44
|
for field_name in link_field_list:
|
|
38
45
|
if isinstance(data[field_name], dict) and "id" in data[field_name].keys():
|
|
@@ -44,6 +51,34 @@ async def async_response(data=None, message=None, code=None, page_no=None, total
|
|
|
44
51
|
if data[field_name]:
|
|
45
52
|
data[field_name] = arrow.get(data[field_name]).to(time_zone).format(date_format)
|
|
46
53
|
|
|
54
|
+
for key, value in replace_dict.items():
|
|
55
|
+
data[key] = value
|
|
56
|
+
|
|
57
|
+
if "create_time" in data.keys() and data.get("create_time"):
|
|
58
|
+
data["create_time"] = arrow.get(data["create_time"]).to(time_zone).format(ARR_HUMAN_READ_FMT)
|
|
59
|
+
|
|
60
|
+
if "update_time" in data.keys() and data.get("update_time"):
|
|
61
|
+
data["update_time"] = arrow.get(data["update_time"]).to(time_zone).format(ARR_HUMAN_READ_FMT)
|
|
62
|
+
|
|
63
|
+
elif isinstance(data, dict):
|
|
64
|
+
datetime_field_list = []
|
|
65
|
+
date_field_list = []
|
|
66
|
+
for field_name, field_type in data.items():
|
|
67
|
+
if field_name.endswith('_date') or field_name == "birthday" or field_name.endswith('_birthday'):
|
|
68
|
+
date_field_list.append(field_name)
|
|
69
|
+
elif isinstance(field_type, datetime):
|
|
70
|
+
datetime_field_list.append(field_name)
|
|
71
|
+
elif isinstance(field_type, date):
|
|
72
|
+
date_field_list.append(field_name)
|
|
73
|
+
|
|
74
|
+
data = json.loads(json.dumps(data, default=jsonable_encoder))
|
|
75
|
+
for field_name in datetime_field_list:
|
|
76
|
+
if data[field_name]:
|
|
77
|
+
data[field_name] = arrow.get(data[field_name]).to(time_zone).format(time_format)
|
|
78
|
+
for field_name in date_field_list:
|
|
79
|
+
if data[field_name]:
|
|
80
|
+
data[field_name] = arrow.get(data[field_name]).to(time_zone).format(date_format)
|
|
81
|
+
|
|
47
82
|
if "create_time" in data.keys() and data.get("create_time"):
|
|
48
83
|
data["create_time"] = arrow.get(data["create_time"]).to(time_zone).format(ARR_HUMAN_READ_FMT)
|
|
49
84
|
|
internal/model/base_model.py
CHANGED
|
@@ -44,7 +44,9 @@ class InternalBaseDocument(Document):
|
|
|
44
44
|
else:
|
|
45
45
|
print(f"order type value error: temp_sort:{temp_sort}")
|
|
46
46
|
continue
|
|
47
|
-
|
|
47
|
+
|
|
48
|
+
if not any(s[0] == str(cls.id) for s in sort):
|
|
49
|
+
final_sort.append((cls.id, pymongo.ASCENDING))
|
|
48
50
|
|
|
49
51
|
if exclude_field_list:
|
|
50
52
|
# 當需要排除欄位時,使用 Motor 直接操作
|
|
@@ -141,7 +143,9 @@ class InternalBaseDocument(Document):
|
|
|
141
143
|
else:
|
|
142
144
|
print(f"order type value error: temp_sort:{temp_sort}")
|
|
143
145
|
continue
|
|
144
|
-
|
|
146
|
+
|
|
147
|
+
if not any(s[0] == str(cls.id) for s in sort):
|
|
148
|
+
final_sort.append((cls.id, pymongo.ASCENDING))
|
|
145
149
|
|
|
146
150
|
if exclude_field_list:
|
|
147
151
|
# 當需要排除欄位時,使用 Motor 直接操作
|
internal/utils.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
import json
|
|
3
|
+
import hashlib
|
|
3
4
|
from datetime import datetime, timezone
|
|
4
5
|
|
|
5
6
|
import arrow
|
|
6
7
|
|
|
7
8
|
from .base_config import BaseConfig
|
|
8
|
-
from .const import STR_EMPTY, ARR_EXPORT_DATETIME_FMT, STR_DASH, REDIS_LPR_DATA_LIST_PREFIX
|
|
9
|
+
from .const import STR_EMPTY, ARR_EXPORT_DATETIME_FMT, STR_DASH, REDIS_LPR_DATA_LIST_PREFIX, STR_SPACE
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
def is_today(time, system_time_zone):
|
|
@@ -48,7 +49,7 @@ def update_dict_with_cast(curr_settings: BaseConfig, new_conf: dict):
|
|
|
48
49
|
|
|
49
50
|
|
|
50
51
|
def sanitize_plate_no(plate_no):
|
|
51
|
-
return plate_no.replace(STR_DASH, STR_EMPTY).upper()
|
|
52
|
+
return plate_no.replace(STR_SPACE, STR_EMPTY).replace(STR_DASH, STR_EMPTY).upper()
|
|
52
53
|
|
|
53
54
|
|
|
54
55
|
def get_current_utc() -> datetime:
|
|
@@ -105,6 +106,7 @@ def get_dealer_by_organization_id(organization_id: str) -> str:
|
|
|
105
106
|
|
|
106
107
|
return organization_id
|
|
107
108
|
|
|
109
|
+
|
|
108
110
|
def extract_title(name):
|
|
109
111
|
if '小姐' in name:
|
|
110
112
|
return '小姐'
|
|
@@ -115,6 +117,7 @@ def extract_title(name):
|
|
|
115
117
|
else:
|
|
116
118
|
return None
|
|
117
119
|
|
|
120
|
+
|
|
118
121
|
def extract_name(name):
|
|
119
122
|
"""从姓名中提取真实姓名"""
|
|
120
123
|
# 检查是否包含 '小姐' 或 '先生' 并提取姓名
|
|
@@ -125,4 +128,28 @@ def extract_name(name):
|
|
|
125
128
|
elif '先生' in name:
|
|
126
129
|
return name.split('先生')[0].strip()
|
|
127
130
|
else:
|
|
128
|
-
return name.strip()
|
|
131
|
+
return name.strip()
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def hash_login_password(passwd):
|
|
135
|
+
prefix = '___'
|
|
136
|
+
postfix = '_______'
|
|
137
|
+
data = str(passwd)
|
|
138
|
+
sha_256 = hashlib.sha256()
|
|
139
|
+
sha_256.update(prefix.encode())
|
|
140
|
+
sha_256.update(data.encode())
|
|
141
|
+
sha_256.update(postfix.encode())
|
|
142
|
+
|
|
143
|
+
return sha_256.hexdigest()
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def hash_secret_key(passwd):
|
|
147
|
+
prefix = '___'
|
|
148
|
+
postfix = '_______'
|
|
149
|
+
data = str(passwd)
|
|
150
|
+
sha_256 = hashlib.sha256()
|
|
151
|
+
sha_256.update(prefix.encode())
|
|
152
|
+
sha_256.update(data.encode())
|
|
153
|
+
sha_256.update(postfix.encode())
|
|
154
|
+
|
|
155
|
+
return sha_256.hexdigest()
|
internal/validator_utils.py
CHANGED
|
@@ -10,8 +10,12 @@ def verify_and_sanitize_plate_no(value: str, is_require: bool = False):
|
|
|
10
10
|
raise PlateNoFormatException()
|
|
11
11
|
|
|
12
12
|
if value:
|
|
13
|
-
|
|
13
|
+
# 移除空格和常見分隔符號進行檢查
|
|
14
|
+
cleaned = sanitize_plate_no(value)
|
|
15
|
+
|
|
16
|
+
if not re.match(r'^[外使領試臨軍A-Za-z0-9]{5,7}$', cleaned):
|
|
14
17
|
raise PlateNoFormatException()
|
|
18
|
+
|
|
15
19
|
return sanitize_plate_no(value)
|
|
16
20
|
|
|
17
21
|
|
|
@@ -25,16 +25,16 @@ internal/ext/amazon/aws/__init__.py,sha256=2YFjb-rHG1JaZGZiZffYDesgTAJjDshOqQbsw
|
|
|
25
25
|
internal/ext/amazon/aws/const.py,sha256=l4WMg5bKWujwOKABBkCO2zclNg3abnYOfbhD7DG8GsA,109
|
|
26
26
|
internal/http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
27
|
internal/http/requests.py,sha256=jLnOXEQOMEOpZrevVGFKlQ_MCkhjfudRqkuC-HWeHx0,8913
|
|
28
|
-
internal/http/responses.py,sha256=
|
|
28
|
+
internal/http/responses.py,sha256=CueHdh9JvUZ8MEuLgLefuB-yv4ikJZIDzA-dMWtYZAk,4872
|
|
29
29
|
internal/interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
30
|
internal/interface/base_interface.py,sha256=3YaVjIgLi_pZpLk5SEIk8WVkuICM8qPavT8rB0MdB5U,1536
|
|
31
31
|
internal/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
32
|
internal/middleware/log_request.py,sha256=ZtCyfrF3IyKTF6Uj8L66CutdZi3srVmppqO_EXT5Tuw,3035
|
|
33
33
|
internal/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
|
-
internal/model/base_model.py,sha256
|
|
34
|
+
internal/model/base_model.py,sha256=-YlVPZGuG926PksyQw5SgKjkdC80q_eQTL3EnzVSfIs,8020
|
|
35
35
|
internal/model/operate.py,sha256=QSM6yXYXpJMwrqkUGEWZLrEBaUgqHwVHY_Fi4S42hKc,3190
|
|
36
|
-
internal/utils.py,sha256=
|
|
37
|
-
internal/validator_utils.py,sha256=
|
|
38
|
-
internal-1.1.
|
|
39
|
-
internal-1.1.
|
|
40
|
-
internal-1.1.
|
|
36
|
+
internal/utils.py,sha256=6iIM1EPLeYYj5LEdgqDADGH-52q9YM6lOxaaxs6z1Gg,4559
|
|
37
|
+
internal/validator_utils.py,sha256=iRI8aJLz0wz-j8p-T1BOGOF8VE2zwNh424uApbc8IZs,1640
|
|
38
|
+
internal-1.1.45.dist-info/METADATA,sha256=-g_Uw-lP4eo9_jIYZVg_nSJdxhd_L8J5AQ-g8kZjtws,939
|
|
39
|
+
internal-1.1.45.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
|
|
40
|
+
internal-1.1.45.dist-info/RECORD,,
|
|
File without changes
|