mirror of
https://github.com/baiqwerdvd/ArknightsUID.git
synced 2025-05-04 19:17:33 +08:00
🐛 修正一下错误
This commit is contained in:
parent
ab3caab461
commit
e271f33e79
@ -5,7 +5,7 @@ import json
|
||||
import os
|
||||
import pickle
|
||||
import shutil
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from datetime import datetime, timedelta
|
||||
from pathlib import Path
|
||||
from tempfile import mkstemp
|
||||
from typing import Any
|
||||
@ -14,6 +14,7 @@ import anyio
|
||||
from anyio import Path as anyioPath
|
||||
from anyio.to_thread import run_sync
|
||||
from msgspec import Struct
|
||||
from pytz import UTC
|
||||
|
||||
from gsuid_core.logger import logger
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
from typing import Dict, Literal, Union
|
||||
from typing import Dict, Literal, Optional, Type, Union
|
||||
|
||||
from gsuid_core.utils.database.base_models import Bind, Push, T_BaseIDModel, T_User, User, with_session, BaseModel
|
||||
from gsuid_core.utils.database.base_models import Bind, Push, T_BaseIDModel, User, with_session, BaseModel
|
||||
from gsuid_core.webconsole.mount_app import GsAdminModel, PageSchema, site
|
||||
from sqlmodel import Field
|
||||
from sqlalchemy.future import select
|
||||
@ -78,6 +78,18 @@ class ArknightsPush(Push, table=True):
|
||||
training_is_push=False
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@with_session
|
||||
async def base_select_data(
|
||||
cls: Type[T_BaseIDModel], session: AsyncSession, **data
|
||||
) -> Optional[T_BaseIDModel]:
|
||||
stmt = select(cls)
|
||||
for k, v in data.items():
|
||||
stmt = stmt.where(getattr(cls, k) == v)
|
||||
result = await session.execute(stmt)
|
||||
data = result.scalars().all()
|
||||
return data[0] if data else None
|
||||
|
||||
@classmethod
|
||||
async def update_push_data(cls, uid: str, data: Dict) -> bool:
|
||||
retcode = -1
|
||||
@ -98,7 +110,7 @@ class ArknightsPush(Push, table=True):
|
||||
|
||||
@classmethod
|
||||
async def select_push_data(
|
||||
cls: type[T_BaseIDModel], uid: str
|
||||
cls: Type[T_BaseIDModel], uid: str
|
||||
) -> Union[T_BaseIDModel, None]:
|
||||
return await cls.base_select_data(uid=uid)
|
||||
|
||||
|
@ -2,7 +2,7 @@ import base64
|
||||
import json
|
||||
from collections.abc import Callable, Iterable, Iterator
|
||||
from copy import copy, deepcopy
|
||||
from typing import Any, Dict, List, Tuple, TypeVar, Union
|
||||
from typing import Any, Dict, List, Tuple, Type, TypeVar, Union
|
||||
|
||||
from msgspec import Meta, Struct, UnsetType, convert, field
|
||||
from msgspec import json as mscjson
|
||||
@ -29,7 +29,7 @@ class BaseStruct(Struct, forbid_unknown_fields=True, omit_defaults=True, gc=Fals
|
||||
|
||||
@classmethod
|
||||
def convert(
|
||||
cls: type[Model],
|
||||
cls: Type[Model],
|
||||
obj: Any,
|
||||
*,
|
||||
strict: bool = True,
|
||||
|
@ -51,6 +51,10 @@ extra_standard_library = ["typing_extensions"]
|
||||
[tool.pytest.ini_options]
|
||||
asyncio_mode = "auto"
|
||||
|
||||
[tool.pyright]
|
||||
pythonVersion = "3.8"
|
||||
pythonPlatform = "All"
|
||||
|
||||
[tool.ruff]
|
||||
select = ["E", "W", "F", "UP", "C", "T", "PYI", "PT", "Q"]
|
||||
ignore = ["C901", "Q000"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user