springbootAI 1.8.0__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.
Files changed (175) hide show
  1. spring/__init__.py +66 -0
  2. spring/ai/__init__.py +78 -0
  3. spring/ai/advisors.py +139 -0
  4. spring/ai/annotations.py +74 -0
  5. spring/ai/autoconfig.py +481 -0
  6. spring/ai/core.py +391 -0
  7. spring/ai/etl.py +188 -0
  8. spring/ai/memory.py +109 -0
  9. spring/ai/observability.py +129 -0
  10. spring/ai/providers.py +789 -0
  11. spring/ai/resilience.py +258 -0
  12. spring/ai/tools.py +106 -0
  13. spring/ai/vectorstore.py +303 -0
  14. spring/annotations/__init__.py +188 -0
  15. spring/annotations/cache.py +126 -0
  16. spring/annotations/cloud.py +207 -0
  17. spring/annotations/conditional.py +272 -0
  18. spring/annotations/core.py +864 -0
  19. spring/annotations/messaging.py +107 -0
  20. spring/aop/__init__.py +4 -0
  21. spring/aop/cloud_aop.py +404 -0
  22. spring/aop/comprehensive_aop.py +1015 -0
  23. spring/aop/method_interceptor.py +19 -0
  24. spring/aop/proxy_factory.py +55 -0
  25. spring/cloud/__init__.py +76 -0
  26. spring/cloud/discovery.py +364 -0
  27. spring/cloud/feign.py +469 -0
  28. spring/cloud/gateway.py +452 -0
  29. spring/cloud/load_balancer.py +149 -0
  30. spring/cloud/seata.py +557 -0
  31. spring/cloud/sentinel.py +525 -0
  32. spring/cloud/tracer.py +337 -0
  33. spring/config/__init__.py +21 -0
  34. spring/config/binding.py +206 -0
  35. spring/config/config_loader.py +405 -0
  36. spring/context/__init__.py +13 -0
  37. spring/context/application_context.py +589 -0
  38. spring/context/bean_definition.py +70 -0
  39. spring/context/bean_factory.py +1052 -0
  40. spring/context/registry.py +58 -0
  41. spring/context/scanner.py +106 -0
  42. spring/core/__init__.py +3 -0
  43. spring/core/graceful_shutdown.py +196 -0
  44. spring/core/typing_utils.py +50 -0
  45. spring/csv/__init__.py +52 -0
  46. spring/csv/annotations.py +402 -0
  47. spring/csv/converters.py +69 -0
  48. spring/csv/easy_csv.py +95 -0
  49. spring/csv/exceptions.py +27 -0
  50. spring/csv/reader.py +195 -0
  51. spring/csv/writer.py +155 -0
  52. spring/data/__init__.py +54 -0
  53. spring/data/page.py +181 -0
  54. spring/data/repository.py +274 -0
  55. spring/data/specification.py +228 -0
  56. spring/datasource/__init__.py +66 -0
  57. spring/datasource/annotations.py +133 -0
  58. spring/datasource/context.py +69 -0
  59. spring/datasource/dynamic.py +148 -0
  60. spring/event/__init__.py +7 -0
  61. spring/event/publisher.py +69 -0
  62. spring/excel/__init__.py +51 -0
  63. spring/excel/annotations.py +405 -0
  64. spring/excel/converters.py +231 -0
  65. spring/excel/easy_excel.py +94 -0
  66. spring/excel/exceptions.py +31 -0
  67. spring/excel/reader.py +254 -0
  68. spring/excel/style.py +95 -0
  69. spring/excel/writer.py +197 -0
  70. spring/i18n/__init__.py +97 -0
  71. spring/i18n/accessor.py +94 -0
  72. spring/i18n/auto_config.py +177 -0
  73. spring/i18n/holder.py +106 -0
  74. spring/i18n/locale.py +152 -0
  75. spring/i18n/locale_resolver.py +367 -0
  76. spring/i18n/message_source.py +250 -0
  77. spring/i18n/middleware.py +79 -0
  78. spring/i18n/properties.py +168 -0
  79. spring/i18n/sources.py +255 -0
  80. spring/logging/__init__.py +1 -0
  81. spring/logging/loguru_logger.py +228 -0
  82. spring/main.py +378 -0
  83. spring/messaging/__init__.py +1 -0
  84. spring/messaging/rabbitmq.py +302 -0
  85. spring/monitoring/__init__.py +1 -0
  86. spring/monitoring/prometheus.py +199 -0
  87. spring/orm/__init__.py +258 -0
  88. spring/orm/database.py +222 -0
  89. spring/orm/ddl_auto.py +1217 -0
  90. spring/orm/migration.py +419 -0
  91. spring/orm/mybatis_integration.py +400 -0
  92. spring/orm/pymybatis/__init__.py +86 -0
  93. spring/orm/pymybatis/annotations/__init__.py +30 -0
  94. spring/orm/pymybatis/annotations/annotations.py +332 -0
  95. spring/orm/pymybatis/cache/__init__.py +47 -0
  96. spring/orm/pymybatis/cache/cache.py +371 -0
  97. spring/orm/pymybatis/cache/redis_cache.py +434 -0
  98. spring/orm/pymybatis/circuit_breaker/__init__.py +21 -0
  99. spring/orm/pymybatis/circuit_breaker/circuit_breaker.py +424 -0
  100. spring/orm/pymybatis/configuration.py +525 -0
  101. spring/orm/pymybatis/core/__init__.py +10 -0
  102. spring/orm/pymybatis/core/sql_session.py +1382 -0
  103. spring/orm/pymybatis/core/sql_session_factory.py +76 -0
  104. spring/orm/pymybatis/dialect/__init__.py +9 -0
  105. spring/orm/pymybatis/dialect/dialect.py +445 -0
  106. spring/orm/pymybatis/dynamic_sql/__init__.py +9 -0
  107. spring/orm/pymybatis/dynamic_sql/dynamic_sql.py +900 -0
  108. spring/orm/pymybatis/interceptor/__init__.py +31 -0
  109. spring/orm/pymybatis/interceptor/interceptor.py +427 -0
  110. spring/orm/pymybatis/mapper/__init__.py +9 -0
  111. spring/orm/pymybatis/mapper/mapper.py +540 -0
  112. spring/orm/pymybatis/metrics/__init__.py +41 -0
  113. spring/orm/pymybatis/metrics/metrics.py +595 -0
  114. spring/orm/pymybatis/pool/__init__.py +9 -0
  115. spring/orm/pymybatis/pool/connection_pool.py +711 -0
  116. spring/orm/pymybatis/security/__init__.py +19 -0
  117. spring/orm/pymybatis/security/access_control.py +415 -0
  118. spring/orm/pymybatis/security/password_encoder.py +293 -0
  119. spring/orm/pymybatis/security/sensitive_data_masker.py +326 -0
  120. spring/orm/pymybatis/security/sql_injection_detector.py +675 -0
  121. spring/orm/pymybatis/transaction/__init__.py +9 -0
  122. spring/orm/pymybatis/transaction/transaction.py +288 -0
  123. spring/orm/pymybatis/type_handler/__init__.py +37 -0
  124. spring/orm/pymybatis/type_handler/type_handler.py +473 -0
  125. spring/orm/pymybatis/version.py +9 -0
  126. spring/orm/pymybatis/xml_parser/__init__.py +9 -0
  127. spring/orm/pymybatis/xml_parser/xml_parser.py +761 -0
  128. spring/retry/__init__.py +12 -0
  129. spring/retry/retry_annotations.py +71 -0
  130. spring/retry/retry_decorator.py +155 -0
  131. spring/scheduling/__init__.py +3 -0
  132. spring/scheduling/scheduler.py +389 -0
  133. spring/security/__init__.py +39 -0
  134. spring/security/jwt_utils.py +281 -0
  135. spring/security/replay_protection.py +206 -0
  136. spring/security/secret_manager.py +226 -0
  137. spring/security/security_aop.py +248 -0
  138. spring/security/security_context.py +172 -0
  139. spring/test/__init__.py +45 -0
  140. spring/test/slicing.py +341 -0
  141. spring/tracing/__init__.py +11 -0
  142. spring/tracing/skywalking.py +229 -0
  143. spring/tx/__init__.py +52 -0
  144. spring/tx/events.py +172 -0
  145. spring/tx/synchronization.py +143 -0
  146. spring/utils/__init__.py +5 -0
  147. spring/utils/banner.py +32 -0
  148. spring/utils/logger.py +73 -0
  149. spring/utils/redis_client.py +526 -0
  150. spring/validation/__init__.py +55 -0
  151. spring/validation/aop.py +141 -0
  152. spring/validation/constraints.py +357 -0
  153. spring/validation/exceptions.py +55 -0
  154. spring/validation/validator.py +139 -0
  155. spring/web/__init__.py +12 -0
  156. spring/web/actuator.py +319 -0
  157. spring/web/exception_handler.py +61 -0
  158. spring/web/health.py +399 -0
  159. spring/web/interceptor.py +91 -0
  160. spring/web/result.py +44 -0
  161. spring/web/swagger.py +601 -0
  162. spring/web/web_context.py +755 -0
  163. spring/websocket/__init__.py +86 -0
  164. spring/websocket/annotations.py +169 -0
  165. spring/websocket/broker.py +238 -0
  166. spring/websocket/exceptions.py +26 -0
  167. spring/websocket/handler.py +243 -0
  168. spring/websocket/router.py +526 -0
  169. spring/websocket/session.py +216 -0
  170. springbootai-1.8.0.dist-info/METADATA +2796 -0
  171. springbootai-1.8.0.dist-info/RECORD +175 -0
  172. springbootai-1.8.0.dist-info/WHEEL +5 -0
  173. springbootai-1.8.0.dist-info/entry_points.txt +2 -0
  174. springbootai-1.8.0.dist-info/licenses/LICENSE +7 -0
  175. springbootai-1.8.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,31 @@
