Skip to content

Commit 234bf70

Browse files
authored
Fix the code with outdated system config (#683)
1 parent 6d5e741 commit 234bf70

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed

backend/core/conf.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,6 @@ class Settings(BaseSettings):
242242
# Plugin Code Generator
243243
CODE_GENERATOR_DOWNLOAD_ZIP_FILENAME: str = 'fba_generator'
244244

245-
# Plugin Config
246-
CONFIG_BUILT_IN_TYPES: list[str] = ['website', 'protocol', 'policy']
247-
248245
@model_validator(mode='before')
249246
@classmethod
250247
def check_env(cls, values: Any) -> Any:

backend/plugin/config/crud/crud_config.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from sqlalchemy.ext.asyncio import AsyncSession
66
from sqlalchemy_crud_plus import CRUDPlus
77

8-
from backend.core.conf import settings
98
from backend.plugin.config.model import Config
109
from backend.plugin.config.schema.config import CreateConfigParam, UpdateConfigParam
1110

@@ -21,7 +20,7 @@ async def get(self, db: AsyncSession, pk: int) -> Config | None:
2120
:param pk: 参数配置 ID
2221
:return:
2322
"""
24-
return await self.select_model_by_column(db, id=pk, type__not_in=settings.CONFIG_BUILT_IN_TYPES)
23+
return await self.select_model_by_column(db, id=pk)
2524

2625
async def get_by_key(self, db: AsyncSession, key: str) -> Config | None:
2726
"""
@@ -41,7 +40,7 @@ async def get_list(self, name: str | None, type: str | None) -> Select:
4140
:param type: 参数配置类型
4241
:return:
4342
"""
44-
filters = {'type__not_in': settings.CONFIG_BUILT_IN_TYPES}
43+
filters = {}
4544

4645
if name is not None:
4746
filters['name__like'] = f'%{name}%'
@@ -79,9 +78,7 @@ async def delete(self, db: AsyncSession, pks: list[int]) -> int:
7978
:param pks: 参数配置 ID 列表
8079
:return:
8180
"""
82-
return await self.delete_model_by_column(
83-
db, allow_multiple=True, id__in=pks, type__not_in=settings.CONFIG_BUILT_IN_TYPES
84-
)
81+
return await self.delete_model_by_column(db, allow_multiple=True, id__in=pks)
8582

8683

8784
config_dao: CRUDConfig = CRUDConfig(Config)

backend/plugin/config/service/config_service.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from sqlalchemy import Select
55

66
from backend.common.exception import errors
7-
from backend.core.conf import settings
87
from backend.database.db import async_db_session
98
from backend.plugin.config.crud.crud_config import config_dao
109
from backend.plugin.config.model import Config
@@ -51,8 +50,6 @@ async def create(*, obj: CreateConfigParam) -> None:
5150
:return:
5251
"""
5352
async with async_db_session.begin() as db:
54-
if obj.type in settings.CONFIG_BUILT_IN_TYPES:
55-
raise errors.RequestError(msg='非法类型参数')
5653
config = await config_dao.get_by_key(db, obj.key)
5754
if config:
5855
raise errors.ConflictError(msg=f'参数配置 {obj.key} 已存在')

0 commit comments

Comments
 (0)