mirror of
https://github.com/fastapi-practices/fastapi-best-architecture.git
synced 2026-09-21 21:15:13 +00:00
Fix the code with outdated system config (#683)
This commit is contained in:
@@ -242,9 +242,6 @@ class Settings(BaseSettings):
|
||||
# Plugin Code Generator
|
||||
CODE_GENERATOR_DOWNLOAD_ZIP_FILENAME: str = 'fba_generator'
|
||||
|
||||
# Plugin Config
|
||||
CONFIG_BUILT_IN_TYPES: list[str] = ['website', 'protocol', 'policy']
|
||||
|
||||
@model_validator(mode='before')
|
||||
@classmethod
|
||||
def check_env(cls, values: Any) -> Any:
|
||||
|
||||
@@ -5,7 +5,6 @@ from sqlalchemy import Select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlalchemy_crud_plus import CRUDPlus
|
||||
|
||||
from backend.core.conf import settings
|
||||
from backend.plugin.config.model import Config
|
||||
from backend.plugin.config.schema.config import CreateConfigParam, UpdateConfigParam
|
||||
|
||||
@@ -21,7 +20,7 @@ class CRUDConfig(CRUDPlus[Config]):
|
||||
:param pk: 参数配置 ID
|
||||
:return:
|
||||
"""
|
||||
return await self.select_model_by_column(db, id=pk, type__not_in=settings.CONFIG_BUILT_IN_TYPES)
|
||||
return await self.select_model_by_column(db, id=pk)
|
||||
|
||||
async def get_by_key(self, db: AsyncSession, key: str) -> Config | None:
|
||||
"""
|
||||
@@ -41,7 +40,7 @@ class CRUDConfig(CRUDPlus[Config]):
|
||||
:param type: 参数配置类型
|
||||
:return:
|
||||
"""
|
||||
filters = {'type__not_in': settings.CONFIG_BUILT_IN_TYPES}
|
||||
filters = {}
|
||||
|
||||
if name is not None:
|
||||
filters['name__like'] = f'%{name}%'
|
||||
@@ -79,9 +78,7 @@ class CRUDConfig(CRUDPlus[Config]):
|
||||
:param pks: 参数配置 ID 列表
|
||||
:return:
|
||||
"""
|
||||
return await self.delete_model_by_column(
|
||||
db, allow_multiple=True, id__in=pks, type__not_in=settings.CONFIG_BUILT_IN_TYPES
|
||||
)
|
||||
return await self.delete_model_by_column(db, allow_multiple=True, id__in=pks)
|
||||
|
||||
|
||||
config_dao: CRUDConfig = CRUDConfig(Config)
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
from sqlalchemy import Select
|
||||
|
||||
from backend.common.exception import errors
|
||||
from backend.core.conf import settings
|
||||
from backend.database.db import async_db_session
|
||||
from backend.plugin.config.crud.crud_config import config_dao
|
||||
from backend.plugin.config.model import Config
|
||||
@@ -51,8 +50,6 @@ class ConfigService:
|
||||
:return:
|
||||
"""
|
||||
async with async_db_session.begin() as db:
|
||||
if obj.type in settings.CONFIG_BUILT_IN_TYPES:
|
||||
raise errors.RequestError(msg='非法类型参数')
|
||||
config = await config_dao.get_by_key(db, obj.key)
|
||||
if config:
|
||||
raise errors.ConflictError(msg=f'参数配置 {obj.key} 已存在')
|
||||
|
||||
Reference in New Issue
Block a user