1
+ """
2
+ PyMyBatis拦截器模块
3
+
4
+ 支持自定义插件拦截SQL执行过程
5
+ """
6
+
7
+ from .interceptor import (
8
+ ExecutorInterceptor,
9
+ Interceptor,
10
+ InterceptorChain,
11
+ InterceptorSecurityError,
12
+ Invocation,
13
+ LogInterceptor,
14
+ PerformanceInterceptor,
15
+ Plugin,
16
+ PluginProxy,
17
+ SecurityInterceptor,
18
+ )
19
+
20
+ __all__ = [
21
+ 'ExecutorInterceptor',
22
+ 'Interceptor',
23
+ 'InterceptorChain',
24
+ 'InterceptorSecurityError',
25
+ 'Invocation',
26
+ 'LogInterceptor',
27
+ 'PerformanceInterceptor',
28
+ 'Plugin',
29
+ 'PluginProxy',
30
+ 'SecurityInterceptor',
31
+ ]
@@ -0,0 +1,427 @@
1
+ """
2
+ PyMyBatis拦截器模块
3
+
4
+ 支持自定义插件拦截SQL执行过程,类似于MyBatis的Interceptor机制
5
+ """
6
+
7
+ from typing import Any, Optional
8
+ from abc import ABC, abstractmethod
9
+
10
+
11
+ class InterceptorChain:
12
+ """
13
+ 拦截器链
14
+
15
+ 管理多个拦截器,按照顺序执行
16
+ """
17
+
18
+ def __init__(self):
19
+ """初始化拦截器链"""
20
+ self.interceptors: list = []
21
+
22
+ def add_interceptor(self, interceptor: 'Interceptor') -> None:
23
+ """
24
+ 添加拦截器
25
+
26
+ Args:
27
+ interceptor: 拦截器实例
28
+ """
29
+ self.interceptors.append(interceptor)
30
+
31
+ def remove_interceptor(self, interceptor: 'Interceptor') -> None:
32
+ """
33
+ 移除拦截器
34
+
35
+ Args:
36
+ interceptor: 拦截器实例
37
+ """
38
+ if interceptor in self.interceptors:
39
+ self.interceptors.remove(interceptor)
40
+
41
+ def clear(self) -> None:
42
+ """清空所有拦截器"""
43
+ self.interceptors.clear()
44
+
45
+ def plugin_all(self, target: Any) -> Any:
46
+ """
47
+ 为目标对象添加所有拦截器
48
+
49
+ Args:
50
+ target: 目标对象
51
+
52
+ Returns:
53
+ 包装后的目标对象
54
+ """
55
+ for interceptor in self.interceptors:
56
+ target = interceptor.plugin(target)
57
+ return target
58
+
59
+ def invoke(self, target: Any, method: str, args: tuple, kwargs: dict,
60
+ proceed) -> Any:
61
+ """Run interceptors as one ordered invocation chain.
62
+
63
+ This path is used by ``SqlSession`` directly, avoiding a proxy around
64
+ the session that would recursively invoke the same public method.
65
+ """
66
+ def invoke_at(index: int) -> Any:
67
+ if index >= len(self.interceptors):
68
+ return proceed()
69
+ invocation = Invocation(
70
+ target, method, args, kwargs,
71
+ proceed=lambda: invoke_at(index + 1),
72
+ )
73
+ return self.interceptors[index].intercept(invocation)
74
+
75
+ return invoke_at(0)
76
+
77
+
78
+ class Interceptor(ABC):
79
+ """
80
+ 拦截器抽象基类
81
+
82
+ 定义拦截器的核心接口:
83
+ - intercept: 执行拦截逻辑
84
+ - plugin: 包装目标对象
85
+ - set_properties: 设置属性
86
+ """
87
+
88
+ @abstractmethod
89
+ def intercept(self, invocation: 'Invocation') -> Any:
90
+ """
91
+ 执行拦截逻辑
92
+
93
+ Args:
94
+ invocation: 调用对象
95
+
96
+ Returns:
97
+ 拦截结果
98
+ """
99
+ pass
100
+
101
+ def plugin(self, target: Any) -> Any:
102
+ """
103
+ 包装目标对象
104
+
105
+ Args:
106
+ target: 目标对象
107
+
108
+ Returns:
109
+ 包装后的目标对象
110
+ """
111
+ return Plugin.wrap(target, self)
112
+
113
+ def set_properties(self, properties: dict) -> None:
114
+ """
115
+ 设置属性
116
+
117
+ Args:
118
+ properties: 属性字典
119
+ """
120
+ pass
121
+
122
+
123
+ class Invocation:
124
+ """
125
+ 调用对象
126
+
127
+ 封装被拦截的方法调用
128
+ """
129
+
130
+ def __init__(self, target: Any, method: str, args: tuple,
131
+ kwargs: Optional[dict] = None, proceed=None):
132
+ """
133
+ 初始化调用对象
134
+
135
+ Args:
136
+ target: 目标对象
137
+ method: 方法名
138
+ args: 方法参数
139
+ """
140
+ self.target = target
141
+ self.method = method
142
+ self.args = args
143
+ self.kwargs = kwargs or {}
144
+ self._proceed = proceed
145
+
146
+ def proceed(self) -> Any:
147
+ """
148
+ 执行原方法
149
+
150
+ Returns:
151
+ 方法执行结果
152
+ """
153
+ if self._proceed is not None:
154
+ return self._proceed()
155
+ return getattr(self.target, self.method)(*self.args, **self.kwargs)
156
+
157
+ def get_target(self) -> Any:
158
+ """获取目标对象"""
159
+ return self.target
160
+
161
+ def get_method(self) -> str:
162
+ """获取方法名"""
163
+ return self.method
164
+
165
+ def get_args(self) -> tuple:
166
+ """获取方法参数"""
167
+ return self.args
168
+
169
+ def get_kwargs(self) -> dict:
170
+ """Return keyword arguments passed to the intercepted method."""
171
+ return dict(self.kwargs)
172
+
173
+
174
+ class Plugin:
175
+ """
176
+ 插件包装器
177
+
178
+ 使用动态代理包装目标对象,实现拦截功能
179
+ """
180
+
181
+ @staticmethod
182
+ def wrap(target: Any, interceptor: Interceptor) -> Any:
183
+ """
184
+ 包装目标对象
185
+
186
+ Args:
187
+ target: 目标对象
188
+ interceptor: 拦截器
189
+
190
+ Returns:
191
+ 包装后的对象
192
+ """
193
+ return PluginProxy(target, interceptor)
194
+
195
+
196
+ class PluginProxy:
197
+ """
198
+ 插件代理类
199
+
200
+ 实现动态代理,拦截目标对象的方法调用
201
+ """
202
+
203
+ def __init__(self, target: Any, interceptor: Interceptor):
204
+ """
205
+ 初始化代理对象
206
+
207
+ Args:
208
+ target: 目标对象
209
+ interceptor: 拦截器
210
+ """
211
+ self.target = target
212
+ self.interceptor = interceptor
213
+
214
+ def __getattr__(self, name: str):
215
+ """
216
+ 获取属性
217
+
218
+ Args:
219
+ name: 属性名
220
+
221
+ Returns:
222
+ 属性值或方法包装器
223
+ """
224
+ attr = getattr(self.target, name)
225
+
226
+ if callable(attr):
227
+ def wrapper(*args, **kwargs):
228
+ invocation = Invocation(self.target, name, args, kwargs)
229
+ return self.interceptor.intercept(invocation)
230
+ return wrapper
231
+
232
+ return attr
233
+
234
+
235
+ class ExecutorInterceptor(Interceptor):
236
+ """
237
+ Executor拦截器
238
+
239
+ 拦截SQL执行过程,可用于日志记录、性能监控等
240
+ """
241
+
242
+ def intercept(self, invocation: Invocation) -> Any:
243
+ """
244
+ 执行拦截逻辑
245
+
246
+ Args:
247
+ invocation: 调用对象
248
+
249
+ Returns:
250
+ 拦截结果
251
+ """
252
+ method = invocation.get_method()
253
+ args = invocation.get_args()
254
+
255
+ # 记录执行前信息
256
+ print(f"[ExecutorInterceptor] Executing method: {method}")
257
+ print(f"[ExecutorInterceptor] Args: {args}")
258
+
259
+ # 执行原方法
260
+ result = invocation.proceed()
261
+
262
+ # 记录执行后信息
263
+ print(f"[ExecutorInterceptor] Method {method} completed")
264
+
265
+ return result
266
+
267
+
268
+ class LogInterceptor(Interceptor):
269
+ """
270
+ 日志拦截器
271
+
272
+ 记录SQL执行日志,包括SQL语句、参数和执行时间
273
+ """
274
+
275
+ def __init__(self, logger=None):
276
+ """
277
+ 初始化日志拦截器
278
+
279
+ Args:
280
+ logger: 日志记录器,不指定则使用print
281
+ """
282
+ self.logger = logger
283
+
284
+ def intercept(self, invocation: Invocation) -> Any:
285
+ """
286
+ 执行拦截逻辑
287
+
288
+ Args:
289
+ invocation: 调用对象
290
+
291
+ Returns:
292
+ 拦截结果
293
+ """
294
+ import time
295
+
296
+ method = invocation.get_method()
297
+ args = invocation.get_args()
298
+
299
+ # 提取SQL和参数
300
+ sql = None
301
+ params = None
302
+ if args:
303
+ for arg in args:
304
+ if isinstance(arg, str) and ('SELECT' in arg.upper() or 'INSERT' in arg.upper()
305
+ or 'UPDATE' in arg.upper() or 'DELETE' in arg.upper()):
306
+ sql = arg
307
+ elif isinstance(arg, dict):
308
+ params = arg
309
+
310
+ # 记录开始时间
311
+ start_time = time.time()
312
+
313
+ # 执行原方法
314
+ result = invocation.proceed()
315
+
316
+ # 记录执行时间
317
+ end_time = time.time()
318
+ elapsed_time = (end_time - start_time) * 1000
319
+
320
+ # 记录日志
321
+ log_message = f"[SQL] {method}: {sql}"
322
+ if params:
323
+ log_message += f" | Params: {params}"
324
+ log_message += f" | Time: {elapsed_time:.2f}ms"
325
+
326
+ if self.logger:
327
+ self.logger.info(log_message)
328
+ else:
329
+ print(log_message)
330
+
331
+ return result
332
+
333
+
334
+ class PerformanceInterceptor(Interceptor):
335
+ """
336
+ 性能监控拦截器
337
+
338
+ 监控SQL执行性能,记录慢查询
339
+ """
340
+
341
+ def __init__(self, slow_query_threshold: float = 1.0):
342
+ """
343
+ 初始化性能监控拦截器
344
+
345
+ Args:
346
+ slow_query_threshold: 慢查询阈值(秒),默认为1秒
347
+ """
348
+ self.slow_query_threshold = slow_query_threshold
349
+
350
+ def intercept(self, invocation: Invocation) -> Any:
351
+ """
352
+ 执行拦截逻辑
353
+
354
+ Args:
355
+ invocation: 调用对象
356
+
357
+ Returns:
358
+ 拦截结果
359
+ """
360
+ import time
361
+
362
+ # 记录开始时间
363
+ start_time = time.time()
364
+
365
+ # 执行原方法
366
+ result = invocation.proceed()
367
+
368
+ # 记录执行时间
369
+ end_time = time.time()
370
+ elapsed_time = end_time - start_time
371
+
372
+ # 检查是否慢查询
373
+ if elapsed_time > self.slow_query_threshold:
374
+ method = invocation.get_method()
375
+ args = invocation.get_args()
376
+
377
+ # 提取SQL
378
+ sql = None
379
+ if args:
380
+ for arg in args:
381
+ if isinstance(arg, str) and ('SELECT' in arg.upper() or 'INSERT' in arg.upper()
382
+ or 'UPDATE' in arg.upper() or 'DELETE' in arg.upper()):
383
+ sql = arg
384
+
385
+ print(f"[SLOW QUERY] {method}: {sql} | Time: {elapsed_time:.2f}s")
386
+
387
+ return result
388
+
389
+
390
+ class SecurityInterceptor(Interceptor):
391
+ """
392
+ 安全拦截器
393
+
394
+ 检查SQL执行的安全性,防止SQL注入等攻击
395
+ """
396
+
397
+ def intercept(self, invocation: Invocation) -> Any:
398
+ """
399
+ 执行拦截逻辑
400
+
401
+ Args:
402
+ invocation: 调用对象
403
+
404
+ Returns:
405
+ 拦截结果
406
+ """
407
+ from ..security.sql_injection_detector import check_sql_injection
408
+
409
+ args = invocation.get_args()
410
+
411
+ # 检查参数安全性
412
+ for arg in args:
413
+ if isinstance(arg, dict):
414
+ for key, value in arg.items():
415
+ if not check_sql_injection(value):
416
+ raise InterceptorSecurityError(f"SQL注入检测失败: {key}={value}")
417
+ elif isinstance(arg, str):
418
+ if not check_sql_injection(arg):
419
+ raise InterceptorSecurityError(f"SQL注入检测失败: {arg}")
420
+
421
+ # 执行原方法
422
+ return invocation.proceed()
423
+
424
+
425
+ class InterceptorSecurityError(Exception):
426
+ """安全异常"""
427
+ pass
@@ -0,0 +1,9 @@
1
+ """
2
+ PyMyBatis映射器模块
3
+
4
+ 包含Mapper接口定义和代理实现
5
+ """
6
+
7
+ from .mapper import Mapper, MapperProxy, MapperRegistry
8
+
9
+ __all__ = ['Mapper', 'MapperProxy', 'MapperRegistry']