mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-14 08:30:01 +08:00
perf👌: 道具使用与签到
This commit is contained in:
@@ -46,7 +46,7 @@ class GoodsInfo(Model):
|
||||
daily_limit: int = 0,
|
||||
is_passive: bool = False,
|
||||
icon: str | None = None,
|
||||
) -> str | None:
|
||||
) -> str:
|
||||
"""添加商品
|
||||
|
||||
参数:
|
||||
@@ -73,7 +73,8 @@ class GoodsInfo(Model):
|
||||
icon=icon,
|
||||
)
|
||||
return str(uuid_)
|
||||
return None
|
||||
else:
|
||||
return (await cls.get(goods_name=goods_name)).uuid
|
||||
|
||||
@classmethod
|
||||
async def delete_goods(cls, goods_name: str) -> bool:
|
||||
|
||||
@@ -43,11 +43,15 @@ class UserConsole(Model):
|
||||
返回:
|
||||
UserConsole: UserConsole
|
||||
"""
|
||||
user, _ = await UserConsole.get_or_create(
|
||||
user_id=user_id,
|
||||
defaults={"platform": platform, "uid": await cls.get_new_uid()},
|
||||
)
|
||||
return user
|
||||
if not await cls.exists(user_id=user_id):
|
||||
await cls.create(
|
||||
user_id=user_id, platform=platform, uid=await cls.get_new_uid()
|
||||
)
|
||||
# user, _ = await UserConsole.get_or_create(
|
||||
# user_id=user_id,
|
||||
# defaults={"platform": platform, "uid": await cls.get_new_uid()},
|
||||
# )
|
||||
return await cls.get(user_id=user_id)
|
||||
|
||||
@classmethod
|
||||
async def get_new_uid(cls) -> int:
|
||||
@@ -56,7 +60,7 @@ class UserConsole(Model):
|
||||
返回:
|
||||
int: 最新uid
|
||||
"""
|
||||
if user := await cls.annotate().order_by("uid").first():
|
||||
if user := await cls.annotate().order_by("-uid").first():
|
||||
return user.uid + 1
|
||||
return 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user