internal 0.1.73__py3-none-any.whl → 0.1.75__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.
Potentially problematic release.
This version of internal might be problematic. Click here for more details.
- internal/exception/internal_exception.py +9 -0
- internal/http/responses.py +1 -1
- internal/model/base_model.py +30 -4
- {internal-0.1.73.dist-info → internal-0.1.75.dist-info}/METADATA +1 -1
- {internal-0.1.73.dist-info → internal-0.1.75.dist-info}/RECORD +6 -6
- {internal-0.1.73.dist-info → internal-0.1.75.dist-info}/WHEEL +0 -0
|
@@ -36,3 +36,12 @@ class DatabaseConnectFailureException(InternalBaseException):
|
|
|
36
36
|
def __init__(self, message: str = None, **kwargs):
|
|
37
37
|
_message = message or self.message
|
|
38
38
|
super().__init__(status.HTTP_500_INTERNAL_SERVER_ERROR, self.code, _message, **kwargs)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class NoChangeException(InternalBaseException):
|
|
42
|
+
code = "error_no_change"
|
|
43
|
+
message = "Document no change"
|
|
44
|
+
|
|
45
|
+
def __init__(self, message: str = None, **kwargs):
|
|
46
|
+
_message = message or self.message
|
|
47
|
+
super().__init__(status.HTTP_200_OK, self.code, _message, **kwargs)
|
internal/http/responses.py
CHANGED
|
@@ -9,7 +9,7 @@ from beanie import Document, Link
|
|
|
9
9
|
async def async_response(data=None, message=None, code=None, page_no=None, total_num=None, page_size=None,
|
|
10
10
|
status_code=status.HTTP_200_OK):
|
|
11
11
|
def _serialize(data):
|
|
12
|
-
if issubclass(data, Document):
|
|
12
|
+
if issubclass(type(data), Document):
|
|
13
13
|
link_field_list = []
|
|
14
14
|
for field_name in data.__annotations__:
|
|
15
15
|
field_type = getattr(data, field_name)
|
internal/model/base_model.py
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
2
|
from enum import Enum
|
|
3
|
-
from typing import List, Tuple
|
|
3
|
+
from typing import List, Tuple, Union, Dict, Type
|
|
4
4
|
|
|
5
|
+
import arrow
|
|
5
6
|
import pymongo
|
|
6
|
-
from fastapi import FastAPI
|
|
7
7
|
from beanie import Document
|
|
8
|
-
from
|
|
8
|
+
from fastapi import FastAPI
|
|
9
|
+
from pydantic import Field, BaseModel
|
|
9
10
|
|
|
11
|
+
from .operate import Operate
|
|
10
12
|
from ..const import DEF_PAGE_SIZE, DEF_PAGE_NO
|
|
13
|
+
from ..exception.internal_exception import NoChangeException
|
|
11
14
|
|
|
12
15
|
|
|
13
16
|
class InternalBaseDocument(Document):
|
|
@@ -16,7 +19,8 @@ class InternalBaseDocument(Document):
|
|
|
16
19
|
|
|
17
20
|
@classmethod
|
|
18
21
|
async def get_pagination_list(cls, app: FastAPI, query: list = None, sort: List[Tuple] = None,
|
|
19
|
-
page_size: int = DEF_PAGE_SIZE, page_no: int = DEF_PAGE_NO,
|
|
22
|
+
page_size: int = DEF_PAGE_SIZE, page_no: int = DEF_PAGE_NO,
|
|
23
|
+
ignore_cache: bool = False,
|
|
20
24
|
fetch_links: bool = False):
|
|
21
25
|
if not query:
|
|
22
26
|
final_query = []
|
|
@@ -46,6 +50,28 @@ class InternalBaseDocument(Document):
|
|
|
46
50
|
|
|
47
51
|
return page_no, page_size, total_num, page_data
|
|
48
52
|
|
|
53
|
+
async def update_wrap(self, schema: Union[Dict, Type[BaseModel]]) -> Tuple[Operate, 'InternalBaseDocument']:
|
|
54
|
+
if not issubclass(type(schema), dict) and not issubclass(type(schema), BaseModel):
|
|
55
|
+
raise TypeError("Schema must be a subclass of BaseModel or dict")
|
|
56
|
+
|
|
57
|
+
original_model = self.model_copy(deep=True)
|
|
58
|
+
delta_dict = schema
|
|
59
|
+
if issubclass(type(schema), BaseModel):
|
|
60
|
+
delta_dict = schema.model_dump()
|
|
61
|
+
|
|
62
|
+
for key, value in delta_dict.items():
|
|
63
|
+
if value is not None and hasattr(self, key):
|
|
64
|
+
setattr(self, key, value)
|
|
65
|
+
|
|
66
|
+
operate = await Operate.generate_operate(original_model.model_dump(), self.model_dump())
|
|
67
|
+
if not operate.add and not operate.remove and not operate.change:
|
|
68
|
+
raise NoChangeException()
|
|
69
|
+
|
|
70
|
+
self.update_time = arrow.utcnow().datetime
|
|
71
|
+
|
|
72
|
+
await self.save()
|
|
73
|
+
return operate, self
|
|
74
|
+
|
|
49
75
|
|
|
50
76
|
class OrderTypeEnum(str, Enum):
|
|
51
77
|
ASC = "ASC"
|
|
@@ -8,20 +8,20 @@ internal/const.py,sha256=U1S9r7bjtHgad2oYQoHO19s8D4V0WDUG-L-haV4UaIw,1025
|
|
|
8
8
|
internal/database.py,sha256=jnvcj3HVM7VLXAQQq4hCkxUufL6BmI01tbsJw671S8U,838
|
|
9
9
|
internal/exception/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
10
|
internal/exception/base_exception.py,sha256=U0ZXx1FOXydAnQQImznkeAdsKVC_YaukPWvJdWqEBfg,363
|
|
11
|
-
internal/exception/internal_exception.py,sha256=
|
|
11
|
+
internal/exception/internal_exception.py,sha256=byaaH5DBZTp-M8YMzGicOS2rHMg7S4zS7Two-1r7tj8,1651
|
|
12
12
|
internal/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
internal/ext/amazon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
internal/ext/amazon/aws/__init__.py,sha256=2YFjb-rHG1JaZGZiZffYDesgTAJjDshOqQbswOYzhP8,834
|
|
15
15
|
internal/ext/amazon/aws/const.py,sha256=l4WMg5bKWujwOKABBkCO2zclNg3abnYOfbhD7DG8GsA,109
|
|
16
16
|
internal/http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
internal/http/requests.py,sha256=o-eMxG4HqlgJGoErPaiRywGbw5cfUYiW4wJGMXEovS4,1415
|
|
18
|
-
internal/http/responses.py,sha256=
|
|
18
|
+
internal/http/responses.py,sha256=IVY-piFxA9iCUx6p_Y7OCgbx0-yJxc_laGDqrhZ4Z6I,1590
|
|
19
19
|
internal/interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
20
|
internal/interface/base_interface.py,sha256=R5MmO5oa5-ORPV_adkegLVCwsVio2zFOuQFGiby3khs,340
|
|
21
21
|
internal/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
-
internal/model/base_model.py,sha256=
|
|
22
|
+
internal/model/base_model.py,sha256=SeJtYynw1Uq2_tW95evqVbVFz8OpaLAgQfKkcPPdVzg,2962
|
|
23
23
|
internal/model/operate.py,sha256=luEoP_Asvso_11qz1SAE1Kn5KxAnDRptM0VylC5tNik,1493
|
|
24
24
|
internal/utils.py,sha256=0SubS0iUhDvjSX1F4TykasA5-enYJzt2VH-f7_0BnjI,1509
|
|
25
|
-
internal-0.1.
|
|
26
|
-
internal-0.1.
|
|
27
|
-
internal-0.1.
|
|
25
|
+
internal-0.1.75.dist-info/METADATA,sha256=CLrPlXt9weplJMudUQKQJH24wTgaovW_v_EPOlq-alo,625
|
|
26
|
+
internal-0.1.75.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
27
|
+
internal-0.1.75.dist-info/RECORD,,
|
|
File without changes
|