fastcodedog 3.1.7__tar.gz → 3.2.0__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.
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/PKG-INFO +1 -1
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/api/endpoint.py +1 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/crud/query.py +1 -0
- fastcodedog-3.2.0/fastcodedog/context/model/case.py +15 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/model/model.py +3 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/api/api_function.py +1 -1
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/api/config.py +1 -1
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/api/db.py +4 -2
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/api/oauth2.py +4 -3
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/crud/crud_functions.py +1 -0
- fastcodedog-3.2.0/fastcodedog/generation/model/case.py +42 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/model/model.py +4 -1
- fastcodedog-3.2.0/fastcodedog/prepare/pdm_to_model/after/case.py +29 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/prepare.py +2 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/schema_and_crud_to_api/endpoint.py +1 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/schema_and_crud_to_api/prepare.py +4 -2
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/pyproject.toml +1 -1
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/README.md +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/README_zh.md +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/cli.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/common/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/common/clean_expired.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/common/source_file_path.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/common/write_file.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/api/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/api/api.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/api/oauth2.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/api/param.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/common/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/common/get_context_object.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/common/get_relationship.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/context.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/contextbase.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/crud/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/crud/column.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/crud/crud.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/crud/default_value.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/crud/join_relationship.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/model/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/model/additional_method.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/model/column.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/model/computed_property.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/model/copy_method.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/model/parameter.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/model/relationship.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/schema/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/schema/alias_generator.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/schema/field.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/schema/response_schema.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/schema/schema.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/schema/sub_object.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/setting/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/setting/config.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/setting/extend_app.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/setting/listen.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/setting/project.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/setting/source_directory.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/context/setting/tenant.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/api/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/api/api.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/api/generation.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/api/main.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/base/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/base/block.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/base/call.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/base/class_type.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/base/file.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/base/function.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/base/head_comment.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/base/line_break.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/base/location_finder.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/base/required_import.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/base/text.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/base/variable.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/commonfiles/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/commonfiles/configfiles/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/commonfiles/generation.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/commonfiles/main.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/commonfiles/oauthfiles/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/commonfiles/toolfiles/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/commonfiles/utilfiles/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/commonfiles/utilfiles/api_logging.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/commonfiles/utilfiles/case_converter.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/commonfiles/utilfiles/log.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/crud/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/crud/crud.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/crud/generation.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/crud/query_functions.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/crud/selectinload.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/model/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/model/additional_method.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/model/base.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/model/column.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/model/computed_property.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/model/copy_method.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/model/generation.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/model/init.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/model/relation_object.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/model/relationship.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/model/table_args.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/schema/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/schema/field.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/schema/generation.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/schema/response_schema.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/schema/schema.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/schema/sub_object.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/inc/middleware/api_logging.file.in +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/model_and_schema_to_crud/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/model_and_schema_to_crud/default_values.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/model_and_schema_to_crud/prepare.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/model_and_schema_to_crud/queries.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/model_to_schema/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/model_to_schema/alias_generator.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/model_to_schema/no_input_fields.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/model_to_schema/no_response_fields.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/model_to_schema/prepare.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/model_to_schema/response_schemas.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/model_to_schema/specified_field_types.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/README.MD +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/after/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/after/additional_methods.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/after/additional_relationships.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/after/computed_properties.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/after/copy_methods.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/after/disable_relationships.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/after/specified_class_names.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/after/specified_relationship_orderby.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/before/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/before/additional_foreign_keys.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/before/fill_tenant_id.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/before/specified_column_types.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/before/specified_relationship_names.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/column.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/pdm.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/reference.xml +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/table.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/table.xml +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/schema_and_crud_to_api/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/schema_and_crud_to_api/schemas.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/schema_and_crud_to_api/validate_reponse_models.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/util/__init__.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/util/case_converter.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/util/deep_update.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/util/extractor.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/util/find_file.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/util/indent.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/util/inflect_wrapper.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/util/make_dirs.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/util/read_inc.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/util/singleton.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/util/type_converter.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/util/valid_name.py +0 -0
- {fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/util/wrap_str_with_quotation.py +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from fastcodedog.context.contextbase import ContextBase
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Case(ContextBase):
|
|
6
|
+
def __init__(self):
|
|
7
|
+
super().__init__()
|
|
8
|
+
self.title = '' # 标题,用于描述case的用途
|
|
9
|
+
self.name = '' # case属性名
|
|
10
|
+
self.comment = '' # 详细说明
|
|
11
|
+
self.module = '' # 所属模块
|
|
12
|
+
self.model_name = '' # 所属模型
|
|
13
|
+
self.whens = [] # case条件列表,按顺序定义。自动指定数字和else_
|
|
14
|
+
self._types['whens'] = str
|
|
15
|
+
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
模型
|
|
4
4
|
"""
|
|
5
5
|
from fastcodedog.context.contextbase import ContextBase
|
|
6
|
+
from fastcodedog.context.model.case import Case
|
|
6
7
|
from fastcodedog.context.model.column import Column
|
|
7
8
|
from fastcodedog.context.model.computed_property import ComputedProperty
|
|
8
9
|
from fastcodedog.context.model.additional_method import AdditionalMethod
|
|
@@ -27,6 +28,8 @@ class Model(ContextBase):
|
|
|
27
28
|
self._types['relationships'] = Relationship
|
|
28
29
|
self.computed_properties = {}
|
|
29
30
|
self._types['computed_properties'] = ComputedProperty
|
|
31
|
+
self.cases = {}
|
|
32
|
+
self._types['cases'] = Case
|
|
30
33
|
self.additional_methods = {}
|
|
31
34
|
self._types['additional_methods'] = AdditionalMethod
|
|
32
35
|
self.copy_methods = {}
|
|
@@ -186,7 +186,7 @@ return {{}}""", possible_imports=[self.crud_imoprt, 'from fastapi import HTTPExc
|
|
|
186
186
|
Import('Session', Db().package),
|
|
187
187
|
Import('get_session', Db().package)])
|
|
188
188
|
# Oauth2依赖
|
|
189
|
-
if self.api.context.oauth2_enabled:
|
|
189
|
+
if self.api.context.oauth2_enabled and self.context.oauth2_required:
|
|
190
190
|
self.params['token'] = self.Parameter('token', type='Annotated[str, Depends(oauth2_scheme)]', nullable=True,
|
|
191
191
|
possible_imports=['from fastapi import Depends',
|
|
192
192
|
Import('Annotated', 'typing')])
|
|
@@ -121,7 +121,7 @@ return result
|
|
|
121
121
|
|
|
122
122
|
def _get_ini_content(self):
|
|
123
123
|
content = "; 可以通过ini文件、环境变量和命令行三种方式配置参数,优先级依次递增\n"
|
|
124
|
-
content += "; 通过uvicorn或者celery
|
|
124
|
+
content += "; 通过uvicorn或者celery启动时,日志配置仍然以本配置为准,建议通过环境变量设置不同进程的不同参数\n"
|
|
125
125
|
for section, params in self.sections.items():
|
|
126
126
|
if section.startswith('_'):
|
|
127
127
|
continue
|
|
@@ -16,10 +16,12 @@ class Db(File):
|
|
|
16
16
|
self._init_blocks_and_imports()
|
|
17
17
|
|
|
18
18
|
def _init_blocks_and_imports(self):
|
|
19
|
-
self.blocks.append(Variable('engine', value=f"""create_engine(database_url, connect_args={{"check_same_thread": False}}
|
|
19
|
+
self.blocks.append(Variable('engine', value=f"""create_engine(database_url, pool_size=pool_size, max_overflow=max_overflow, connect_args={{"check_same_thread": False}}
|
|
20
20
|
) if database_url.startswith('sqlite') else create_engine(database_url)""",
|
|
21
21
|
possible_imports=['from sqlalchemy import create_engine',
|
|
22
|
-
Import('database_url', Config().package)
|
|
22
|
+
Import('database_url', Config().package),
|
|
23
|
+
Import('pool_size', Config().package),
|
|
24
|
+
Import('max_overflow', Config().package)]))
|
|
23
25
|
self.blocks.append(Variable('Session', value='sessionmaker(bind=engine)',
|
|
24
26
|
possible_imports=['from sqlalchemy.orm import sessionmaker']))
|
|
25
27
|
get_session = Function('get_session')
|
|
@@ -70,14 +70,15 @@ OAuth2.REDIS_URL = 'redis://localhost:6379/oauth2'""")
|
|
|
70
70
|
if ctx_instance.tenant.enabled:
|
|
71
71
|
tenant_model = ctx_instance.get_tenant_model()
|
|
72
72
|
function.blocks.append(Text(f"""if '@' not in username:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
if not oauth2_default_domain:
|
|
74
|
+
raise HTTPException(status_code=HTTP_400_BAD_REQUEST, detail="用户名格式错误,需要包含域名后缀。比如1001@example.com")
|
|
75
|
+
username = f'{{username}}@{{oauth2_default_domain}}'
|
|
76
76
|
username, domain = username.split('@')
|
|
77
77
|
tenant = session.query({tenant_model.name}).filter_by(domain=domain).filter_by(enabled=True).first()
|
|
78
78
|
if not tenant:
|
|
79
79
|
raise HTTPException(status_code=HTTP_400_BAD_REQUEST, detail="域名后缀不存在或未启用")""",
|
|
80
80
|
possible_imports=[Import(tenant_model.name, LocationFinder.get_package(tenant_model.name, 'model', tenant_model.module)),
|
|
81
|
+
Import('oauth2_default_domain', Config().package),
|
|
81
82
|
'from starlette.status import HTTP_400_BAD_REQUEST']))
|
|
82
83
|
# 如果用户表有tenant_id字段,则需要加上tenant_id的过滤
|
|
83
84
|
if ctx_instance.tenant.local_column_code in user_model.columns:
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from fastcodedog.context.model.case import Case as CaseContext
|
|
3
|
+
from fastcodedog.generation.base.call import Call
|
|
4
|
+
from fastcodedog.generation.base.required_import import Import
|
|
5
|
+
from fastcodedog.generation.base.variable import Variable
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Case(Variable):
|
|
9
|
+
def __init__(self, context: CaseContext = None, parent=None):
|
|
10
|
+
super().__init__(context.name, context=context, parent=parent)
|
|
11
|
+
self.title = context.title # 标题
|
|
12
|
+
self.whens = context.whens # case条件列表
|
|
13
|
+
|
|
14
|
+
self.value = self.get_value()
|
|
15
|
+
self.comment = context.comment if context.comment else self.title
|
|
16
|
+
|
|
17
|
+
self.add_possible_imports([
|
|
18
|
+
Import('from sqlalchemy import case'),
|
|
19
|
+
])
|
|
20
|
+
|
|
21
|
+
def get_value(self):
|
|
22
|
+
"""
|
|
23
|
+
生成类似如下的代码:
|
|
24
|
+
case(
|
|
25
|
+
(result.is_(None), 0),
|
|
26
|
+
(result == False, 1),
|
|
27
|
+
(result == True, 2),
|
|
28
|
+
else_=3
|
|
29
|
+
)
|
|
30
|
+
"""
|
|
31
|
+
case_params = []
|
|
32
|
+
|
|
33
|
+
# 为每个when条件创建一个元组,自动分配数字值
|
|
34
|
+
for index, when_condition in enumerate(self.whens):
|
|
35
|
+
# 创建元组形式: (condition, value)
|
|
36
|
+
case_params.append(f"({when_condition}, {index})")
|
|
37
|
+
|
|
38
|
+
# 添加else_子句,值为条件数量
|
|
39
|
+
case_params.append(f"else_={len(self.whens)}")
|
|
40
|
+
|
|
41
|
+
return Call('case', params=case_params)
|
|
42
|
+
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
from fastcodedog.context.model.model import Model as ModelContext
|
|
3
|
+
from fastcodedog.generation.model.case import Case
|
|
3
4
|
from fastcodedog.generation.model.copy_method import CopyMethod
|
|
4
5
|
from fastcodedog.generation.base.class_type import ClassType
|
|
5
6
|
from fastcodedog.generation.base.line_break import LineBreak
|
|
@@ -27,7 +28,9 @@ class Model(ClassType):
|
|
|
27
28
|
# relationships
|
|
28
29
|
self.blocks.extend([Relationship(relationship, self) for relationship in context.relationships.values() if
|
|
29
30
|
not relationship.disabled])
|
|
30
|
-
|
|
31
|
+
# case
|
|
32
|
+
self.blocks.append(LineBreak()) # 空行
|
|
33
|
+
self.blocks.extend([Case(case, self) for case in context.cases.values()])
|
|
31
34
|
for additional_method in context.additional_methods.values():
|
|
32
35
|
self.blocks.append(AdditionalMethod(additional_method))
|
|
33
36
|
for copy_method in context.copy_methods.values():
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import json5
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
from fastcodedog.util.case_converter import camel_to_snake
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def add_cases(model_directory, cases):
|
|
9
|
+
"""
|
|
10
|
+
对应sqlalchemy的case,可用于order_by, filter, select, group_by, update等场景
|
|
11
|
+
这些属性不保存到数据库,通过各种条件计算得到对应的值
|
|
12
|
+
通过在model和schema中自定义属性的方法定义这些属性
|
|
13
|
+
"""
|
|
14
|
+
for case in cases:
|
|
15
|
+
module = case.get('module')
|
|
16
|
+
model_name = case.get('model_name')
|
|
17
|
+
name = case.get('name')
|
|
18
|
+
if module and model_name and name:
|
|
19
|
+
json_file = os.path.join(model_directory, module, f'{camel_to_snake(model_name)}.json5')
|
|
20
|
+
data = json5.load(open(json_file, 'r', encoding='utf-8'))
|
|
21
|
+
# 移除 case 中的 module 和 model_name
|
|
22
|
+
case.pop('module')
|
|
23
|
+
case.pop('model_name')
|
|
24
|
+
# 确保 cases 键存在
|
|
25
|
+
if 'cases' not in data:
|
|
26
|
+
data['cases'] = {}
|
|
27
|
+
data['cases'][name] = case
|
|
28
|
+
json5.dump(data, open(json_file, 'w', encoding='utf-8'), ensure_ascii=False, indent=4)
|
|
29
|
+
|
|
@@ -12,6 +12,7 @@ from fastcodedog.prepare.pdm_to_model.before.additional_foreign_keys import fill
|
|
|
12
12
|
from fastcodedog.prepare.pdm_to_model.before.fill_tenant_id import fill_tenant_id
|
|
13
13
|
from fastcodedog.prepare.pdm_to_model.before.specified_column_types import rename_specified_column_types
|
|
14
14
|
from fastcodedog.prepare.pdm_to_model.before.specified_relationship_names import add_specified_relationship_names
|
|
15
|
+
from fastcodedog.prepare.pdm_to_model.after.case import add_cases
|
|
15
16
|
from fastcodedog.prepare.pdm_to_model.pdm import Pdm
|
|
16
17
|
|
|
17
18
|
|
|
@@ -36,5 +37,6 @@ def prepare_model(pre_process_scripts):
|
|
|
36
37
|
# rename_specified_class_names(ctx_instance.source_directory.model, pre_process_scripts['specified_class_names'])
|
|
37
38
|
add_computed_properties(ctx_instance.source_directory.model, pre_process_scripts['computed_properties'])
|
|
38
39
|
specified_relationship_orderby(ctx_instance.source_directory.model, pre_process_scripts['specified_relationship_by'])
|
|
40
|
+
add_cases(ctx_instance.source_directory.model, pre_process_scripts['cases'])
|
|
39
41
|
add_additional_methods(ctx_instance.source_directory.model, pre_process_scripts['additional_methods'])
|
|
40
42
|
add_copy_methods(ctx_instance.source_directory.model, pre_process_scripts['copy_methods'])
|
{fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/schema_and_crud_to_api/prepare.py
RENAMED
|
@@ -26,11 +26,13 @@ def crud_and_schema_to_api(crud_context, schema_context):
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
def prepare_api(pre_process_scripts):
|
|
29
|
+
def prepare_api(pre_process_scripts, specify_api=None):
|
|
30
30
|
# 先清空目录
|
|
31
31
|
shutil.rmtree(ctx_instance.source_directory.api, ignore_errors=True)
|
|
32
32
|
for module, cruds in ctx_instance.cruds.items():
|
|
33
|
-
for crud_context in cruds.
|
|
33
|
+
for model, crud_context in cruds.items():
|
|
34
|
+
if specify_api and model not in specify_api:
|
|
35
|
+
continue
|
|
34
36
|
schema_context = get_schema_context(module, crud_context.name)
|
|
35
37
|
file_path = get_api_file_path(module, crud_context.name)
|
|
36
38
|
write_json_file(file_path, crud_and_schema_to_api(crud_context, schema_context))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/commonfiles/configfiles/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/commonfiles/oauthfiles/__init__.py
RENAMED
|
File without changes
|
{fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/commonfiles/toolfiles/__init__.py
RENAMED
|
File without changes
|
{fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/commonfiles/utilfiles/__init__.py
RENAMED
|
File without changes
|
{fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/generation/commonfiles/utilfiles/api_logging.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/model_and_schema_to_crud/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/model_and_schema_to_crud/prepare.py
RENAMED
|
File without changes
|
{fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/model_and_schema_to_crud/queries.py
RENAMED
|
File without changes
|
|
File without changes
|
{fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/model_to_schema/alias_generator.py
RENAMED
|
File without changes
|
{fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/model_to_schema/no_input_fields.py
RENAMED
|
File without changes
|
{fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/model_to_schema/no_response_fields.py
RENAMED
|
File without changes
|
|
File without changes
|
{fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/model_to_schema/response_schemas.py
RENAMED
|
File without changes
|
{fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/model_to_schema/specified_field_types.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/after/additional_methods.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/after/copy_methods.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/pdm_to_model/before/fill_tenant_id.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/schema_and_crud_to_api/__init__.py
RENAMED
|
File without changes
|
{fastcodedog-3.1.7 → fastcodedog-3.2.0}/fastcodedog/prepare/schema_and_crud_to_api/schemas.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|