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