internal 1.1.31__py3-none-any.whl → 1.1.32.1__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.

@@ -0,0 +1,6 @@
1
+ from enum import Enum
2
+
3
+
4
+ class PointTypeEnum(str, Enum):
5
+ INVOICE_REWARD = "invoice_reward"
6
+ ACTIVITY = "activity"
internal/database.py CHANGED
@@ -2,6 +2,18 @@ from motor.motor_asyncio import AsyncIOMotorClient
2
2
  from pymongo.errors import ServerSelectionTimeoutError
3
3
 
4
4
  from .exception.internal_exception import DatabaseInitializeFailureException, DatabaseConnectFailureException
5
+ from bson import Decimal128
6
+ from bson.codec_options import CodecOptions, TypeDecoder, TypeRegistry
7
+ from decimal import Decimal
8
+
9
+
10
+ class Decimal128Decoder(TypeDecoder):
11
+ """自定義 Decimal128 解碼器,自動轉換為 Python Decimal"""
12
+ bson_type = Decimal128
13
+ python_type = Decimal
14
+
15
+ def transform_bson(self, value):
16
+ return value.to_decimal()
5
17
 
6
18
 
7
19
  class MongoDB:
@@ -31,7 +43,7 @@ class MongoDB:
31
43
  if self.ssl_ca_certs and self.ssl_ca_certs != "":
32
44
  db_settings["tlsCAFile"] = self.ssl_ca_certs
33
45
 
34
- self.client = AsyncIOMotorClient(**db_settings)
46
+ self.client = AsyncIOMotorClient(**db_settings).get_database()
35
47
  except ServerSelectionTimeoutError:
36
48
  raise DatabaseInitializeFailureException()
37
49
 
@@ -42,7 +54,11 @@ class MongoDB:
42
54
  def get_database(self):
43
55
  if not self.client:
44
56
  raise DatabaseConnectFailureException()
45
- return self.client[self.db_name]
57
+
58
+ type_registry = TypeRegistry([Decimal128Decoder()])
59
+ codec_options = CodecOptions(type_registry=type_registry)
60
+
61
+ return self.client.get_database(self.db_name, codec_options=codec_options)
46
62
 
47
63
  async def get_mongodb_uri(self) -> str:
48
64
  if self.user_name and self.password:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: internal
3
- Version: 1.1.31
3
+ Version: 1.1.32.1
4
4
  Summary:
5
5
  Author: Ray
6
6
  Author-email: ray@cruisys.com
@@ -11,9 +11,10 @@ internal/common_enum/lpr_direction.py,sha256=glCGSkcXHUB6_p2jO_7IdEHycyFVhu0vHDD
11
11
  internal/common_enum/notify_type.py,sha256=p01d9ODiJ9vDpFBJ55bhu7WOyO7Te3slToOhvFKxQbk,188
12
12
  internal/common_enum/operator_type.py,sha256=XfHwGDsuOG6-ajitDoRuLFLT1LhHKoXXzFRW4e5vmJ8,173
13
13
  internal/common_enum/order_type.py,sha256=XwAl5JaZgFLahBQhBKG4VuMJ39Si9KZEhcSS0-DKKzQ,90
14
+ internal/common_enum/point_type.py,sha256=nmrHw_6OJIadgWwqCa63IVnc4T5uf69vQojWPbAwCrE,120
14
15
  internal/common_enum/websocket_channel.py,sha256=BIhdE2z_xF3lgStS8GiaS5M8BXm4_g3vHQaaN5qNJTQ,283
15
16
  internal/const.py,sha256=ozBUBCNwETjtszb5XUrJhVfvKPBzVOMeGt38yenXd0Q,1487
16
- internal/database.py,sha256=1u53JnFJ0jvP7H4HPY2faA2ABdPQ8SlsZigYmQAPktI,2470
17
+ internal/database.py,sha256=HmvvU3570N0O4w-pTFMeKrVR3jVHseAElF9k62xOySM,3021
17
18
  internal/exception/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
19
  internal/exception/app_exception.py,sha256=4HE1BrXBuMTuukwEYJhz_gxS6eIqHpSBFB99J62BHJ0,3803
19
20
  internal/exception/base_exception.py,sha256=8ctp525A3up9mZrHCq_-Jj0hWr_4NfZsXGg1e4ftVuQ,473
@@ -34,6 +35,6 @@ internal/model/base_model.py,sha256=hxleV8fYNvFgUoYmCv_inEP3kA4tD4HhCBCNFVK8SZg,
34
35
  internal/model/operate.py,sha256=QSM6yXYXpJMwrqkUGEWZLrEBaUgqHwVHY_Fi4S42hKc,3190
35
36
  internal/utils.py,sha256=wK1QumW1AaWE1ga2-WcDH2rtXRr2hSLwXzy-iI5dTzY,3962
36
37
  internal/validator_utils.py,sha256=CqjaVFoAu5MqvBG_AkTP-r7AliWawtUWB851USj4moI,1519
37
- internal-1.1.31.dist-info/METADATA,sha256=r3aE-RO0vODruGTmxXMoO25lUPXmaKlENrEU-hicK3A,939
38
- internal-1.1.31.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
39
- internal-1.1.31.dist-info/RECORD,,
38
+ internal-1.1.32.1.dist-info/METADATA,sha256=ygZPGR68G7GFXBS8BNtWK4ckcORIEbOyf75nx_HCAGk,941
39
+ internal-1.1.32.1.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
40
+ internal-1.1.32.1.dist-info/RECORD,,